I have the below section in my trading strategy. If I swap out the orange highlighted part, for the part below, the time taken to run a walk fwd opt (without changing the Max/Mins or the increments on each variable), over doubles in time; it goes from running it in 2.5 hours, to taking 6 hours.
Any idea why this is?
MAX(High, CurrentBar-OverboughtBar)[0]-Close[0]
As you can see from the below, the above MAX(High.....) is used to define the stopshort and also to move the stop in the ROLL STOP @ A section below, so it would be more consistent to use it.
I just can't understand why the walk forward opt takes so much longer.
else if(Breaklow
&& Close[0]>=Open[0]
// 61.8% Fib is based on the highest high of the double top, not the entire range (inconsistent to the stop and roll positions)
&& (Close[0]-MIN(Low,CurrentBar-RetestBar)[0])/(MAX(High,BarCountOverbought)[CurrentBar-RetestBar]-Close[0])>1.55
&& MAX(High,CurrentBar-OverboughtBar)[0]-Close[0]>0.001
&& ToTime(Time[0])>70000 && ToTime(Time[0])<170000
&& Close[0]-MIN(Low,CurrentBar-RetestBar)[0]>0.001
)
{
int AvTR=(s1*(Convert.ToInt32(Math.Round((ATR(14)[0]/TickSize)))));
// Stop position and roll positions based on the highest high of the entire range, not just the double top. Change this, need to change the rolls as well
int stopShort=Convert.ToInt32((MAX(High, CurrentBar-OverboughtBar)[0]-Close[0])/TickSize)+AvTR;
int profitShort=Convert.ToInt32((Close[0]-MIN(Low,CurrentBar-RetestBar)[0])/TickSize);
double capitalToRisk=100;
double TickValue=Instrument.MasterInstrument.PointValue*I nstrument.MasterInstrument.TickSize;
int GBPperpoint = (int)Instrument.MasterInstrument.RoundDownToTickSi ze((capitalToRisk/TickValue));
int xUnits =(int)(GBPperpoint/(stopShort));
SetStopLoss("GoShort", CalculationMode.Ticks,stopShort, false);
SetProfitTarget("GoShort", CalculationMode.Ticks,profitShort);
EnterShort(xUnits,"GoShort");
EntryBar=CurrentBar;
Breaklow=false;
Notrade=true;
rolA=true;
Oversold=false;
}
//////////////////////////////////////////////////////////////////////////////////////
// ROLL STOP @ A: roll the stop to protect the position
if (Position.MarketPosition == MarketPosition.Short
&& rolA
&& Close[0]<Position.AveragePrice-((x1*1*TickSize*(Convert.ToInt32((MAX(High, EntryBar-OverboughtBar)[BarsSinceEntryExecution("GoShort")+1]-Close[BarsSinceEntryExecution("GoShort")+1])/TickSize))+(s1*(Convert.ToInt32(Math.Round((ATR(14 )[BarsSinceEntryExecution("GoShort")+1]/TickSize))))))
)
)
{
rolA=false;
int stopShort=Convert.ToInt32((MAX(High, EntryBar-OverboughtBar)[BarsSinceEntryExecution("GoShort")+1]-Close[BarsSinceEntryExecution("GoShort")+1])/TickSize)+(s1*(Convert.ToInt32(Math.Round((ATR(14)[BarsSinceEntryExecution("GoShort")+1]/TickSize)))));
SetStopLoss("GoShort", CalculationMode.Price,Close[0]+(stopShort)*TickSize, false);
rolB=true;
}
Comment