Thinkorswim Condition Wizard 44

Build Custom Scans, Alerts and Chart Studies Using Thinkorswim Condition Wizard

Wouldn’t you love to be able to create highly complex scans, alerts and chart studies? Frustrated from spending endless hours trying to learn how to write code? In this video, I show you how to use the Thinkorswim Condition Wizard to build highly complex alerts, scans and Condition Wizardchart studies. We start by showing a very basic example but we cover every detail so you won’t get lost. Then we progress to more complex solutions through a series of 5 examples. Each example is taken directly from posts to our Q&A forum. These are real world examples, posed by real traders just like you.


Examples included in this video:

  • Identifying stocks where the TTM_Wave C is light blue
  • Stocks above simple moving average the previous 3 bars
  • Three consecutive bars of 2% or more gain
  • Unusual option volume
  • MACD crossover below the zero line

Want to learn more?

Once you master these techniques, be sure to view our advanced Strategies video: Thinkorswim AutotTade Almost . This video explains how to use the Thinkorswim Condition Wizard to build chart strategies and conditional orders for automated trade execution. Also included are code templates. Which make it very easy to copy code from the Thinkorswim Condition Wizard and paste it into your own custom chart strategy.

For a complete understanding of Thinkorswim Chart Strategies be sure to view all our videos in this topic:

*Thinkorswim is a chart analysis platform offered by TD Ameritrade:

TD Ameritrade provides financial services including the trading of Stocks, Futures, Options and Forex.


Please be sure to share this page with your friends and colleagues. Leaving comments below is the best way to help make the content of this site even better.

Watch the video, Thinkorswim Condition Wizard below:

__ Support our free content by making a purchase below. Thanks! __

Questions? Comments? Post a review?

