Could you please help me here?
Does this look like the right output from the included code? Note the change in PnL based on the close price change. Is there an error in the GetProfitLoss method?
Date / Time 10/09/2010 15:02:00
Instrument $USDJPY
Close 84.25
Position = Long
Quantity = 20000
Avg Entry Price =84.23
NT PnL 399.99999999992
Date / Time 10/09/2010 15:03:00
Instrument $USDJPY
Close 84.25
Position = Long
Quantity = 20000
Avg Entry Price =84.23
NT PnL 399.99999999992
Date / Time 10/09/2010 15:04:00
Instrument $USDJPY
Close 84.22
Position = Long
Quantity = 20000
Avg Entry Price =84.23
NT PnL -200.000000000102
Date / Time 10/09/2010 15:05:00
Instrument $USDJPY
Close 84.22
Position = Long
Quantity = 20000
Avg Entry Price =84.23
NT PnL -200.000000000102
int x = 0; foreach (Position p in Positions) { if (p.MarketPosition != MarketPosition.Flat && BarsPeriods[x].Value == 1) { day_pnl_open += p.GetProfitLoss(Closes[x][0], PerformanceUnit.Currency); if (p.Instrument.FullName == "$USDJPY") { Print("Date / Time "+ Time[0].ToString()); Print("Instrument "+ BarsArray[x].Instrument.FullName); Print("Close " + Closes[x][0]); if (p.MarketPosition == MarketPosition.Short) { Print("Position = Short "); } else { Print("Position = Long "); } Print("Quantity = " + p.Quantity); Print("Avg Entry Price =" + p.AvgPrice); Print("NT PnL "+ p.GetProfitLoss(Closes[x][0], PerformanceUnit.Currency)); } } x++; }
drolles
Comment