protected void OnPositionUpdate(object sender, PositionEventArgs e)
{
if (e.Position.Instrument == this.Instrument)
{
if (e.MarketPosition == MarketPosition.Flat)
{
// Do stuff
}
}
}
This method works on SIM but not on a live trade. And this appears to be caused by live trades not returning a flat status, but instead a direction long or short only. Example of execution difference:
Live trade:
BUY: MarketPosition: Long AveragePrice: 1183.3 Quantity: 1
STOP: MarketPosition: Short AveragePrice: 0 Quantity: 0
SIM trade:
BUY: MarketPosition: Long AveragePrice: 1179.7 Quantity: 1
STOP: MarketPosition: Flat AveragePrice: 0 Quantity: 0
So my question is, how can I check if the account is flat on a specific instrument in OnPositionUpdate()?
Comment