After publishing couple of times, here I am asking for a suggestion! :-)
I am working on an indicator based on the ZigZag, but in order to draw some nice rectangles, I should need the time at wich the maximum/minimum has been created.
I am able to get the ZigZag values through this function
double getExtreme(int ne)
{
int k=iBars(Symbol(),0);
int ke=0;
for (int i=0; i<k; i++)
{double zz=iCustom(Symbol(), 0, "ZigZag",ZigZagDepth,ZigZagDeviation,ZigZagBackStep, 0, i);
if (zz!=0) {ke++; if (ke>ne) return(zz);}
}
}
However, to calculate the time I am just using this function:
int getTime(doublevalue, int start, string type)
{
for(int x=start;x<999;x++)
{if(Low[x]==value && type=="Valley"){return(x);}
if(High[x]==value && type=="Peak"){return(x);}
}
return (Time[0]);
}
In which the caller specifies whether he is looking for time of a peak of valley.
Is there a more elegant approach to this??
Thanks!! :-)
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
After publishing couple of times, here I am asking for a suggestion! :-)
I am working on an indicator based on the ZigZag, but in order to draw some nice rectangles, I should need the time at wich the maximum/minimum has been created.
I am able to get the ZigZag values through this function
However, to calculate the time I am just using this function:
In which the caller specifies whether he is looking for time of a peak of valley.
Is there a more elegant approach to this??
Thanks!! :-)
David