// When accountCurrent equals an Account, the .PositionUpdate event is subscribed to so that when the account is flat the RealizedProfitLoss is checked. accountCurrent.PositionUpdate += OnPositionUpdate; private void OnPositionUpdate(object sender, PositionEventArgs e) {[INDENT]Print(string.Format("OnPositionUpdate() Name: {0} \tMarketPosition: {1} ", e.Position.Account.DisplayName, e.MarketPosition.ToString().ToUpper())); if (e.MarketPosition == MarketPosition.Flat) {[/INDENT][INDENT=2]CheckAccountRealizedProfitLoss(accountCurrent);[/INDENT][INDENT]}[/INDENT] Print("OnPositionUpdate() - EXIT"); }
FastTraderButtons: #### MouseClick started >> Buy button clicked
FastTraderButtons - Price clicked: 11115.25
- orderFT = orderId='ae9369d28a15412790b5b829e47b0e8e' account='ac83410' name='FT: Buy Limit' orderState=Initialized instrument='MNQ 12-20' orderAction=Buy orderType='Limit' limitPrice=11115.25 stopPrice=0 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=13743 time='2020-09-25 13:05:47' gtd='2099-12-01' statementDate='2020-09-25'
ResetButtonsAndCursor() - Started
- ResetButtons: All is Good to trade. Resetting buttons.
- ResetButtons: SetTextBlockMITState() started
ResetButtonsAndCursor(): - EXIT
OnPositionUpdate() Name: xxxxx0!AMP!xxxxxxx0 MarketPosition: LONG
OnPositionUpdate() - EXIT
FastTraderButtons: #### MouseClick started >> Sell button clicked
FastTraderButtons - Price clicked: 11122.75 <<<<<<< This sell order puts the account flat
- orderFT = orderId='4fde9ba2cc8c4378af2dabee16ebc522' account='ac83410' name='FT: Sell StopLimit' orderState=Initialized instrument='MNQ 12-20' orderAction=Sell orderType='Stop Limit' limitPrice=11122.75 stopPrice=11122.75 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=13744 time='2020-09-25 13:06:29' gtd='2099-12-01' statementDate='2020-09-25'
ResetButtonsAndCursor() - Started
- ResetButtons: All is Good to trade. Resetting buttons.
- ResetButtons: SetTextBlockMITState() started
ResetButtonsAndCursor(): - EXIT
OnPositionUpdate() Name: xxxxx0!AMP!xxxxxxx0 MarketPosition: SHORT <<<<<<< The account is flat, Not Short.
OnPositionUpdate() - EXIT
OnPositionUpdate() event handler was working fine previously and firing MarketPosition.Flat when the account went flat, but today I noticed it stopped firing when flat. It is only firing for MarketPosition.Long or MarketPosition.Short. When a long position was opened a MarketPosition.Long had fired. The sell order, to put the account flat and verified in the Control Center Positions tab, was firing a MarketPosition.Short when it should be MarketPosition.Flat. I tested this several times today, and never saw a MarketPosition.Flat.
Is there some detail I'm missing or not understanding about <account>.PositionUpdate?
thanks.
Comment