protected override void OnBarUpdate()
{
// check conditions for trade
if (CurrentBar < BarsRequiredToTrade)
return;
// enter based on slave signals
if (mOrder == null && isUpTrend())
EnterLong("myOrder");
if (mOrder == null && isDownTrend())
EnterShort("myOrder");
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
// Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
// This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not gauranteed to be complete if it is referenced immediately after submitting
if (order.Name == "myOrder" && orderState != OrderState.Filled)
mOrder = order;
if (mOrder != null && mOrder == order)
{
Print(DateTime.Now.ToString()+"|"+ Name + "|" + order.ToString());
if (order.OrderState == OrderState.Filled)
mOrder = null;
}
}
Time Category Message
5/29/18 5:25 Position Instrument='GBPUSD' Account='401386179' Average price=1.33168 Quantity=10,000 Market position=Short Operation=Operation_Add
5/29/18 5:25 Execution Execution='635614510' Instrument='GBPUSD' Account='401386179' Exchange=Default Price=1.33168 Quantity=10,000 Market position=Short Operation=Operation_Add Order='635614510' Time='5/29/2018 5:25 AM'
5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Filled' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=10000 Fill price=1.33168 Error='No error' Native error=''
5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Working' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Accepted' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Submitted' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
5/29/18 5:25 Position Instrument='GBPUSD' Account='401386179' Average price=0 Quantity=0 Market position=Flat Operation=Remove
5/29/18 5:25 Execution Execution='635614506' Instrument='GBPUSD' Account='401386179' Exchange=Default Price=1.33168 Quantity=10,000 Market position=Short Operation=Operation_Add Order='635614506' Time='5/29/2018 5:25 AM'
5/29/18 5:25 Order Order='635614506/401386179' Name='myOrder' New state='Filled' Instrument='GBPUSD' Action='Sell short' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=10000 Fill price=1.33168 Error='No error' Native error=''
5/29/18 5:25 Order 401386179, Another instruction has already made changes to the trades and orders. affected Order: Sell 10000 Market
5/29/18 5:25 Order Order='8c8fdc5033e54fdda649a4b360db4a34/401386179' Name='Close position' New state='Rejected' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Another instruction has already made changes to the trades and orders. '
5/29/18 5:25 Default Disabling NinjaScript strategy 'TfsEmaTrendBarsV1.3/138997332'
5/29/18 5:25 Default Strategy 'TfsEmaTrendBarsV1.3/138997332' submitted an order that generated the following error 'Order rejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
5/29/18 5:25 Order Order='635614506/401386179' Name='myOrder' New state='Submitted' Instrument='GBPUSD' Action='Sell short' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
5/29/18 5:25 NinjaScript NinjaScript strategy 'TfsEmaTrendBarsV1.3/138997332' submitting order
5/29/18 5:25 NinjaScript NinjaScript strategy 'TfsEmaTrendBarsV1.3/138997332' submitting order

Comment