Thinkorswim AutoTrade Almost 204


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.

DISCLAIMER: I AM NOT A CERTIFIED FINANCIAL ADVISOR AND NOTHING IN THIS VIDEO OR TEXT IS AN ADVERTISEMENT OR RECOMMENDATION TO BUY OR SELL ANY FINANCIAL INSTRUMENT. NOR IS THIS VIDEO OR TEXT INTENDED TO INSTRUCT YOU ON HOW TO MAKE BUY OR SELL DECISIONS USING ANY OF THESE INDICATORS.

*Thinkorswim is a chart analysis platform offered by TD Ameritradewww.tdameritrade.com

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;
Buy_signal.setpaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Buy_signal.setdefaultColor(color.dark_GREEN);
Buy_signal.hidetitle();
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;
Sell_signal.setpaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_down);
sell_signal.setDefaultColor(color.red);
Sell_signal.hidetitle();

About Pete Hahn

For those trying to contact me about our professional services you will find all those details here: https://www.hahn-tech.com/about/ Any questions not related to our professional services or premium indicators should be directed to the comment section of the applicable video or you may post a question in our Q&A Forum: https://www.hahn-tech.com/thinkorswim-forum-topics/

Questions? Comments? Post a review?

204 thoughts on “Thinkorswim AutoTrade Almost

  • 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 )

    thanks
    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.
    Thanks,
    JK

  • 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.