I'm having an issue here with managed orders, I set a small sample where I place a long market order and an SL for it, yet it gets canceled out in the few next ticks.
Also, TraceOrders doesn't seem to do anything for me, doesn't print anything
Would appreciate your help, regards
namespace NinjaTrader.NinjaScript.Strategies
{
public class TestOrders: Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = """;
Name = "Test";
IsInstantiatedOnEachOptimizationIteration = false;
TraceOrders = true;
}
else if (State == State.DataLoaded)
{
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
if (State != State.Realtime)
return;
if (Position.MarketPosition != MarketPosition.Flat)
return;
EnterLong();
}
protected override void OnExecutionUpdate(Execution execution, string execution, double price, int quantity,
MarketPosition marketPosition, string orderId, DateTime time)
{
if (!execution.IsEntryStrategy || !execution.Order.IsLong)
return;
//Either setting Low[0] or a fixed prie it gets cancelled
ExitLongStopMarket(Low[0]);
}
protected override void OnOrderTrace(DateTime timestamp, string message)
{
Print(string.Format("{0} {1}", timestamp, message));
}
}
}

Comment