4 lines of code - 1 calculation not working...

#1
These lines calls on Mathabs("score") depending on whether "positive" score (totalAPLUS) or "negative" score (totalMINUS) is higher.
Does anyone see anything obviously wrong?

Code: Select all

Bimap(StringConcatenate(TradePair[i],"scor1"), CORNER_RIGHT_UPPER, (adW-204), (adH- 0)+((i+0)*42), 83, 39, colourFon, ModColor(colourFon), totalAPLUS>MathAbs(totalMINUS)?clrLime:255, false,
ALIGN_CENTER, " ", 24, "Harabara", totalAPLUS>MathAbs(totalMINUS) ?  DoubleToStr(totalAPLUS/(MathAbs(totalMINUS)!=0?MathAbs(totalMINUS):1),1) /* +" : 1 " */
:  DoubleToStr(MathAbs(totalMINUS)/(totalAPLUS!=0?totalAPLUS:1),1) /* +" : 1" */, "RATIO"); 
It is working perfectly EXCEPT when it is calling on totalAPLUS/totalMINUS and totalAPlus is effectively 100% and totalMINUS is 0%. So, it seems like when totalAPlus is "high" and totalMinus is "0", or "lowest possible", it is calling the wrong calculation.

These are the code lines that are problematic:

Code: Select all

totalAPLUS>MathAbs(totalMINUS)?clrLime:255, false,
         ALIGN_CENTER, " ", 24, "Harabara", totalAPLUS>MathAbs(totalMINUS) ?  DoubleToStr(totalAPLUS/(MathAbs(totalMINUS)!=0?MathAbs(totalMINUS):1),1) /* +" : 1 " */
                                                                       :  DoubleToStr(MathAbs(totalMINUS)/(totalAPLUS!=0?totalAPLUS:1),1)
 
I am struggling to work out the logic from the code to correct it.

Does ? substitute as "if" and ":" is then?


  1. Similar Topics

    1. 0 Replies
      668 Views
    2. Working EA as a gift for 2020 ?

      3 Replies 957 Views

      by ionone, Wed Jan 01, 2020 10:25 pm in MT4 Indicators

      3 Replies
      957 Views

Return to “Coding Help”