I am debugging my strategy and I am noticing an issue which I do not know how to resolve...I can't make any sense of it so can you help? This is in the Playback mode.
I have created a simple MA cross over strategy to demonstrate the issue I'm experiencing. In the example, when the 9ema crosses above the 21ema I want to place a market order to go long however the order is not placed because the strategy thinks that my current market position is not flat and as I've set my strategy up to wait until flat the order does not get placed.
To help me debug the logic, I added a white dot when the current market position is flat and a red dot when the current market position is not flat. The image below shows the last crossover on the right hand side (with the green background) with no order being placed. It also shows a red dot against each bar demonstrating that the current market position is not flat therefore the order is not placed.
If I add a profit target and stop loss (16 ticks for both) in the 'stops and targets' window of the Strategy Builder then the current market position changes to flat as shown by the white dots, albeit it still shows as not being flat for the 3No. crossovers on the left hand side of the image below where the red dots are indicated. In this instance the order is placed as expected.
This behaviour is odd, because if I widen my profit target and stop loss in the 'stops and targets' window of the Strategy Builder to a value greater than the highest or lowest price between the current crossover and the previous crossover then the strategy considers the current market position to not be flat and therefore no order is placed.
My view is that it seems as though the exit conditions (profit target & stop loss) from the previous crossover are influencing the ability to place a trade on the current crossover, even if the order wasn't placed. It is as though the strategy is being applied to earlier data and not just starting from the time when the strategy is enabled.
I've attached the exported strategy, would you please be able to take a look and let me know how I can resolve this issue?
Many thanks,
Neil
Comment