I want to get the absolute value of the MACD value. Main line can sometimes be below zero. It's causing problems with my transactions. How to write the code for the 0 distance, that is, the absolute value of the main line? If anyone knows, can you teach?
- How to Get Histogram from MACD and Signal lines?
- Center of Gravity problem
- How can I compare the value of the main line and the signal line in MQL5..?
The code:
An example of working with iCustom - we get the indicator data in the EA [data folder]\MQL5\Indicators\Examples\MACD.mq5
only for the 'Main' line use MathAbs
string text_main="Main |",text_signal="Signal |"; for(int i=count-1; i>=0; i--) { text_main=text_main+" #"+IntegerToString(i)+" "+MathAbs(DoubleToString(main[i],Digits()+1))+" | "; text_signal=text_signal+" #"+IntegerToString(i)+" "+DoubleToString(signal[i],Digits()+1)+" | "; } Comment(text_main,"\n",text_signal);

How to start with MQL5
- 2020.09.06
- www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...

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