why not higlight correctly ?

 

Hi guys  i want higlight  a candel that have  >= 6 pips  i create  this  script , but  not mark  all candel that respect this parameter ,  why ??


//+------------------------------------------------------------------+
//|                                                         6pip.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 clrWhite
extern int PipRequest = 6;            // QUANTI PIP PER EVIDENZIARE
double Buffer[];
// Dichiarazione globale della variabile di stato
bool alertShown = false;

int OnInit()
{
    SetIndexBuffer(0, Buffer);
    SetIndexStyle(0, DRAW_ARROW);
    SetIndexArrow(0, 233);
    
    return(INIT_SUCCEEDED);
}




int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
    int start = prev_calculated;
    if (start == 0)
        start = 1;

    for (int i = start; i < rates_total; i++)
    {
        double bodySize = MathAbs(open[i] - close[i]);
        double pipSize = MarketInfo(Symbol(), MODE_POINT) * PipRequest;

        if (bodySize <= pipSize)
        {
            Buffer[i] = high[i]; // Disegna un punto in alto sulla candela
        }
        else
        {
            Buffer[i] = 0; // Non disegnare nulla sulla candela
        }
    }
    
    return (rates_total);
}
 
faustf: s  i want higlight  a candel that have  >= 6 pips 
 double pipSize = MarketInfo(Symbol(), MODE_POINT) * PipRequest;

Your first problem is a PIP is not a point.

PIP, Point, or Tick are all different in general.
          Ticks, PIPs or points in the GUI. Make up your mind. - MQL4 programming forum #1 (2014)
          Percentage in point - Wikipedia

Unless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points), and metals. Compute what a PIP is and use it, not points.
          How to manage JPY pairs with parameters? - MQL4 programming forum (2017)
          Slippage defined in index points - Expert Advisors and Automated Trading - MQL5 programming forum (2018)