Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 277
![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.
Please help me to compare the MA price on the first bar with the MA prices on the previous four bars. If the price has increased and the difference is greater than N fill the buffer. I am trying this way
Which price rose - the MA? Has it risen in relation to each successive bar (value on the bar) or in relation to any of the four?
Which price rose - the MA? Did it go up relative to each subsequent bar (value on the bar) or relative to any of the four?
Yes, to any bar.
Condition: If the value of the MA on the first bar has increased by N relative to the value of the MA on any of the four preceding bars then buffer.
I need to know that the value of the MA has risen by "N" pips, and it doesn't matter for what period of time, but I can't think of anything other than a comparison on a limited number of bars.
Yes, To anyone.
Condition: If the value of the MA line on the first bar has increased by N relative to the MA value on any of the four previous bars, then buffer.
I need to know that the MA value has risen by "N "pips, and no matter what the time, but other than comparing on a limited number of bars I can't think of anything.
So why don't you subtract one MA value from the other and look at the delta - compare it to the low, why these cycles?
So why don't you subtract one MA value from the other and look at the delta - compare it with the minimum, why these cycles?
Price can change slowly over several bars, one pip at a time (notionally) the fifth will be the change you are looking for.
Price can change slowly over several bars
So take the indicator value 4 bars ago and the current value and compare - if the averaging period is not super shallow, then the increase is smooth...
Or do you have indicators with different settings?
So take the indicator value 4 bars ago and the current value and compare - if the averaging period is not super shallow, then the increase is smooth...
The difference you are looking for may be on the second bar, but you suggest comparing the first and the fourth.
The difference you are looking for may be on the second bar, but you suggest comparing the first and the fourth.
What is the averaging period of the MA - I was just wondering - do you need a break?
One MA indicator. Can you help with the loop?
If I understand correctly what you want, here is the script - deal with it.
I make delta in positive value, if you need to determine with + or -, then remove lineif(DeltaMA<0)DeltaMA=DeltaMA*(-1); and take into account separately a constant for comparison (with - and +)