English

## Mathematical Functions

 99 fly7680 2016.09.15 11:21   Hello, I performed a series of calculations to arrive at a final percentage. The code has no errors but the calculation does not work.example:Total excursion Body candle = 36 tenthsTotal excursion shadows      = 11 tenths mathematical expression (100 * 11) / 36 = 30.55%Can you help me?Thank you```bool c1 = Open[1+i] < Close[1+i] && MathAbs(Close[1+i]-Open[1+i]) > 2  * myPoint; bool c2 = MathAbs (High [1+i] - Close[1+i]); //shadow up                           bool c3 = MathAbs (Open [1+i] - Low  [1+i]); //shadow donw                           bool c4 = MathAbs (High [1+i] - Low  [1+i]); //total escursion                     bool c5 = MathAbs (c2+c3); //sum shadow                                                 bool c6 = (100*c5)/ c4;  //result as a percentage                                                                 bool c7 = c6 < 3.9;                                                               ```
 99 fly7680 2016.09.15 15:03 #   I modified the code and no errors but still does not work.Help please?```      bool   c1 =  Open[1+i] < Close [1+i] && MathAbs(Close[1+i]-Open[1+i]) > 2  * myPoint; //Candela Verde       double c2 = MathAbs (High [1+i] - Close[1+i]); //shadow up                                 double c3 = MathAbs (Open [1+i] - Low  [1+i]); //shadow donw                                 double c4 = MathAbs (High [1+i] - Low  [1+i]); //total escursion       double c5 = MathAbs (c2+c3);        //sum shadow                           double c6 = MathAbs (100*c5)/c4;  //result as a percentage                                                                       bool   c7 = c6 < 3.9; ```
 1299 FMIC 2016.09.15 16:10 #   You are assuming that all candles have Close > Open. Also, use variable names that are more meaningful and self documenting.```// Attention - uncompiled/untested! int    BarShift       = i + 1; // Depends on what you are doing (as "WHRoeder" pointed out) double    CandleOpen     = Open[  BarShift ],    CandleClose    = Close[ BarShift ],    CandleHigh     = High[  BarShift ],    CandleLow      = Low[   BarShift ],    CandleRange    = CandleHigh - CandleLow,    BodyHigh       = fmax( CandleOpen, CandleClose ),    BodyLow        = fmin( CandleOpen, CandleClose ),    WickUpperRange = CandleHigh - BodyHigh,    WickLowerRange = BodyLow - CandleLow,    WickRange      = WickUpperRange + WickLowerRange,    WickRatio      = ( CandleRange != 0.0  ) ? WickRange / CandleRange : 0.0, // Prevent "divide by zero" error    WickPercentage = WickRatio * 100.0; ```