Thinkorswim AutoTrade Almost 150

As Close As We Can Get To Auto-Trading on Thinkorswim

In this video we show how to build your own code using a point and click condition wizard. The condition wizard

Thinkorswim AutoTrade Almost

Thinkorswim AutoTrade Almost

makes it very simple to build your own set of rules for trade execution. However you may not realize the code generated by the condition wizard can be very easily inserted into a template to form a Strategy and/or Custom Chart Study. We supply the templates, and show you how to put it all together. You will learn how to build your code using the condition wizard and you will learn how to convert that into a Strategy file. And Using tools we provided in previous videos you will then be able to analyze the performance of those Strategies.

We also show you how to use the condition wizard to generate orders that will execute in the same way as those theoretical orders generated by the custom Strategies.
AutoTrades are not fully supported on Thinkorswim as on other platforms. However if you learn how to connect the pieces you can place conditional orders that await the signal created by a set of defined rules. Once the conditions are satisfied, the order is released from hold and becomes a live order.


*Thinkorswim is a chart analysis platform offered by TD

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 AutoTrade Almost below:


This is the code for the Strategy Template:
input tradeSize = 100;
def signal = 0;
addOrder(OrderType.BUY_TO_OPEN, signal, open[-1], tradeSize, Color.CYAN, Color.CYAN);
def exit = 0;
addOrder(OrderType.SELL_TO_CLOSE, exit, open[-1], tradeSize, Color.MAGENTA, Color.MAGENTA);

This is the code for the Study Template:
declare lower;
plot signal = 0;
plot exit = 0;

This is the code for the revised SLM Ribbons study:
input price = close;
input superfast_length = 8;
input fast_length = 13;
input slow_length = 21;
input displace = 0;
def mov_avg8 = ExpAverage(price[-displace], superfast_length);
def mov_avg13 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);
#moving averages
Plot Superfast = mov_avg8;
plot Fast = mov_avg13;
plot Slow = mov_avg21;
def buy = mov_avg8 > mov_avg13 and mov_avg13 > mov_avg21 and low > mov_avg8;
def stopbuy = mov_avg8 <= mov_avg13;
def buynow = !buy[1] and buy;
plot Buy_Signal = buynow and !stopBuy;
def sell = mov_avg8 < mov_avg13 and mov_avg13 < mov_avg21 and high < mov_avg8;
def stopsell = mov_avg8 >= mov_avg13;
def sellnow = !sell[1] and sell;
Plot Sell_Signal = sellNow and !stopSell;

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

Questions? Comments? Post a review?

