RTP = Close[0];
if (Position.MarketPosition.Long) {
RTP = Strategy.Position.AveragePrice + Strategy.Position.GetUnrealizedProfitLoss(Performa nceUnit.Currency) / Strategy.Position.Quantity
}
else if (Position.MarketPosition.Short) {
RTP = Strategy.Position.AveragePrice - Strategy.Position.GetUnrealizedProfitLoss(Performa nceUnit.Currency) / Strategy.Position.Quantity
}
The documentation states that if you do not pass a price value to GetUnrealizedProfitLoss() it will use the Real-Time price.
My reasoning is that sometimes when data is "Bursting" the OnBarUpdate() current bar may be a few bars away for non time based bars like volume bars.
Any thoughts?
Comment