44 thoughts on “Thinkorswim Condition Wizard

  • 12decopas

    I want to scan while in premarket, all symbols that premark price are %20 higher than Previous Day Close.

    Afterhours_change, and gap_up studies doesn’t fit those criterias.
    So, I tried to simply reuse the code for study “Previous Day Close” as this



    input percent_change = 20.00;
    def pdc = PreviousDayClose();
    def precio = high(“period” = AggregationPeriod.DAY, “priceType” = PriceType.LAST);

    input aggregationPeriod = AggregationPeriod.DAY;
    input length = 1;
    input displace = -1;
    input showOnlyLastPeriod = no;
    def PrevDayClose;
    if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) {
    PrevDayClose = Double.NaN;
    } else {
    PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);

    plot scan = precio >= (((percent_change)/100)+1)*pdc;


    But error arraises “Seconday period not allowed: DAY”
    And if change that period by removing it, doesn’t work as spected.

    I imagine that this simple scanner has to be ready made but I couldn’t find it.

    Any help to achive my goals ?

    Thank you!

    • Pete Hahn Post author

      This request is entirely unrelated to the context of this video so it will be removed. Secondary aggregation periods are not supported in the Study Filters of custom scans and there is no way to work around this limitation.

  • Георги Караиванов

    There is no ASK or BID like on the clip, how to keep track what is the lowest price of the day and what is the current market price?

    • Pete Hahn Post author

      Lowest price of the day is “low” when set to the daily time frame. Current price is always “close” regardless of time frame. I don’t recall using the Ask or Bid in this video. Can you tell me where in the video you found that?

      • Георги Караиванов

        20:15 but it is for alerts, i guess it is different for condition.

        So basically if i undaunted correct to make scan that can show me if the lowest price of stock is above specific price and below currant market price i have to: plot scan = low > 10 and close < 11;

        One recommendation, add edit 😛

        Thx Pete, i just tried it and it worked!

        Happy new year and all the best to everyone 😉

    • Георги Караиванов

      I just need a scan that can show me if the lowest price of stock is above specific price and below currant market price :/

      • Pete Hahn Post author

        That is actually much easier to build then any of the examples provided in the video. Just keep practicing using the examples I provided and you will learn how to do the simply scans as well.

  • Ross C.

    Hi, really appreciate you posting these videos. I’ve learned a lot from them and have a followup question. Is it possible to execute a conditional order with a ratio of two stocks meeting a particular criteria or worst case, two criteria?

    Ideally, in scenario 1, it would something like execute advanced order for selling Stock A at a certain price that also triggers a buy order for Stock B given the condition when (StockB/StockA)<9

    Alternatively, in scenario 2, two conditions where both are met: (1) Stock A hits ask target of x and (2) Stock B bid is less than y, which would trigger an advanced order described above where you would sell A and buy B for limit orders at the x and y prices set

    Many thanks for any suggestions

  • CC

    Hi Pete,

    For a Study Alert with the Condition Wizard set to DAY Aggregate.
    How could you set it so it will check on that DAY condition but that will be checked at an specific Time every day?
    Lets say compare the SMA of today with the SMA of yesterday, but do it at 3:30pm.
    Thank you,


    • Pete Hahn Post author

      You cannot do that within the code. You would need to set that as a separate Study Filter of your scan or setup your scan to run at a specified time each day. Check the Q&A forum for resources. Far too complex to address here in the comments section of a video.

  • Rao

    Hi Pete,
    How can we sell orders based on buy price . IF I have multiple orders with different trade price , how can we sell only orders high are at given price .

    Greatly appreciate if you can help

    • Pete Hahn Post author

      This video does not cover anything you just inquired about. You need to contact the Trade Desk at TD Ameritrade. We cannot help you with this.

  • Scott Alexander

    This is an incredible site. Thank you so much for doing this. I’m wanting to write a script in TOS that will do things like give an arrow signal when a moving average crosses another moving average, or change the color of a volume bar when it’s higher or lower than a previous volume bar. Is this sort of thing possible using the condition wizard?

    • Pete Hahn Post author

      We have not yet created a video that specifically covers Condition Wizard for chart studies. However the video we published for custom watchlist columns will show examples of similar techniques which could be used to create custom chart studies:
      Also, be sure to search our Q&A forum. Tons of examples of custom charts studies. You are very likely to find solutions there that already do what you have in mind.

  • madhav

    Hello Pete,

    First of all Thank you for your time and effort for all the videos that you are sharing for us. I truly appreciate your help!!. Do you know any custom setups for momentum stocks that we can find based on the criteria for potential quick day trades? I saw most of the videos on the conditions of the previous close like 2 or 3 days of the price or volume action in sequence.

    Any help you provide is greatly appreciated

    • Pete Hahn Post author

      Thanks for the feedback. The materials I publish are meant to help traders learn how to do their own research. I don’t teach them how to trade but rather teach them how to fish for their own trades. Have you viewed any of our videos in the Strategies category? Those are the tools every trader needs to learn so they can do their own research and find trading opportunities uniquely suited to their own risk tolerance and goals.

  • Vahak Agojian

    I created the following script in TOS with conditions wizard. SimpleMovingAvg().”SMA” is less than close and SimpleMovingAvg().”SMA” from 1 bars ago is less than close from 1 bars ago and SimpleMovingAvg().”SMA” from 2 bars ago is greater than close from 2 bars ago then I went back after watching the video to assign background color but I get the invalid statement when trying to “Assign Background Color” to an existing script.

  • Nikolaos Skevofilax

    Hello Pete, first I’m like to thank you for all the good teaching you are providing us.My question for you is, I build a custom watch list on a Mac Pro. However, when activated the watch list I get “custom expression limit exceeded”. Can you pls help me. thank you for your time and help.

  • Sam

    Hello Pete,
    I’m looking to add the condition in the scan when 8,21,34,55,89 moving avg (Exponential) are overlapping each other, is there any way I can get this working?

    • Pete Hahn Post author

      What does that mean? Overlapping each other. You mean stacked? Shortest EMA on top, longest EMA on bottom, each moving average in order from top to bottom according to their length?

      • Sam

        First of all you’re amazing, thank you for quick reply. I’m looking for the the scan where ( 8,21,34,55,89) exponential moving avg are stacking up on each other (it doesn’t matter which one is on top or down), like they are in very tight range. Take current example of ticker “LK” on 78 minute chart, all my moving avgs are in very tight range. I attached picture, all yellow lines are exponential moving avg on 78 min chart. I tried many things but sadly It didn’t work. If any you can guide me, that would be really helpful.

      • Pete Hahn Post author

        yes, you can use any of the standard time frames that are supported by scans. This is really not the place to seek a solution of this nature. We have a Q&A forum were you can post a question. However I suspect that in order to complete this idea you have will take more time than I permit for free solutions I provide in the forum.

  • DeNice Spice

    Hi, thanks for looking at this question. I’m kind of lost on where I might find the answer later but I’ll try. You did a custom bollinger band squeeze with someone. I called TOS and we installed it. I wish for the bands to be tighter as I’m not seeing the tight bands. I’d like to go back about about five days for the squeeze. I’m kind of new to all this trading for only a year. Thx so much. Glad to hear you’re doing well.

  • Matt B

    Mr. Pete, I’m glad to see you are feeling better and are back in action. I’m having trouble logging in to your message board so I figured I would ask it here. Is it possible, on TOS, to code arrows to show up at cycle highs/lows determined by slow stochastics %D value crossovers? A cycle high being %D crossing above 45 and then back down crossing below 55. The cycle high would be the highest price in that “loop”. Sorry to post this here but I can’t seem to login to your webpage. Thank you sir, Matt B

  • Arlette Darty-Ochoa

    HI Pete I just found you on youtube, I really appreciate your teaching, that it is so great, thank you for all the time you put into

  • Steve

    Hello there, Pete! I am very glad to hear that your recovery has been so successful, and I wish you continued good health.
    I cannot express adequately how much I appreciate your videos, and their ability to broaden my understanding of TOS, and the awesome power it contains.
    This video in particular has opened my eyes to a part of TOS I had never considered using before your clear tutorial. I can only imagine ( laying in bed, awake, too late…) what can done with a bit of thinkScript studying in conjunction with the Condition Wizard. Really amazing- I, for one, would really be interested in further adventures with The Wizard!

    Thanks again,

    • Pete Hahn Post author

      Hi Steve,
      Thanks so much for your kind and encouraging words. I’m really excited that you found this video so useful. I certainly have plans for more in this series. Stay tuned.

    • Jim Porter

      I just today hit a bump and needed some help. I have been offline myself for a while so I was unaware of your problem. I am so pleased to hear that you are on the mend from a very serious condition. You have always been my GO TO resource when I encounter a problem and once again you gave me a hand across the gap in my knowledge of Thinkorswim ! I was unaware of all the posting you have made on the condition wizard, etc. so I will have a field day over the next week catching up. Seriously, you have helped me at least as much as Tech Support at thinkorswim, and on the more advanced features, well, as I said you have been my GO TO. Thank you ! and my VERY best wishes for a continued recuperation. I will have a field day going through the treasure chest (as I call it) of educational material I have missed in my absence.


      • Pete Hahn Post author

        Hi Jim. So very glad you found our content so useful. Great to have feedback that confirms I am hitting the mark.