As you can see below, this is what I am using to get the PnL for the GBPUSD:
primaryPnL = (Closes[1][0] - Positions[1].AvgPrice) ;
And, this is what I am using to get the PnL of the EURUSD;
secondaryPnL = (Positions[2].AvgPrice - Closes[2][0]) - eurSpread;
It enters the positions properly, but does not give me the correct totals with the "Print" command?????
Any ideas????
It looks like this:
==================================================
protected override void Initialize()
{
Add("$GBPUSD", PeriodType.Minute, 5);
Add("$EURUSD", PeriodType.Minute, 5);
EntryHandling = EntryHandling.AllEntries;
EntryHandling = EntryHandling.UniqueEntries;
TraceOrders = true;
ExitOnClose = false;
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
// ================================================== =========
eurSpread = GetCurrentAsk() - GetCurrentBid();
// ================================================== ===========
{
if ( Positions[1].MarketPosition == MarketPosition.Long
&& Positions[2].MarketPosition == MarketPosition.Short)
bothInPosition = true;
{
if ((BarsInProgress == 1)
&& bothInPosition == false)
EnterLong(10000, "GBP/USD Long");
if ((BarsInProgress == 2)
&& bothInPosition == false)
EnterShort(10000, "EUR/USD Short");
}
}
//================================================== =============
if (Positions[1].MarketPosition == MarketPosition.Long)
{
primaryPnL = (Closes[1][0] - Positions[1].AvgPrice) ;
}
if (Positions[2].MarketPosition == MarketPosition.Short)
{
secondaryPnL = (Positions[2].AvgPrice - Closes[2][0]) - eurSpread;
}
Print("This is the profit of GBD/USD");
Print (primaryPnL * 10000);
Print("This is the profit of EUR/USD");
Print (secondaryPnL * 10000);
Print("This is the Overall Profit right now");
Print (currentTotal);

Comment