Hello,
i got this error-Message in a MessageBox and in the Output Window.
Checking google i will found this side from Ninjatrader:
perfect solution, i put this in my Strategy and i get following error:
Strategy 'XXX' has been disabled because it attempted to modify a historical order that has transitioned to a live order.
Here is my Code:
protected override void OnBarUpdate()
{
......
FastOrders.Add(EnterLongLimit(0, true, 1, validPrice, "UniqueName"));
........
}
protected override void OnStateChange()
{
if (State == State.Terminated)
{
Print("isTerminated == true");
foreach (Order o in FastOrders)
{
Print(Closes[BarsInProgress].Bars.GetTime(CurrentBar).ToString("yyyy_MM_dd_HH_ mm_ss") + " " + this.Name + "-Terminated Fast CancelOrder(" + o.Name + ") ID: " + o.Id);
CancelOrder(GetRealtimeOrder(o));
}
FastOrders.Clear();
foreach (Order o in SlowOrders)
{
Print(Closes[BarsInProgress].Bars.GetTime(CurrentBar).ToString("yyyy_MM_dd_HH_ mm_ss") + " " + this.Name + "-Terminated Slow CancelOrder(" + o.Name + ") ID: " + o.Id);
CancelOrder(GetRealtimeOrder(o));
}
SlowOrders.Clear();
isTerminated = true;
Print("isTerminated == false");
}
}
output Window:
Enabling NinjaScript strategy 'xxx/233462606' : On starting a real-time strategy - StartBehavior=ImmediatelySubmit Position=BTCEUR 12L AccountPosition=BTCEUR 49L EntryHandling=All entries EntriesPerDirection=200 StopTargetHandling=By strategy position ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=False SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On price change IsUnmanaged=False MaxRestarts=4 in 5 minutes
NinjaScript strategy 'xxx/233462606' submitting order
NinjaScript strategy 'xxx/233462606' submitting order
NinjaScript strategy 'xxx/233462606' submitting order
NinjaScript strategy 'xxx/233462606' submitting order
NinjaScript strategy 'xxx/233462606' submitting order
NinjaScript strategy 'xxx/233462606' submitting order
NinjaScript strategy 'xxx/233462606' submitting order
2021_12_03_01_00_00 xxx-OnOrderUpdate Long_Slow_00003 ID 8304 order.OrderState: Filled
2021_12_03_01_00_00 xxx-OnExecutionUpdate
2021_12_03_01_00_00 xxx-OnExecutionUpdate OrderFilled: Long_Slow_00003
2021_12_03_01_00_00 xxx-Create_EnterShortLimit: fullQuantity: 25 current_TakeProfit: 24210,94
Strategy 'xxx/233462606' has been disabled because it attempted to modify a historical order that has transitioned to a live order. Please see the help guide for more information on transitioning order references from historical to live.
isTerminated == true
2021_12_03_01_00_00 xxx-Terminated Fast CancelOrder(Long_Fast_00010) ID: -1
2021_12_03_01_00_00 xxx-Terminated Fast CancelOrder(Long_Fast_00011) ID: -1
2021_12_03_01_00_00 xxx-Terminated Slow CancelOrder(Long_Slow_00000) ID: -1
2021_12_03_01_00_00 xxx-Terminated Slow CancelOrder(Long_Slow_00001) ID: -1
2021_12_03_01_00_00 xxx-Terminated Slow CancelOrder(Long_Slow_00002) ID: -1
2021_12_03_01_00_00 xxx-Terminated Slow CancelOrder(Long_Slow_00004) ID: -1
isTerminated == false
Disabling NinjaScript strategy 'xxx/233462606'
This OnStateChange will be called to late?
Whats happening here?
with best regards
Spike
Comment