Thinkorswim Strategy Guide 48


Basic Overview of Using Strategies in Thinkorswim

Thinkorswim Strategy Guide

Thinkorswim Strategy Guide

So you have this trading strategy but you have no idea how it performs. Wouldn’t you love to be able to have Thinkorswim automatically test your strategy for you? And wouldn’t it be great if it let you export the trade details so you could analyze them in a spreadsheet? Yeah, it can do that. This video, “Thinkorswim Strategy Guide”, shows you how. The video even includes a link to download a custom strategy that can both long and short entries. The link is embedded within the video so be sure to watch for it. This amazing feature in Thinkorswim is explained step-by-step. If you want to see more videos on this topic just be sure to like the video and leave some comments below.

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 Strategy Guide below:

Edit 2015-09-03:

A viewer requested the lower study version of a strategy demonstrated in this video. The time stamp where this appears is around 11:22 and the study is called “Strat_PivotRev_TrailSqz”. I decided to make this available to everyone right here at the end of this post. The code is displayed below. Just select the text of the code and copy it to your clipboard. Then in the TOS platform go to the edit studies window and click the ‘New” button in the lower left. You can name the study however you like, then paste this code into that window, being sure to first clear away any text that shows up by default.  Hope it helps. If you any further questions just leave a comment in the box below.
declare lower;
input direction = {default "Long", "Short"};
input tradeSize = 100;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
def SlowD = reference StochasticFull(80,20,KPeriod,DPeriod,priceH,priceL,priceC,3,averageType).FullD;
def pivotLow = low > low[1] and low[1] < low[2] and low[2] < low[3];
def pivotHigh = high < high[1] and high[1] > high[2];
plot pivotLowReversal = ( pivotLow and close > high[1] ) or ( pivotLow[1] and close > high[2] and low > low[2] and high[1] < high[2] );
plot exitLong = SlowD < SlowD[1] and SlowD[1] < SlowD[2] and highest(pivotLowReversal[0],2) == 0;
def entry;
def exit;
switch (direction) {
case "Long":
entry = pivotLowReversal;
exit = exitLong;
case "Short":
entry = no;
exit = no;
};

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

Questions? Comments? Post a review?

