I cannot manage with idea of adopting account position. My aim is to sync my orders with real account when I enable strategy
Let's look at the code
protected override void OnStateChange() { if (State == State.SetDefaults) { ...... IsAdoptAccountPositionAware = true; StartBehavior = StartBehavior.AdoptAccountPosition; } else if (State == State.Configure) { } else if (State == State.DataLoaded) { AddChartIndicator(SMA(21)); } else if (State == State.Realtime) { // convert any old historical order object references // to the new live order submitted to the real-time account if (_BasicEntry != null) _BasicEntry = GetRealtimeOrder(_BasicEntry); } } private Order _BasicEntry; protected override void OnBarUpdate() { if (CurrentBars[0] < BarsRequiredToTrade) return; if (Position.MarketPosition==MarketPosition.Flat) { _BasicEntry = EnterLongStopMarket(1,1.3034,"Main Entry"); } else if (Position.MarketPosition == MarketPosition.Long) { Print("Already in long position"); } }
My real account position is absolutely flat. When I enable the strategy it says "Already in long position".
Could you explain how to sync the account position with strategy correctly?
Comment