150 thoughts on “Thinkorswim AutoTrade Almost

  • Jack

    Pete, as always, thank you in advance for all the information you provide. I’m looking at creating strategies for back testing and wondering if there is a way to enter a closing trade that either follows a trailing stop, ATR Stop or a physical stop “x” from the open?

    • Pete Hahn Post author

      There are several built-in chart strategies included with Thinkorswim that already provide similar functionality. Just add them to your chart, test them out and pick the one that works for your particular preferences.

  • David

    Great stuff, thank you!
    After setting up a buy order that triggers a sell order with the conditions in my strategy, is there any way to have ThinkOrSwim kick off another duplicate buy and triggered sell order if I saved the original buy and triggered sell order with the conditions as a template?

    Since my strategy kicks off multiple buy and sell combinations every day on a specific stock, I’d like for ThinkOrSwim to manage the day’s multiple buy and triggered sell orders instead of my babysitting all day for that stock.

    • Pete Hahn Post author

      Sorry but no. And that is the exact reason the word “Almost” is included in the title of the video. I did explain this in the video so be sure you watched the entire video before you start wondering about how you plan to apply this knowledge. Thinkorswim developers have purposefully made it impossible to create fully automated trading systems using the Conditional Order tool.

    • charleyc

      Hi David and Peter, I had the same question and I am trying a “1st Trgs Seq” order, under Advanced orders to set Triggered Condition orders. Peter has mentioned that conditions can not be automated but can it be triggered?
      I can’t find much on “1st Trgs Seq” in TOS education, I also have not found anything on Peter’s site. BTW, Peter thank you for your knowledge. I supported you with a donation.

      I first tested conditions, studies and strategies based on Peter’s video “Almost Auto” and exported to spread sheets and studied outcomes. Working nicely. I then wondered if I can use “1st Trgs Seq” under Advanced Orders to set triggered condition orders.

      I created the order (In Paper Money but have not executed in Real) by first setting a Buy condition order and under the Advanced Order tab, I set it as a “1st Trgs Seq” order. I then clicked on “Create an Opposite Order” by clicking on the dash icon to the right of the gear icon in the order entry line. It placed a Sell condition order to be triggered after the 1st order is filled. Confirm and edit your condition. I then clicked on “Create Duplicate Order” (right of gear icon) of the 1st Buy condition. It placed it as the third in the sequence. Lastly I duplicated the sell condition order as the fourth. So under Monitor it looks like this: 1st Buy condition (WAIT COND), 2nd Sell Condition (WAIT TRIG), 3rd Buy Condition (WAIT TRIG), 4th Sell Condition (WAIT TRIG).

      Unfortunately I can’t test condition orders in OnDemand or Paper Money (A BIG flaw in TOS – looking into Tradestation). I might try it in Real Money by buying one cheap stock in the condition and watch it.


      • Pete Hahn Post author

        Nope, sorry I have nothing to say here. Seems to me you are trying to find a way to remove the word “Almost” from the title of this video. Fully automated systems are not supported and Thinkorswim developers have intentionally made it impossible to create an automated system using this platform. It’s not an oversight or a accident. They intentionally removed any possibility of fully automating any trading system on Thinkorswim. You do not need to waste any more time trying to get that to work.

  • Khoa

    1. Is the purpose of studies and strategies just to see where those conditions shown up on the chart? We won’t know whether those strategies make profit or not unless we place the orders? That kind of defeat the purpose of verifying whether our strategy is good or not. It seems like I’m missing something obvious.
    2. When placing a sell order, how can we tell it to sell only if there are shares available? After I confirm a sell order, its status was “REJECTED. This stock can not be borrowed.” I assume this meant there are no available shares to sell.

    • Pete Hahn Post author

      1. Back testing is where you should have begun your learning. The following videos are prerequisites to this video:
      But this was clearly explained in the video description.
      2. You are correct in that you must have an open position before you can create an order to close a position. It is impossible to enter the sell order before you have executed the buy order and hold those shares in your account. This is a fundamental and basic concept of trading.

      • Khoa

        It was a silly oversight. I turned off the study on the chart and didn’t remember until I watched your reference videos again!!! That was why the trade executions didn’t show up on the chart. I made a contribution. Your videos and explanation were great resources. Thanks again.

  • Khoa

    Pete, appreciate sharing the knowledge. I was looking for “wait until”, “wait for” condition in thinkscript and came across your video. For ex, if RSI crosses below oversold, wait for/until StochasticFast converges (K over D) for at least 2 green candles. I think in the video you use “within X candles” as the time period. What if that X isn’t long enough? We just have to specify X a big number? Is that the only way (i.e. no true wait until condition in thinkscript)?

    • Pete Hahn Post author

      1. Fully automated trading is not supported
      2. We cannot create a Conditional Order that uses Heiken-Ashi candles because those required the use of recursive variables. Which are not supported in Conditional Orders.

      • raviraj hiremath

        Ty. if we give you the requirements would be able to write the code on HA reversals. and how much would you charge?

      • Pete Hahn Post author

        Yes, there are many available platforms that support fully automated trading systems. Some of them are: TradeStation, Sierra Chart, Interactive Brokers, NinjaTrader and Esignal.

      • allen

        Hello Pete, Love the site and the videos!!! Do you know if it’s possible to create TOS Strategy using the conditional wizard? Every time I create a condition with the Condition Wizard, then I add ‘addOrder(OrderType.BUY_AUTO, no);’ the code turns red and it tells me the ‘Condition Wizard doesn’t recognize “addOrder”

        Thanks again for all you do

      • Pete Hahn Post author

        It is very odd that you are asking this question in the comments section of the very video that I would refer to in order to answer your question. I suggest you go back and view the video again and take your time to learn and practice using each of the examples I provided.

  • jerryravi1

    Thank you for the detailed explanation. I am looking for alerts when the price crosses over the lower Bollinger band and RSI crossing 25 and alerts on reversal at the higher BB. How can I do that?

  • Brett Lehmberg

    I used the method you showed in creating a conditional order and it produced “RSILaguerre().”RSI” crosses above 0.2″. In the conditional order screen in the bottom window it showed that it was functioning. When I paste the same code in the strategy creation screen it turns red and says “No such function: RSILaguerre”. Am I missing something?
    def signal = RSILaguerre().”RSI” crosses above 0.2 and RSILaguerre().”gamma” is less than 0.4;
    Thank you for your help!

    • Pete Hahn Post author

      Not much I can do from the comments section of the video. Did you include the template provided and make the changes demonstrated in the video to convert the code generated by the conditional order into code that runs as a chart strategy?

      • Brett Lehmberg

        Thank you for your response. Yes, I copied the line from the conditional order and placed it into the chart strategy just as you showed. In the chart strategy though, it is not recognizing RSILaguerre. I noticed that while in the chart strategy creation screen that the RSI Laguerre study is not in the drop down list on the right where I find all of the other studies. Could that be the problem?

      • Pete Hahn Post author

        The most likely reason for this is that there no such study that is included with Thinkorswim. You must have added this as a custom chart study. In most cases it is not advisable to reference custom study names because it often leads to unexpected results or entirely fails to work. So for custom chart studies it’s best to use the entire code instead of just a reference to it. But that is beyond the technical abilities of the average user.

  • foda

    Pete, You are very talented and gracious in sharing your knowledge with us.

    I have had instances where I have had 4 conditions studies to a conditional order and they were 310 characters. When I saved the order and tried to use it again, TOS had truncated the condition to around 200 characters.

    Have you run into this issue and if so, how did you get around it?

    Keep up the excellent work.

    • Pete Hahn Post author

      This issue has already been posted in our Q&A Forum. Users of Thinkorswim have found that it is not possible to create a Conditional Order, save it as a template, and then use that saved order template to place an order for the same or another ticker symbol. This is an issue that should be submitted to TD Ameritrade support because there is no solution that can be implemented by the end user of the platform. (They have a bug in their platform and it needs to be fixed).

  • Bob

    Very nice presentation and well thought out. Thanks for doing this. But is there a way to save the order as a template so it will be valid for any stock? I’ve created the autotrade from your description and before hitting ‘Confirm and Send’, I saved a custom order template. But when I enter a different symbol and use the saved template (then click on the gear and change the symbol for the study), the order appears but will never execute. I’ve tried this with other studies as well. So my question is: Is there a way to save the order as a global template so all I have to do is select ‘Buy Custom’, select the custom order, select the gear icon, and change the symbol. I have a list of 50 stocks or so that I’d like to trigger if certain conditions are met, but it is way too time consuming to run through the process for each one. Another way to ask the question: Do I have to go through the entire process for each stock that I want to trade automatically?

    • Pete Hahn Post author

      This has already been discussed in the Q&A forum and unfortunately there does not seem to be a way to save a conditional order as a template and apply it to other ticker symbols. Perhaps this is something that should be submitted to TD Ameritrade as a feature request.

  • Richard S

    Hello Pete/ First off, thanks so much for all your generous contributions on this site. I’m trying to create a divergence code that simply compares highest high or lowest low to RSI and MACD histogram for a 20 day period. I was somewhat successful using the study alert in the marketwatch area, but after copying and pasting to the scan tab, it will not produce any results. Any thoughts on what I may be doing wrong?

  • Raj

    I have been watching the videos on your site and have learnt so much over the last few weeks. I was hoping to get your recommendations on some of the top platforms that support full automation of a strategy. Thanks.

      • Pete Hahn Post author

        Of the two I have worked with in the past I can only recommend TradeStation. Not because it’s better than the others, but because it’s the only viable trading platform that supports fully automated trading AND for which I have experience using and building automated trading systems.

  • Cesar

    Hi. I’d want to ask you if it’s possible to do a script that follows last price of a stock, compare it to last prices and, according to the difference between the last price and the previous ones, following them second by second, sends buy and sell orders. Once it sells the stocks, it starts looking again the moment for buying and so on. Thank you very much.

    • Pete Hahn Post author

      What you have just described is a fully automated trading system and I made it perfectly clear in this video that fully automated trading systems are not supported in Thinkorswim.

  • Elvin

    Hi Pete. Thanks for all the content on here. I setup my left column for the ttm squeeze and have it on different time frames on tos. lights up red when theres a squeeze…. Is there any way to set it to ticks?

  • Michael Godwin

    Can a scanner script be written for Ichimoku signals? Price action above Clouds, lagging indicator above price action, averages cross & future cloud green? & or the inverse for shorts?

  • Ben

    Thanks for your detailed explanations and this is really helpful!! I do have a question in regards with triggering orders based on Study Condition.

    I am trying to create a Study order (BUY) which basically using the HullMoving average

    input price = close;
    input length = 8;
    input displace = 2;
    def HMA = MovingAverage(AverageType.HULL, price, length)[-displace];
    def hmaAscending = HMA > HMA[1] and HMA[1] > HMA[2];
    plot trigger = (hmaAscending and !hmaAscending[1]);

    This code perfectly shows/plots in the conditional wizard window in the Alert lower section. But when I save it and go Put this into a order it does not buy even though it should according to the script. I’m trying to buy when the HULL changes the color only on a uptrend.

    Can you please help?


    • Pete Hahn Post author

      Addressing issue like this in the comments section of a video is not possible. I suggest you take the time to search the strategy guide topic of our Q&A forum for guidance.

      • Ben

        Thanks Pete for your response.

        I am trying to create a BUY and SELL using HullMovingAvg. Convert it to a Conditional Wizard code as it looks like doesnt like the above complex code for the Conditional Wizard.

  • Sarthak

    Thanks for the elaborate explanation it is very helpful. My buy condition order produces 2 data points however my sell condition order produces around 8 data points. How can I make sure when these orders are executed the buy order executes first and then the sell order. I don’t want to be short shares in my account. Basically how do I link sell order to only occur after the buy order?

    • Pete Hahn Post author

      It seems you have missed one of the most important details explained in the video. There is no way to fully automate a trading system in Thinkorswim. Keyword from the video title: “Almost”. You can automate the entry. Only AFTER that order is triggered you can automate the exit. Only AFTER that exit is triggered can you automate the next entry. You cannot automate both entry and exit together. Thinkorswim has intentionally made fully automated trading impossible. The video explains the absolute limits of what is possible. Not an introduction, but the pinnacle of what we can achieve.

  • Bharat

    Plz help:
    I would like to put conditional order on TOS. I want to use 3 Min Candle and want to buy a 355 CALL option of XYZ(say it is trading at 343) when 3 Mins candle “CLOSE” is greater than or equal to 350 Resistance price of XYZ.

    And second new order is to BUY PUT(3 Mins Candle): When XYZ stock price break support area of 343 break. Buy PUT when 3 Mins candle CLOSE price is at or below 343.

  • doug brock

    question; need hand holding for -autotrade-almost. /ES 1minute chart;(movavgExponential, close price; length 7; displace 0; show breakouts yes)

    want to Buy 1 contract on EMA up-signal /sell 1 contract on EMA down-signal (boolean signals, I assume)

    (obviously each contract needs to be closed, as the new transaction is being initiated; hopefully autotrade can run for hours, unattended )

    Doug ( thinkorswim user since circa 2016)

    • Pete Hahn Post author

      The answer to the question you did not ask is no. It is not possible to to auto trading on Thinkorswim. Go back and look at the video title. You see the word “Almost”? That is the part that means this is not possible. The video explains the very limits of what is possible in Thinkorswim. This is not an introductory video with more advanced techniques left out. This is the full boat.

  • JK

    Hi Peter,
    Can you do this with options? I trade exclusively the SPY and have my system for 10% a day, and I now want to automate it.

  • akram

    Hi Peter,
    I am trying to do a conditional order but I want to execute at a specific time interval. How can i specify 1Day 1min, or 1Day 5min etc…? it seems it is defaulting always to 1Year 1 Day

  • Jerry Law

    Hi Peter,

    I am Jerry, i am very new to writing script in thinkorswim, i got some problem about the script.
    Could i get some advice from you and other experienced platform user??

    • Pete Hahn Post author

      I have removed the code from your comment. This is not the place to request assistance. You will need to post this in the Q&A forum. When you code contains more than 2 dozen lines of code you will need to save it as a plain text file and attach it to your Q&A post to conserve space. The errors you included in your comment indicate that you changed plot statements to def statements without removing the style statements. If you don’t understand what I just said then you probably need to spend several more months learning to write in this scripting language. Start with the basic before trying something this advanced.

    • Pete Hahn Post author

      There is a setting that allows the chart strategy to add to the theoretical position for each new entry signal. As soon as an exit signal appears the chart strategy will close all open positions. If you have the order types setup to “stop-and-reverse” then the first new exit signal is going to close all the existing long positions and enter a new short position.

  • Joy Banerjee

    Hello Pete,
    Your videos are awesome. I just started with Tos Script, and have a simple question: How can I make sure that my strategy (which i am backtesting) will always start with a buy order? I have both buy and sell definitions, but on the graph the first order shown is always a sell order. When I inactivate sell (#), then a buy order will be shown, otherwise not. What am doing wrong?
    Thank you!

    • Joy Banerjee

      This would be the code:

      input priceClose = close;
      Input priceOpen = open;
      input fastSMALength = 20;
      input fastEMALength = 9;
      input slowSMALength = 200;
      input averageType1 = AverageType.SIMPLE;
      input averageType2 = AverageType.EXPONENTIAL;

      def FastSMA = MovingAverage(averageType1, priceClose, fastSMALength);
      def SlowSMA = MovingAverage(averageType1, priceClose, slowSMALength);
      def FastEMA = MovingAverage(averageType2, priceClose, fastEMALength);

      Def Buy = FastSMA > SlowSMA and FastSMA[1] < SlowSMA [1];
      Def Sell = FastSMA SlowSMA[1];

      AddOrder(OrderType.BUY_TO_OPEN, Buy, close, tickColor = GetColor(4), arrowColor = GetColor(4), name = “ENTRY”);

      AddOrder(OrderType.SELL_TO_OPEN, Sell, tickColor = GetColor(6), arrowColor = GetColor(6), name = “EXIT”);

      • Joy Banerjee

        Sorry, not sure what happened when I pasted the code here.

        def Buy = FastSMA > SlowSMA and FastSMA[1] < SlowSMA [1];
        def Sell = FastSMA SlowSMA[1];

      • Joy Banerjee

        It’s not pasting my full code, not sure why. Trying this one more time.
        My “def” is never capitalized, but when I paste it here, the browser seems to turn it into “Def”, and it also doesn’t paste the full line, omitting the “<" in the def Sell….

        My def Sell says: Sell when the FastSMA is below the SlowSMA and when the FastSMA[1] was above the SlowSMA[1] before.

        I am hoping once I hit Post Comment some characters above won't disappear. Thank you!

      • Pete Hahn Post author

        Much easier if you post this question in our Q&A forum. The comments section of a video is not the place to try and paste code. However I can tell you that the order type for your sell order should be changed to this:
        AddOrder(OrderType.SELL_TO_CLOSE, Sell, tickColor = GetColor(6), arrowColor = GetColor(6), name = “EXIT”);

      • Joy Banerjee

        Pete, thanks for your quick reply. OK, noted, next time it will be in the Q&A section.

  • Adam

    Hi Pete,

    I’ve only been using the TOS platform for a couple months. So my solution may be something obvious.
    I have a pretty good order system using Conditions to drive my Buy, which triggers my OCO sell orders.
    One being a trailing stop loss, and the second is the one I’m having issues with.

    My sell is also conditional , but I I’d like to delay any sale until after my order has reached a 2% gain.
    Originally, I tried a Limit order with conditions, the conditions worked great, letting the price rise past the limit when the stock was running. However, when the conditions tripped, the Limit order would be submitted at the original limit price where it executes. Sometimes the current price would be 5-6% past the original Limit price, but the sale goes through at the limit price, vs. the current market price.

    My next attempt was to use a trailing stop, or market order which gets submitted when the Sell Conditions are met. This worked okay, but would often trip before my 2% gain. I could setup a condition that would allow me to drive it with 2% from the DailyLow or 2% from the DailyOpen, but I couldn’t figure out a way to get 2% from my Buy.

    Is there a solution that allows me to hook my Buy price in to a condition?
    Or is there another solution, that would allow me to Buy, then wait 2%, then check that the other sell conditions are met before Selling?

    any help would be appreciated, thanks

    • Pete Hahn Post author

      This is lightyears beyond the level of complexity we can properly address in the comment section of the video. This question is best posted to our Q&A forum. But before posting a new question in the forum you need to boil this down to a short bullet-point list of specifications. There is no way to create compound conditional orders. So if you are trying to apply conditions to any OCO branch of the original order… you can’t get there from here.

    • keith j miller

      possibly what you may be satisfied with is a limit sell that triggers conditionally but the limit price is changed from “MAN” to “MARK” and set it to +- a small percent or a few cents. this will be the MARK of the equity (or option) at the time the condition triggers plus or minus what you specify.

  • Ben Bakondi

    Is there a way to have the custom conditional orders remain active or re-activate to become “working orders” again so that subsequent trades can be executed according to the “signal” without having to re-enter the conditional orders each time? Perhaps this can be done through a bracket or multi-leg/First-Triggers order? Or perhaps through a third-party platform? if not, what would be the simplest way to save custom conditional orders for quick re-entry ?
    Thank you!!

    • Pete Hahn Post author

      This has already been asked and answered in the Q&A forum. It is not possible to have conditional orders regenerate. The order itself can be saved as a template order. However your conditional order must contain the full code and not just a reference to other study(s).

      • Dustin Spilchuk

        I would like to auto trade from just candlestick patterns but im not sure how to go about doing this. no bollanger bands or anything just simple candlestick patterns. take a HighPriceGappingPlay pattern and set an auto trade based off it, with a 1R stop loss and a 2R profit?

      • Dustin Spilchuk

        OK Pete thanks I didnt realize you offered a service like that. Would you work with me in so that I can learn thinkscript?

      • Pete Hahn Post author

        I do not have a formal curriculum at this time. However those wanting to learn the basics of thinkscript have been posting in the Q&A forum when they get stuck. With over 1,000 posts in the Q&A forum, it has become a vast and searchable knowledge-base of custom thinkorswim solutions.

  • Ray

    Pete thanks for the video. I had to watch @ minute 25:17 several times. I was a bit confused when you pasted the exit strategy where the signal should go and the signal where the exit should go..

  • Couch

    Pete, thanks so much for the strategy details & your video was extremely helpful. Do you ever notice conditional orders not always firing off when a buy or sell signal appears?

    • Pete Hahn Post author

      I do not use conditional orders on a regular basis so I have not experienced any of these issues. Make sure all your order are set to Market or Stop. Any order set to Limit are very likely to fail because by the time the signal triggers the order the price has moved away from that limit price.

      • Pete Hahn Post author

        No. A limit order of any kind does not ensure execution. Limit orders on ensure an execution price. However they can never ensure an execution will occur. Because the price of the limit order must be reachable within the bid/ask spread at the time the order is sent to the market.

  • Mario

    Pete thank you for taking time to do these videos! Is there a way to build a buy order to buy when the low is above the middle VWAP?

      • David

        Hi Pete, thanks for the great video. Is there a work-around for the conditional order not accepting VWAP? Thanks

      • Pete Hahn Post author

        Not at this time. The VWAP study that comes with Thinkorswim uses two functions that are not supported in Study Alerts or Conditional Orders.

      • David

        Hi Pete, thanks for the feedback. Does that mean that using TOS, there is no way I can have TOS alert me every time that the price crosses the lower VWAP bound? I’d be interested in hiring you for 30 minutes of your time to walk me through some of this, if there is a way to do it (via paypal). Thanks

      • David

        Thanks Pete – I may do that, but the time minimum may make that not possible (I’d have to save up alot of ideas or something)… To clarify your comment though, does that mean that I can’t back test a strategy in ToS that uses VWAP? thanks again…!

      • jean

        for the ichimoku scan i tried to download but when i get to tos i cant see the the code. i use the same process for the ichimoku strategie. sorry my English is not enough. im from montreal. and thanks for what u are doing.

      • Pete Hahn Post author

        This video does not provide any code for an Ichimoku scan. This video only provides code for the strategy and scan templates, along with code for the SLM Ribbon.

      • jean

        i know i came here because i can not post in the video of ichimoku scan the platform dont allow me ,so i came here. sorry for this.For the ichimoku study i was able to download on tos. but for the scan i cant. i can see he download on my computer but if i go to import i can not

  • randy kreisel

    Pete, You are very talented and gracious in sharing your knowledge with us.

    I have had instances where I have had 2 conditions to a conditional order and they were not that big. When I saved the order and tried to use it again, TOS had truncated the condition to around 200 characters. Raised ticket with TSO and they confirmed there was a limit but not able/willing to share the details.

    Have you run into this issue and if so, how did you get around it?

    Keep up the excellent work.


  • bruce macdonald

    Hi Mr Hahn. In reviewing the excellent video regarding the TOS almost auto trade set up I believe at 25:23 in the video the lower plot construction the way you describe it, appears to show entry signals and exit signals that were exactly opposite from what you show in your own set up at 25:33 or am I missing something?
    Best regards

    • Pete Hahn Post author

      You are correct. You are only the second person to notice this. The other person found it 10 months ago but posted their comment on the YouTube channel. Thanks for paying close attention to the details.

  • dennis mccabe

    i love this altho TOS is very limited on its workability of ATRtrailstop strategies i would love to see ATRtrailstop crossover alerts and a conditional order that executes at a specified time and triggers on reverse orders thru out the trading day at crossovers

    • Pete Hahn Post author

      You will need to move to another platform to achieve that. TradeStation is one. But the orders can only be submitted from a live chart. There is now way to store the conditional orders on the server, as we can with Thinkorswim.

      • dennis mccabe

        excellent, i really am interested in your work and this site has opened new and exciting doors for me, thank you sir, keep up the good work!!!!

      • Pete Hahn Post author

        Well for sure I will need to know where you found these expired URL’s. Certainly you did not find them in the comments section of this video. I can’t address the problem unless I know where you found these.

  • martin orellanes

    hello Hahn, excellent presentation in the video thank you for sharing it, but I have a doubt is it possible that the platform generates the real purchase and sale order in each signal of the strategy?

      • c0smik

        No better way to learn than from the firehose! Thanks for the reply, I did wonder if I was asking too early 🙂

        Could you help me with two more questions on TOS and automation? Is it possible to:

        -set up a sell rule that compares market price to a previous buy order?
        -set a sell rule that is triggered after a specific amount of time has elapsed from a buy order?

        Thanks again for your time and thoughts

      • Pete Hahn Post author

        So those two question each require the code to have the ability to read from the order book. This is not possible with Thinkorswim. The conditional order can only send an order to market based on the study parameters and rules contained within it.

  • Jay

    Hi Hahn,
    I have a quick question for you, I want to modify this strategy into buying when EMA 9 crossed above VWAP however when I go into condition wizard VWAP is under price and when I add VWAP on to the condition wizard chart it looks completely different than normal VWAP. There are no upper and lower bands and VWAP line is completely wrong so my strategy never comes out correct. what can i do to fix the vwap in condition wizard?

    Thank you for your time and any help

    • Pete Hahn Post author

      Well you cannot use the vwap that appears under the “price” category. You would need to use the one that appears under the “study” category. Not sure if it’s supported though.

  • Troy.B

    Hi Mr Hahn, Thank you for all that you have done for us little guys. Please forgive me if im posting in the wrong section .
    Have you ever seen this indicator before? ( ) its called pip breaker and is used for forex trading only. would you be able to build an indicator similar to this one for the thinkorswim platform?
    Thanks for your time.

    • Pete Hahn Post author

      Reverse engineering other indicators without source code. Not what we do here. If you have source code or the exact specifications for how the indicator functions we can work with that. The indicator must be open source and free of copyright.

  • Bennett Williford

    Is there a way on ThinkorSwim when you create the orders based on the conditions in the study to automatically renew when their conditions are met for the first time? Every time my orders are filled, the conditional order goes away. This doesn’t allow for my strategy to continue to autotrade over and over. It only allows for an autotrade one time based on that condition. After that I would have to manually input the conditional order.

  • Evelina

    Pete, do you happened to know what trading platform allows conditional order with secondary aggregation (to implement your MTF MACD) or what trading platform has automated trading ?
    zillions thanks for your always super useful posts

  • Mark Baker

    I love this concept, it has incredible potential. But like you say in the video it would be very dangerous to use this without extensive testing. Here is my problem, when I am using paper money TOS will not allow me to use the study filters. It says that I don’t have permission. I contacted one of the TOS tech’s on the chat and he says that study filters are not available in paper money. I find this hard to believe because I saw you using study filters with paper money in the video. What am I missing? …I don’t really want to do testing on my live account.

    • Pete Hahn Post author

      My reply via email is copied below for the benefit of other viewers:
      In the video I make use of the Study Filter for some examples but most of the work is done in the Condition Wizard tied to an order. Make sure you are no confusing the two. Because as you say the Study Filter is not available in PaperMoney. So when you see me logged into PaperMoney, I am modifying an order, using the Condition Wizard.

      To sum things up. There is no reason to use PaperMoney to build alerts using the Study Alert. Because the Study Alert has nothing to do with order execution. Make sure you understand there are two completely different tools here. The Study Alert can be used to do initial testing. Then move to PaperMoney and enter orders, applying that same code to the Condition of each order.

  • Scott Blomenkamp

    Great video, I am trying to apply your technique using the pricechannel study and am having a issue. I am trying to use the upperband to trigger the buy and the lower to trigger the exit. The study part shows shows what appears to be the correct triggers. However the stratedy code seems to apply both to the upper band.

    declare lower;

    plot signal = high crosses above PriceChannel().”UpperBand”;

    plot exit = low crosses below PriceChannel().”LowerBand”;


    input tradeSize = 100;

    def signal = high crosses above PriceChannel().”UpperBand”;
    addOrder(OrderType.BUY_TO_OPEN, signal, open[-1], tradeSize, color.CYAN, Color.CYAN);

    def exit = low crosses below PriceChannel().”LowerBand”;
    addOrder(OrderType.SELL_TO_CLOSE, signal, open[-1], tradeSize, color.MAGENTA, Color.MAGENTA);

  • Hilario Dsouza

    Hi Pete,
    Thanks for the video and the code.
    I copied the code (from the strategy template) and pasted it into a new study on a 2 min time chart for /TF, but I do not see any orders show up on the chart, like in your video. I have tried various things and they refuse to show. I even opened TOS from a different computer :). Any ideas


  • Terry C

    Hi Pete,
    I have been studying your recent youtube “Thinkorswim AutoTrade Almost” video.
    It has been very educational!
    Thanks for distilling the process down so elegantly.
    I have been attempting to set up a conditional order through the wizard that applies to Options on ETF’s that I track on a 10 tick Renko Bar chart.
    I see that in the wizard, the only chart options are from 1 minute to 1 month. There are no tick options nor any way to identify a specific type of bar (i.e. Renko 10 ticks).
    Do you know of any way to set up a conditional order with the chart criteria I mentioned?
    Your assistance is greatly appreciated.

    • Pete Hahn Post author

      Hi Terry,
      Thanks for the feedback. At this time there are no options for Tick, Range or Renko charts using conditional orders, scans, or study alerts. Be sure to submit this to support@thinkorswim as a feature request. If enough folks request this they are likely to add this in a future release.
      Take care, good luck in your trading.

      • Ian Simpson

        Hi Peter.
        I am needing someone to build a EA to pick up Limit Orders from somewhere maybe Telegram and plave on TOS platform, can you help or know of someone who could.