Order Management Coding Approach:
- Using Managed with Advance Order Handling
- I am creating order objects along with OnOrderUpdate() and OnExecutionUpdate() methods
Issue:
- I know that this error message occurs when the stop price is above the current price when going Long or the stop price is below the current price when going short. Based on the error message, the error is caused my the later description
- When I run the strategy through the chart for an extended period, I see many scenarios where my stop loss orders works correctly. For some reason that I have not been able to determine, the last trade generates the error. It only happens to the last trade and when I am using a Custom Range for the data series time frame. If I use Days on Load data based on and set the End Date to the current date, I don't get the error.
- This started happening when I started using Custom Range in the Data Series. The End Date is not the current date.
- Using a separate chart that plots my Renko bars along with another tick data series using the Last price, I can confirm that the price at the time the ExitShortStopMarket was submitted is less than the price of the stopPrice. Even more interesting, since the order was created close to the end of the Custom range, when I submit the ExitShortStopMarket order, the market price NEVER came close to the stopPrice. There was never a quick spike to the upside so that when the order was submitted and created in Working status the current price would had been above the stopPrice of the order.
- Keep in mind that this only happens when I set a Custom range and the End date is not the current date. In addition, before the last bar is executed in the Custom range, an order is Opened along with two working orders. The error message feels as if when it tries to create the ExitShortStopMarket, it is comparing the order's stopPrice with the current price in RealTime. In RealTime, the price is definitely above the order's stopPrice.
Comment