'MathAbs' - parameter passed as reference, variable expected

 

error in compile: 'MathAbs' - parameter passed as reference, variable expected

    double bodyPipsBullSum = sumSelectiveCandles(MathAbs(Close[1] - Open[1]), 1, bodyPipsBull);

    double bodyPipsBearSum = sumSelectiveCandles(MathAbs(Close[1] - Open[1]), 1, bodyPipsBear);


 
oliahmed:

error in compile: 'MathAbs' - parameter passed as reference, variable expected


    double bodyPipsBullSum = sumSelectiveCandles(MathAbs(Close[1] - Open[1]), 1, bodyPipsBull);

    double bodyPipsBearSum = sumSelectiveCandles(MathAbs(Close[1] - Open[1]), 1, bodyPipsBear);


Your issue is following:

sumSelectiveCandle is probably defined as follows:

sumSelectiveCandle(double& var1, ...);

As you see it is with ampersand, this means it's a reference and has to be filled with a variable.


double my_var = 1.0;
sumSelectiveCandle(my_var, ...);

When you do a subtraction, you have no variable to store the result, therefore you cannot fill the reference (double&).

You first need to store the result in a variable and then pass that variable to the function call.


 
oliahmed: error in compile: 'MathAbs' - parameter passed as reference, variable expected

It's been that way for at least five years. Do what it says.

   double body     = Close[1] - Open[1],
          bodySize = MathAbs(body);

    double bodyPipsBullSum = sumSelectiveCandles(bodySize, 1, bodyPipsBull);

    double bodyPipsBearSum = sumSelectiveCandles(bodySize, 1, bodyPipsBear);
 
My coding is now error free but when I compiled the coding it removed from the chart
 
oliahmed #:
My coding is now error free but when I compiled the coding it removed from the chart
Not enough details...

You need to give specifics. Either post complete code or at least show log journal.

Alternatively, debug the code and find your error.
 
Dominik Christian Egert #:
Not enough details...

You need to give specifics. Either post complete code or at least show log journal.

Alternatively, debug the code and find your error.
2023.07.22 02:12:06.823 Custom indicator sdfsdfsd AUS200m,H1: removed

 
Dominik Christian Egert #:
log

"Please add me to your friend list. I have sent you a friend request on this MQL5 profile so we can message each other."

 
oliahmed #:

"Please add me to your friend list. I have sent you a friend request on this MQL5 profile so we can message each other."

Done