I’m experiencing an issue with my trading algorithm where stop orders are rarely getting submitted while backtesting. When my conditions are met, the code is supposed to be placing three orders simultaneously:
- EnterLongLimit(assetNum, true, int.Parse(variables.ShareSize.GetValueOrDefault(). ToString()), entryPrice, "");
- ExitLongStopLimit(assetNum, true, int.Parse(variables.ShareSize.GetValueOrDefault(). ToString()), riskLimit, stopPrice, "", "");
- ExitLongStopMarket(assetNum, true, int.Parse(variables.ShareSize.GetValueOrDefault(). ToString()), stopPrice - (passValue / 2), "", "")
A fourth take profit order (ExitLongLimit) is being placed in OnOrderUpdate when the EnterLongLimit order is filled. I have an inverse set of orders being placed for taking short positions. The stop-market order is set a good distance beyond the stop-limit order acting as a security in cases where the stop-limit order isn’t able to get filled.
As you can see in my screenshot of the orders page in the strategy analyzer, stop orders aren’t getting placed when they should be. The first seven orders are all limit orders. The eighth order is a stop-limit with no stop-market. This issue persists throughout every backtest I run. Logs are not showing any warnings or errors. Help with this would be much appreciated!
Comment