The goal is to update Stops of any active order every time OnBarUpdate() is called.
I was trying this example on a MarketReplay connection with a entry create by hand using a ATM in the SuperDOM.
protected override void OnBarUpdate() {
foreach (Order order in Account.Orders) {
if(Order.IsTerminalState(order.OrderState)){
// Print(order.ToString());
}
else {
// Try to change the stop
if (order.OrderType == OrderType.StopMarket){
int sign = 1 ; // Let assume entry is Long
double new_price = order.StopPrice + sign * TickSize;
new_price = order.Instrument.MasterInstrument.RoundToTickSize(new_price);
Print(strinf.Format(" -- sign: {2}: changing stop {0} --> {1}", order.StopPrice, new_price, sign));
ChangeOrder(order, order.Quantity, order.LimitPrice, new_price);
}
}
}
}
Can anyone show me what I am missing?
Thanks in advance
--
Asterio

Comment