Preventing impossible trades in backtesting
I have some strategies that frequently trade on the same bar. Most of these trades are fine, but in back-testing, I have reason to believe that some small number of them are trading in an impossible order. For instance, in a long trade, the price might enter the bar at an intermediate value, fall to the low that meets my sell condition, rise to a high that meets my buy condition, and then exit to the next bar. In back-testing, this would show up as a completed trade, since both my sell and my buy condition are met within the bar. Is there a way of ruling out such impossible trades when back-testing?
At first I thought that the HiLo1 function solved the problem, but it will reject single-bar trades even where the trade can be completed. For example, in the trade described above, if the price rises from the low to the high that triggers a buy, and then falls back down to the low that triggers the sale, conditioning the sale on high before low with HiLo1 would block the sale.
Is there a way to insist that sales come after buys on within-bar long positions, or before them on within-bad long positions?
-
Adminefrain (Admin, CQG) commented
No there is not a way - your profit and stops are too tight. CQG always takes the stance that the stop gets hit first - hence a negative return on a bar that has both limit and stop executing. TradeStation on the other hand will always take the profit objective over the stop on the same bar - talk about suger coating.
There is not a way to know the historical developement of a bar within our code.
CQG's backtesting can enter - exit on the same bar... it cannot enter - exit - reenter in a buy formula. It can sell - exit - buy within the same bar. That is the extent - our product was not made for scalping (executing many times within the developemet of the bar).