counting the number of bars of each peak or trough

 

Hello everyone,

I'm a newbie to MQL5 and I've tried to search on this forum but couldn't find a solution for my problem.

I'm coding an indicator which is used for my EA. The main purpose of this indicator is counting the number of bars of each peak or trough (in other words, it forms the highest or lowest in how many bars). If this number is between a range (Eg. 10-15), it will be shown at the top/bottom of the highest/lowest candle (as in the picture).

I hope an experienced programmer can help!

Documentation on MQL5: Timeseries and Indicators Access / Bars
Documentation on MQL5: Timeseries and Indicators Access / Bars
  • www.mql5.com
If the start_time and stop_time parameters are defined, the function returns the number of bars in the specified time interval, otherwise it returns the total number of bars. If data for the timeseries with specified parameters are not formed in the terminal by the time of the Bars() function call, or data of the timeseries are not synchronized...
Files:
Example.png  10 kb
 
Mql5 Newbie:

Hello everyone,

I'm a newbie to MQL5 and I've tried to search on this forum but couldn't find a solution for my problem.

I'm coding an indicator which is used for my EA. The main purpose of this indicator is counting the number of bars of each peak or trough (in other words, it forms the highest or lowest in how many bars). If this number is between a range (Eg. 10-15), it will be shown at the top/bottom of the highest/lowest candle (as in the picture).

I hope an experienced programmer can help!

Hi, just a thought, you might want to look at using the ZigZag indicator via iCustom. With that, you could count the difference between the highs and lows, depending on the values you use to "drive" the ZigZag.

Reason: