In today’s post, I’ll walk through the process I used to create my own automated custom back test directly inside Thinkorswim. I’ll use the back test I created but this information can be adapted to use with any indicator, entry, or exit trigger you prefer.

Create an Automated Custom Back Test in Thinkorswim Step – by – Step

  1. Start by removing any indicators currently on the chart. Make sure the chart is 100% clear before beginning so the back test parameter’s aren’t impacted.
  2. Add the 9 period Exponential Moving Average to the chart.
  3. Click the Studies tab, then search for the “FloatingPL” indicator and add it to the chart.
  4. Click the Strategies tab, then search for the “ProfitTargetLX” indicator and add it to the chart.
  5. Write the code for the custom strategy you prefer. The code for the bullish strategy I use is just below.

input price = close;
input MAlength = 9;
input displace = 0;

def MA = MovAvgExponential(length = MAlength);

def call = open[-displace] < MA and close[-displace] > MA;

AddOrder(OrderType.BUY_TO_OPEN, call, price[-displace], name = “Call”, tradesize = 100, tickcolor = Color.CYAN, arrowcolor = Color.LIGHT_GRAY);

Code Updated 3/18/23 to include; entry at closing price of signal bar instead of opening price.
  1. Click the Strategies tab, then click create.
  2. Name the new strategy whatever you prefer and add the code above. Be sure to remove any current parameters already listed. Click create.
  3. Setup the profit target, stop loss, and displace parameters. Adjust the stop loss and profit target to your choice but in this instance be sure to set displace to a value of 1.
Automated Custom Back Test in Thinkorswim
Thinkscript Code Editor

Closing Thoughts

That’s all there is! You’ve now created an automated custom back test in Thinkorswim to easily identify assets that may be good trading candidates for the listed criteria.

The sky is the limit to the number of automated custom back test in Thinkorswim you could create but this get’s you well on your way. Additionally, Thinkorswim comes pre-loaded with several strategies right out of the box so I would encourage everyone interested to sift through those to find one that may look promising.

Should you want to continue learning about Thinkscript, here is a dive into the basics from and should I be capable of assisting please reach me in the comments below.

God bless,