You may use a ZigZag as a source of extremum points. Then the algorithm can be something like that (in pseudo-code, off the top of my head):
cycle through all ZigZag extremums (by i, 0 - is most recent) { cycle through all levels of interest (by j) { if extremum[i] > level[j] and extremum[i + 1] < level[j] { countUp[j]++ } if extremum[i] < level[j] and extremum[i + 1] > level[j] { countDown[j]++ } } }
You may use a ZigZag as a source of extremum points. Then the algorithm can be something like that (in pseudo-code, off the top of my head):
According to your code I think when the condition "if" is true the counter countUp or countDown will iterate (add 1) every new tick as long as condition "if" is true, while we want to add only 1 iteration regardless of any new tick.
According to your code I think when the condition "if" is true the counter countUp or countDown will iterate (add 1) every new tick as long as condition "if" is true, while we want to add only 1 iteration regardless of any new tick.
This is up to you to decide when to call this stuff - on every tick or bar - from the mentioning ZigZag you should easily deduce that it's apparently for bar by bar execution, and even more - it requires to check that latest ZigZag extremum became stable. This is just a sketch which you need to improve in many aspects, including caching cumulative results for already calculated bars.
This is up to you to decide when to call this stuff - on every tick or bar - from the mentioning ZigZag you should easily deduce that it's apparently for bar by bar execution, and even more - it requires to check that latest ZigZag extremum became stable. This is just a sketch which you need to improve in many aspects, including caching cumulative results for already calculated bars.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
Actually I'm not expert in mql4 language but really need to create an indicator or EA that can count how many times the price go up and how many times go down above and under a given levels (level1 and level0).
In this example the price go up 1 time above Level1 and 3 times below Level0.
any help will be apreciated.
Regards.