Taking the absolute value of value

 
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?
 

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
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...