How to properly allign back-test orders with signals


Category:
0
0

Backtesting a strategy. Entry indicators (arrows up/down) are correct timing for entries based on desired conditions. When backtesting using AddOrder to buy (what I desired to buy is when the actual condition occurs) the entry and exits are one candle after the indicated entry. Buy entry & Sell exits set to “close.” I’ve also tried “open” and “close[1]” with the same results. Entering and exiting a full 1 candle after the entry & exit conditions actually occur.

As I’m new to backtesting, is there anyway to resolve this and get the actual order entry/exit times & prices to occur at the same time as when the indicated conditions occur (such as an EMA crossover), or is this an insurmountable issue of backtesting?

addOrder(OrderType.BUY_TO_OPEN, buy, close, 2000 / close, tickColor = color.green, arrowColor = color.green, name = “BUY CALL TFPB”);

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on August 11, 2023 8:51 am
48 views
1
Private answer

This is a pretty common issue and we have already provided a very detailed solution in a previous post in this forum.

Before getting into that I wanted to explain that I changed the title of the question before approving it. The new title I selected should make it much easier for others to locate this solution using the search function. I also moved this question out of the "Chart Studies" topic and into the "Strategy Guide" topic (which is where questions about chart strategies are found).

The following post will explain exactly how to achieve the correct alignment between the signals and the back-test orders. Several examples are included to help you learn how these pieces fit together:

https://www.hahn-tech.com/ans/parablic-sar-signal-not-firing-in-tos-strategy/

For those who are looking for more training on how to use chart strategies on Thinkorswim I will reference some additional resources:

https://www.hahn-tech.com/thinkorswim-strategy-guide/

https://www.hahn-tech.com/tos-strategy-analysis/

https://www.hahn-tech.com/thinkorswim-strategy-analysis/

 

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on August 11, 2023 9:13 am
0
Perfect Pete! Thank you so much. Entry conditions, buy orders and prices are now aligned properly. I was up at 2:30 am working on this stuff. Thought I was going to have to backtest everything manually (extremely labor intensive & time-consuming). You, sir are a godsend! Hope you don't mind but I posted the link to your solution here on Reddit ThinkorSwim subreddit as the answer to my question there also.
( at August 11, 2023 11:41 am)
1
Sharing this post is the best possible way you can support my efforts. So thank you very much for sharing this post and please feel free to do so with any other of my content you find helpful.
( at August 11, 2023 12:13 pm)