OKay thanks.
I am using the code from your link:
double SwingValue[2]={0,0}; int Found = 0; int k = 0; while(Found <= 2){ if(iCustom(NULL, 0, "ZigZag", Depth, 5, 3, 0, k) != 0){ SwingValue[Found] = iCustom(NULL , 0, "ZigZag", Depth, 5, 3, 0, k); Found++; } k++; }
Now to count the number of bars until last ZZ high, i increament my counter until High[i] == ZZ high:
for (int v=1; v<Bars; v++) { if(High[v] == SwingValue[0]) // ZZ High { break; } else { counter_for_zzhigh = counter_for_zzhigh + 1; } }
Works fine but on rare occasions numerous bars have the same High and thus the counter wont "increase enough"
Anyone knows a better way for counting bars until last ZZ high?
for (int v=1; v<Bars; v++) { if(High[v] != SwingValue[0]) { counter_for_zzhigh = counter_for_zzhigh + 1; } else break; }
Something like that.
Thanks Sir,
Now it seems that the indexes of SwingValue[Found] do flip.
I assumed that SwingValue[0] has always the latest ZZ high and SwingValue[1] is always latest ZZ low.
But in backtesting the indexes sometimes change positions and therefore the counter will show the number of Bars of current chart.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello everyone,
The following code draws arrows of the latest high and low from the ZigZag indicator.
The arrows will not be repainted and thus stay on the chart.
The code snipped presented here is from someone else.
I wanted to kindly ask if someone can built a loop or counter to find the number of bars until the latest high and low presented on the chart.
The latest low is alway the latest green up and vice versa.
I am not good at coding and every attempt ended in complete failure :-(
Thanks in advance for any help.