I use an AutoStrategy that close everything at time end. The strategy use the ATM for manage the orders. The issue comes when I enable the feature Reverse at stop that is into the ATM strategy. (GUIDE FOR AUTOREVERSE https://ninjatrader.com/support/help...to_reverse.htm
When I enable it it creates a Sell Stop or Buy Stop than reverse to buy or sell when the Stop Loss is reached by the price.
The issue is:
One order/position still OPEN sometimes without Stop Loss and Take profrit after use the function :Account.Cancel(orders);
its not canceled!!
so is dangerous!!
Below the code that I try to use but it doesnt close everything how expected. How can I solve the issue easily? I want to close all the remaining orders, positions (everything) but the strategy should stay enabled.
Thanks for your help!
if (ToTime(Time[0]) >= ToTime( 10, 30, 00)) // The condition { var orders = Account.Orders.Where( x => x.Instrument == Instrument && !Order.IsTerminalState(x.OrderState)); if(orders.Count()!= 0) { Print( Name +", "+ Instrument.FullName +", "+ BarsArray[0].BarsPeriod +": active orders detected & canceled: " + orders.Count().ToString()); [B]Account.Cancel(orders); [/B]// Cancel Everything }
Comment