I'm running a strategy with 5 instruments. Since the position is closed out by the time OnPositionUpdate runs, how do you access the last trade information (price, quantity, instrument) from OnPositionUpdate? Is there a BarsInProgress type of functionality like there is in OnBarUpdate to filter the code in OnPositionUpdate so that I only get sent an email for the instruments that just went flat, not all the instruments that are in the strategy but already flat? Or, to do this best, should I be using OnOrderUpdate?
[SIZE=2][FONT=Courier New][COLOR=#0000ff]protected[/COLOR][/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnPositionUpdate(IPosition position) [/SIZE][/FONT] [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE] [FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (position.MarketPosition == MarketPosition.Flat) [/SIZE][/FONT] [SIZE=2][FONT=Courier New]{ [/FONT][/SIZE] [SIZE=2][FONT=Courier New]SendMail([/FONT][/SIZE][FONT=Courier New][SIZE=2][COLOR=#800000]"email"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"other email"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], Instrument.ToString() + [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]" Position Closed"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], "[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]Performance update: "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] + Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit.ToString());[/SIZE][/FONT] [FONT=Courier New][SIZE=2]}[/SIZE][/FONT] [SIZE=2][FONT=Courier New]} [/FONT][/SIZE]
Comment