Motivation: All options to "sync" StartBehavior create these really wrong-priced "virtual entries".
Implementation:
In StateChange to Realtime the code detects when position is not flat, then raises a flag so that the first(?) OnBarUpdate (or next/whatever) send a "sync" order. I can print these "are called" but neither OnOrderUpdate or OnExecutionUpdate show these Accepted/Rejected etc.???
Could you please help guide me?
Extra question: can these be simulated in Playback mode?
Thank you in advance!!!
protected override void OnBarUpdate() { //if( CurrentBar < BarsRequiredToTrade ) // return; // Sync orders from Historical to Realtime to avoid wrong P/L reports and "virtual entries" if (needSync && !realTimeSynched) SyncLivePosition(); ....
private void SyncLivePosition() { if (Position.MarketPosition == MarketPosition.Long) { Print(Time[0] + " Transition Historical position into Realtime: Re-entering Long position..."); EnterLong("Long"); } else if (Position.MarketPosition == MarketPosition.Short) { Print(Time[0] + " Transition Historical position into Realtime: Re-entering Short position..."); EnterShort("Short"); } else { Print(Time[0] + " No position to sync at Reatltime, staying flat."); } realTimeSynched = true; needSync = false; // try getting new position info??? StrategyPositionInfo(); }
Comment