HighOfDay = High[HighestBar(High, 24)];
LowOfDay = Low[LowestBar(Low, 24)];
LongEntryOrder = EnterLongStopMarket(0, true, 100000, HighOfDay, "Longtest");
ShortEntryOrder = EnterShortStopMarket(0, true, 100000, LowOfDay, "Shorttest");
if(LongEntryOrder != null)
Print("First Long stop" + LongEntryOrder.Id);
if(ShortEntryOrder != null)
Print("First short stop" + ShortEntryOrder.Id);
I'm entering in my stops and profittarget in the onorderupdate function as below. I have tried creating stops in onexecuteupdate as well and have also tried creating stops in the
state.configure in onstatechange function with SetStopLoss and SetProfitTarget. But I'm always getting the same result where only the first stop order I have set gets created.
Can someone please help me here. Is what I'm trying to do possible in Ninjatrader 8.
Thanks,
Mark
if (LongEntryOrder != null && LongEntryOrder == order)
{
if (order.OrderState == OrderState.Filled)
{
Print("Set the long profit target and stop " + HighOfDay);
LongStop = ExitLongStopMarket(0, true, 100000, HighOfDay - 0.001, "MyLongStop", "Longtest");
LongProfit = ExitLongLimit(0, true, 100000, HighOfDay + 0.001, "MyShortTarget", "Longtest");
LongEntryOrder = null;
}
}
if (ShortEntryOrder != null && ShortEntryOrder == order)
{
if (order.OrderState == OrderState.Filled)
{
Print("Set the short profit target and stop " + LowOfDay);
ShortStop = ExitShortStopMarket(0, true, 100000, LowOfDay + 0.001, "MyShortStop", "Shorttest");
ShortProfit = ExitShortLimit(0, true, 100000, LowOfDay - 0.001, "MyShortTarget", "Shorttest");
ShortEntryOrder = null;
}
}
Comment