I tried to place orders, but I can't see these orders in executions tab or orders tab on the platform NinjaTrader.
namespace NinjaTrader.NinjaScript.Strategies
{
public class GridL : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"GridL";
Name = "GridL";
Calculate = Calculate.OnPriceChange;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.ImmediatelySubmitSynchronizeAccount;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 0;
}
else if (State == State.Configure)
{
}
}
private Order entryOrder = null;
protected override void OnBarUpdate()
{
if (entryOrder == null && Close[0] > Open[0]){
EnterShort(2, "myEntryOrder");
Print("Execution : close=" + Close[0] + " Open="+Open[0] + " at " + "dateTime=" + DateTime.Now.ToString("HH:mm:ss.fff"));
}
else{
Print("close=" + Close[0] + " Open="+Open[0]);
}
}
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
{
if (entryOrder != null && entryOrder == order)
{
entryOrder = order;
if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
{
entryOrder = null;
}
}
}
}
}

Comment