I am testing my own strategy that uses a third party indicator as well as my own.
There are advantages to being able to determine entry conditions on a lower timeframe than the chart timeframe. I am running the "chart" data series on 120 minute (BarsInProgress 0) but I have added other timeframes for entry calculations. The timeframe that I wish to enter trades on is the 5 minute. I also use the 1 minute and 3 minute because my third party indicator requires them.
When I enter a trade I place limit orders on the 5 minute data series (BarsInProgress 3). These trades enter as expected, however they all "close" at the beginning/end of a new 120 min candle unexpectedly. It is not always the subsequent 120 minute candle, it may be 2 or 3 chart timeframe candles after the entry, and it is not "closing" at end of session or end of day. This seems to be random. I say "close" in quotes because it is not exactly exiting the trades as you would expect.
To clarify further, when I enter a trade I set target and stop loss orders. However, the trade closes without price reaching either of these exits. For example, conditions allow my strategy to place a limit order entry at 6:45PM on BIP 3 (5 min data series), with target and stop loss orders set. Trade is eventually triggered at 8:55PM. Things look normal as the trade plays out until at 10:00PM I get this log (from TraceOrders)
Cancelled pending exit order, since associated position is closed
It then proceeds to cancel my target and stop loss and the Position.MarketPosition moves from Short to Flat. But the trade is still active despite the market position saying otherwise. This then causes my strategy to enter a different trade, however the original entry is still active and naked with no exit orders. According to the backtest results, the first trade closes when the second trade also has the Cancellation as above at (12:00AM) and the cycle repeats for the length of the backtest.
Note the screenshot attached. Each trade closes on the open (close?) of a 120 minute bar, yet was opened on the 5 minute timeframe as intended. Almost all of these trades closed at a random value that was often an overshoot of the original stop loss, and the one trade that went to target somehow closed at the right place, however its exit orders were also closed 2 hours prior according to the logs for the same reason as all the others.
What could be closing these orders? It seems like the order handling thinks the trade has closed but the Strategy Analyzer still has them open?
I should also note that I have Exit on session close unselected and there are no errors in the logs. This strategy also works if I make the chart timeframe = the entry timeframe. It would just be better if I could make it work with the chart timeframe larger than the entry timeframe for reasons that would take me a long time to explain.

Comment