48 thoughts on “Thinkorswim Strategy Guide

  • Mohammad

    Hi Pete, thanks for putting these wealth of knowledge. For the life of me I couldn’t download this “Long Haul” Strategy. So I took the screen shot and converted and verified the code form your video. But I am getting error on entrypoint() and also in IsNaN.
    Please provide me the link so I can download it or tell me what to do. I don’t know your google drive link either. thanks again.

    • Pete Hahn Post author

      The following post in our FAQ section should clear up the problem you are having. The file is a study file and is cannot be opened to view it’s contents for copy/paste. The file must be saved to your hard drive and imported into Thinkorswim.

      • Mohammad Ahmed

        I am a newbie, I am trying for 2 days without success. I humbly request if you can give me the link to download, I will really appreciate it.

      • Pete Hahn Post author

        That is the only link to download. Every video I publish provides the code in this format. You will need to learn how to work with these types of files if you want to benefit from all of the free content I provide.

  • Joe

    Love your videos. They are well done and very informative.
    I have written a strategy (this is the first strategy I have written. I have written a lot of studies (thanks to you). I have done my strategy’s in Excel. This is a cool alternative). I believe that the strategy is properly set up to only buy when buy conditions are met and sell only when sell conditions are met.
    I am basically using your ADDORDER statements
    AddOrder(OrderType.BUY_AUTO, GreenDown, open[-1],
    tradeSize, Color.PINK, Color.PINK,
    “GreenDown @ ” +open[-1]);

    AddOrder(OrderType.SELL_AUTO, RedUp, open[-1],
    tradeSize, Color.white, Color.white,
    “RedUp @ ” +open[-1]);
    This is what happens when I run the study.
    A buy is initiated when the first buy or sell condition is met.
    This will run until the next buy or sell condition is met.
    At the same time, an inverse by is initiated.
    When the next condition is met it inverts the order again.
    so on an so forth until, the chart ends.
    FloatingPL shows no time when it is flat (an indication that no position has been taken).
    The chart is showing alternating blue and red dashed lines between the trades.
    My buy or sell indicator sometimes indicates a buy/sell when it is already in the market. Could this be the problem?
    There are places where there is clean buy to sell (no intervening indicators). And it still has the same problem.
    What is wrong?

    • Pete Hahn Post author

      Sorry but there is very little assistance I can provide for a question of this complexity. That’s why we have a Q&A Forum. I suggest you search the Q&A Forum for examples and see if that clears up your issue. For now the only detail I can provide is your order are set to “BUY_AUTO” and “SELL_AUTO” and this would cause exactly what you have described. There does not appear to be anything wrong. You probably just need to change the order types.

  • Joe Petti

    Hi Pete: I have developed a number of strategies in TOS, using the “Create Scan Query” and then have the program convert each Scan into ThinkScript, which then gives me Buy & Sell signals for each equity chart,

    ie., In ThinkScript: To BUY: “MACD().”Value” is greater than MACD().”Value” from 1 bars ago

    To SELL: “MACD().”Value” is less than MACD().”Value” from 1 bars ago”

    Is there a simple way to convert those strategies to get a Floating PL graph without writing the horrendous codes?

  • PHILIP MORRISON

    Hi Pete,
    Appreciate your video. Great job !!
    If I want to develop my own strategies, what scripting language can be used? I am using C# to develop strategies now. Can I load those into TOS Strategies? What other languages can be loaded into TOS Strategies?
    Appreciate your help.
    Phil

    • Pete Hahn Post author

      At this time not other languages are supported. Since you are already writing strategies in C# I suggest you move to a platform that supports a real programming language. Trade Station, Sierra Chart or NinjaTrader. Thinkorswim only supports a very basic scripting language.

  • Rao

    Hi Pete,

    If we buy stock at multiple entry points , like I bought Ulta at 240 , and 190 and if I want to sell orders which I bought at 190 . Please let me know how the script for it should be.

    Thanks Rao.

    • Pete Hahn Post author

      What you are asking is nothing more than a matter of book keeping. (do you use First-In-First-Out or do you take the average price. You cannot structure any sell order in any way that can impact this. You need to contact TD Ameritrade and have them explain this to you. It has absolutely nothing to do anything presented in this video.

  • A.V.

    Hi Pete, maybe I didn’t be clear. I want to print the signals, not at (open[-1]), not a the open of next bar, just at the price where condition triggers (same price of the market when ‘alert’ condition sound is printed at message center). Is that possible? Thank you!

    • Pete Hahn Post author

      This all depends on the code you are using. The comment section of a video is not the place to be trying to work out things of this complexity. There is no blanket answer this question. There is not one size fits all solution to your question. Post a question in the Q&A forum and include your code, a screenshot and and explanation of what your code is not doing correctly.

  • A.V.

    Hi Pete, it seems all the TOS strategies print entries and exits at the ‘open’ of bars. Is there a way to print at the ‘real price’ when strategy condition triggers? Do you’ve an example? Thank you!

    • Pete Hahn Post author

      Sounds like you want a chart strategy that simulates an entry based on a stop or limit order rather than a market order on open or market order at close. I have built several of these for clients but I am not sure if anything has been published to the public. You can browse our Q&A forum to see if there are any examples there: https://www.hahn-tech.com/ans/cat/strategies/

      • A.V.

        No stop or limit, I meant if the entry can be printed (Chart / Report) at the exact price in which the condition is met, and not at the ‘open’ of bar as usual by default. Otherwise you get a false performance.

      • Pete Hahn Post author

        For built-in strategies, if they set the entry at the open of the bar following the signal then this is absolutely correct. If you are building your own strategies then yes, it is very important to write the code so that is uses the correct entry price. But a built-in strategy included with Thinkorswim that buys at the open is absolutely providing accurate performance.

    • Pete Hahn Post author

      If it’s on a chart, and you have a chart strategy loaded on the chart, they yes. The process is no different. However because you asked this question I suspect you are not talking about plotting an OPRA code on a chart with a strategy and exporting that to Excel.

  • cmorgh

    Peter, thank you so much for your time and effort in providing such useful videos, it is truly appreciated! Question: If I want to turn the above Study (script above on this page) into a strategy what do I need to adjust because copying the complete script of the Study into a new strategy doesn’t work.

    • Pete Hahn Post author

      The code posted below the video was added after another viewer requested a lower study version of the chart strategy. The download link for the chart strategy version is included within the video. Look for the info button in the upper right corner and click on it while the video is playing.

  • john

    Good Morning Hahn, i love your videos. i’m trying to modify the MTF macd so that it can accept tick and range bar charts unstead of just minutes. do you t hink this would be possible? (i’m not a coder) thanks for all that you do. YOU ROCK.

  • Nicholas

    Hi Hahn, may i know where do I get your amazing studies and strategies library that I can download and import to my TOS platform? Thanks for your video, very useful indeed!

    • Pete Hahn Post author

      There is no such library. Each piece of code is published in connection with a free video tutorial. In order to download each custom tool you need to watch each video.

  • Keith

    It looks difficult to build a strategy. I would like to build one, but have no way of knowing how to do it. I’d like to build one that uses a 10 minute chart where a long position would be triggered if price crosses above the lower Bollinger Band set at 14 and the sell when it touches the 8 EMA. A Short position would have the opposite logic. Short when the price crosses below the upper Bollinger Band set at 14 and close when it touches the 8 EMA. I would also like to see if the closing order can be conditional where it has a stop loss or hits the 8 EMA. Any help or guidance would be greatly appreciated.

    • Pete Hahn Post author

      Lol. Please do NOT loose sight of the intended purpose of this video. Which is to show you how to build your own strategy and backtest it. That disclaimer you saw at the start of the video? That’s not just a disclaimer. It’s a warning. I only write code and teach folks how to get the most out of the platform. I don NOT trade. Examples given in this and other videos are pretty much just picked out of the clear blue sky.

  • james

    Hello Pete:
    Your videos on strategies are very educational and easy to follow. Great work.
    One question, is it possible to backtest options with strategies? Thanks.
    James

  • john

    Pete,
    Thank you for the Strategy Video. I have tried using Chrome and Firefox to view the link at 28:22 in your video and in both browsers no link is visible. What am I doing incorrectly?

    • Pete Hahn Post author

      try it again. I had to replace all the links because YouTube removed them all. The new method of providing links looks a bit different but should work just fine.

      • John Frazer

        I will try again in 15 minutes or so. Thank you. Is it best to view from the video from within your website or via YouTube directly? By the Hahn-Tech

  • HenryB

    I’ve been watching your videos on strategies. They are wonderful. Because you asked I want to say I am very interested in how to create a strategy from a study. I have found that many of the built-in studies generate far more profitable signals if you change the default settings. It would be very useful to be able to quantify the results of the changes. Please do more videos on this topic.
    Thank you for all your time and effort you so generously share with the world.
    BRAVO ZULU!
    HenryB

    • Pete Hahn Post author

      Thanks for the great feedback. You will find the rest of the videos on this topic listed in the left side-menu. They are listed in the order they should be viewed.

  • Steve Nichol

    Very kool. Wondering how this would act of we used the pivot with a positive signal from a momentum study? I’m also going to check it with the schaff trend cycle indicator. Great work. Keep it up.