Mostly the strategy works ok until I try and define fixed stop loss values in the Initialize section.
If I use CalculationMode.Ticks and enter a value it works fine, but as soon as I try to set a calculated price value, it compiles ok but the strategy tester does not like it and gives me no options at all.
I have tried a number of solutions to get around it using BarsArray etc. but I dont think it likes these sorts of calulations in the Initialize section.
Would someone mind passing comment on my Initialize section?
protected override void Initialize()
{
TraceOrders = true;
QuantityType = QuantityType.Strategy;
TimeInForce = Cbi.TimeInForce.Gtc;
ExitOnClose = false;
CalculateOnBarClose = false;
Add(PeriodType.Minute, 5);
Add(PeriodType.Minute, 240);
spread = GetCurrentAsk()- GetCurrentBid();
EntriesPerDirection = 1;
EntryHandling = EntryHandling.UniqueEntries;
if (BarsInProgress !=0)
return;
longstop = MIN(Low,12)[0];
shortstop = MAX(High,12)[0];
SetStopLoss("Long 1a", CalculationMode.Price, longstop, false);
SetStopLoss("Long 1b", CalculationMode.Price, longstop, false);
SetStopLoss("Long 1c", CalculationMode.Price, longstop, false);
SetStopLoss("Short 1a", CalculationMode.Price, shortstop, false);
SetStopLoss("Short 1b", CalculationMode.Price, shortstop, false);
SetStopLoss("Short 1c", CalculationMode.Price, shortstop, false);
}

Comment