- Using DataSeries in which the End Date is not today. The Days to Load is set to 6.
- I am using order objects to manage the trade
- I am implementing a pullback strategy (for longs and a retracement for shorts) using a Limit order and I also have a property which counts the number of bars which have passed since the the pullback order was created. If it reaches a set number of bars, it will cancel the Limit order.
- Connecting using NT Continuum. The broker is Phillip Capital. I am using the SIM account, not my real account
- When the strategy reaches the last bar, it reaches the Realtime state. Once it reaches the Realtime state, any non-null orders gets converted to a Realtime order
else if (State == State.Realtime)
{
if (entryOrder != null)
{
entryOrder = GetRealtimeOrder(entryOrder);
Print("I AM HERE");
}
}
Issue:
- The pullback logic and the number of bars before the Limit order gets cancelled is working correctly when processing the historical bars; no issue there!
- Before the strategy transitions to Realtime a limit order gets created and it is NOT canceled due to the number of bars.
- Using the OnOrderUpdate() method and displaying the order details using order.ToString(), I can see that last order went through the following order states: Submitted, Accepted, and Working. I create my entryOrder object if the object is null and once the order.State == OrserState.Working.
- Since it reaches the working state, I am creating the entryOrder. This is happening in historical bars
- The Working order gets converted into the Realtime order since the strategy reaches the Realtime state. When this happens, I can see an Order record in the Orders tab of the Control Center. Interesting enough, the State of this order is Submitted. But I know it reached the working state. I am confuse about this!
- Before I disable the strategy and because no new bars are getting created (the End Date of the Data Series is not Today), the strategy never cancels the entryOrder which should be in working status as the Limit order never gets filled.
- I decide to disable to cancel the strategy by unchecking the Enable check box
- I have code in the Terminate state
else if (State == State.Realtime)
{
if (entryOrder != null)
{
Print("I am going to cancel entryOrder ");
CancelOrder(entryOrder);
}
}
- When I try to cancel the entryOrder, the order that resides in the Orders tab in the control center changes from Submitted to Cancel Pending. Once it reaches the Cancel Pending state, it never gets resolve. If I run the strategy again, the CancelPending order creates to error:
- Unable to cancel out live orders. Strategy yyyy was not Started.
- Strategy yyyy has been disabled because it attempted to modify a historical order that has transitioned to live order. Please see the help guide.....
- To eliminate the Cancel Pending order, I need to reset the SIM account. Since I am not canceling the submitted order correctly, this issue will happen again.
- How to cancel an order (because I disable the strategy) that was never filled in historical and now it has been converted to Realtime order?

Comment