I want to close trades when the last up fractal is lower than the second last up fractal, and same in reverse for down fractals.
I am using the following code to determine the last fractals:
My question is how to find out about the second last fractals - to then compare them and close trades if the rule is met?
I am using the following code to determine the last fractals:
Inserted Code
//+----Determines last up and down fractals,
double LastUpFractal,LastDownFractal,TimeOfLastDownFractal,TimeOfLastUpFractal;
for(int k=1;k<Bars;k++){//for loop to find last UpFractal
if(iFractals(NULL, Period(), MODE_UPPER,k)!=0){// NULL removed Symbol() added
LastUpFractal=iFractals(NULL, Period(), MODE_UPPER,k);
TimeOfLastUpFractal=Time[k];
break;
}//end if
}//end for
for(int j=1;j<Bars;j++){//for loop to find last DownFractal
if(iFractals(NULL, Period(), MODE_LOWER,j)!=0){
LastDownFractal=iFractals(NULL, Period(), MODE_LOWER,j);
TimeOfLastDownFractal=Time[j];
break;
}//end if
}//end for My question is how to find out about the second last fractals - to then compare them and close trades if the rule is met?