Basic Overview of Using Strategies in Thinkorswim

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 Ameritrade: www.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;
};
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?
Indeed there is. I published some templates built for just this purpose and the following video provides those templates and demonstrates how to use them: https://www.hahn-tech.com/thinkorswim-autotrade-almost/
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
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.
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.
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.
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!
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.
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!
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/
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.
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.
Hi Pete, is there a way to export Options strategies to Excel? Thank you!
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.
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.
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.
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.
Glad you like the videos. At this time there is no way to apply secondary aggregation periods on any Range bar chart. And Tick based aggregation periods are not available to reference as a higher time frame. Here is a full list of available aggregation periods for referencing higher time frames: https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AggregationPeriod
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!
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.
hey Pete this file would not load into tostados. invalid characters
TOS*
I just tested the file and it is working just fine. I’ve never heard of the error message: “invalid characters” on Thinkorswim.
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.
Keep watching videos. Everything is organized by topic and listed in the menu on the left hand side bar. This one is our most advanced video on this topic: https://www.hahn-tech.com/thinkorswim-autotrade-almost/
Love the video but over time, you will lost money, because it’s not taking into account how strong the trend is.
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.
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
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?
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.
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
what if i have a strategy idea i want to test? how can i code it into thinkorswim? can you help with that?
Yes indeed. We assist clients with a very large number of custom projects. You can get all the details here, including rates: https://www.hahn-tech.com/about/
That is also covered under our professional services. Please use the link previously provided if you wish to hire us to complete a custom project for you.
Keep making these videos, Peter. I really like them
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
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.
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.
Pingback: Thinkorswim Strategies Complex Stop Management - Hahn-Tech, LLC
Pingback: Thinkorswim Strategy Guide MTF - Hahn-Tech, LLC
Pingback: Thinkorswim Strategy Ichimoku - Hahn-Tech, LLC
Pingback: Thinkorswim Scan To Strategy - Hahn-Tech, LLC