Under the initialize shows the Data Series added
protected override void Initialize()
{
CalculateOnBarClose = true;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
Add("M6E 09-14", PeriodType.Minute, 5);
Add("M6B 09-14", PeriodType.Day, 1);
Add("M6B 09-14", PeriodType.Minute, 5);
Add(PeriodType.Minute, 1);
}
My exit strategy attempts are shown below. What I am trying to do is when the cumulative value of my positions between the instruments used (accounting for position size) is greater than a target value then close both positions. Thanks.
if (BarsInProgress == 0
&& ((((Positions[3].AvgPrice - Closes[3][0]) * Positions[3].Quantity * TickSize) + ((Closes[1][0] - Positions[1].AvgPrice) * Positions[1].Quantity * TickSize)) > 5
|| Positions[1].MarketPosition == MarketPosition.Flat)
)
{
ExitLong("PoundLong");
}
if (BarsInProgress == 1
&& ((((Positions[3].AvgPrice - Closes[3][0]) * Positions[3].Quantity * TickSize) + ((Closes[1][0] - Positions[1].AvgPrice) * Positions[1].Quantity * TickSize)) > 5
|| Positions[3].MarketPosition == MarketPosition.Flat)
)
{
ExitShort("EuroShort");
}

Comment