could someone help me out please on the code below... it has failed to work on the charts though it compiles with no errors at all.

 
//+------------------------------------------------------------------+
//|                                            Nad_Envelope.mq5 |
//|                                  Copyright 2022, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   3
//--- plot lowerband
#property indicator_label1  "lowerband"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrOrangeRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot upperband
#property indicator_label2  "upperband"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot signal
#property indicator_label3  "signal"
#property indicator_type3   DRAW_COLOR_ARROW
#property indicator_color3  clrDarkOrchid
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- input parameters
input int      length=500;
input int      bandwidth=8;
input int      multiplier=3;
//--- indicator buffers
double         lowerbandBuffer[];
double         upperbandBuffer[];
double         signalBuffer[];
double         signalColors[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,lowerbandBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,upperbandBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,signalBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,signalColors,INDICATOR_COLOR_INDEX);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(2,PLOT_ARROW,159);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 n = prev_calculated-1;
    int k = 2;
    if (rates_total <= 0){
      return(0);
    }


//--- start area of the envelopes calculations

    if (ArraySize(close)-1 <= 0){
        for(int i=0;i<=length/k-1;i++){
            for (int t=0;t<4;t++){
                upperbandBuffer[t] = float("nan");
                lowerbandBuffer[t] = float("nan");
            }
         }
     }

    if (ArraySize(close)-1 > 0){
        double y [500];
        double sum_e = 0;
        for(int i=0; i<=length-1;i++){
            double sum = 0;
            double sumw = 0;

            for (int j=0; j<=length-1; j++){
                double w = MathExp(-(MathPow(i-j, 2) / (bandwidth * bandwidth * 2)));
                sum += close[j] * w;
                sumw += w;
            }
            

            double y2 = sum / sumw;
            sum_e += MathAbs(close[i] - y2);
            y[i] = y2;
         }
         
        double mae = sum_e / length * multiplier;
                
        for (int i=1;i<=length-1;i++){
             double y2= y[i];
             double y1= y[i-1];

            upperbandBuffer[i] = y1 + mae;
            lowerbandBuffer[i] = y1 - mae;
            
        
          if (close[i] > y1 + mae && close[i+1] < y1 + mae){
              signalBuffer[i] = y1 + mae;
              signalColors[i] = i;
          }
          if (close[i] < y1 - mae && close[i+1] > y1 - mae){
              signalBuffer[i] = y1 - mae;
              signalColors[i] = i;
          }
        }
      }

//--- return value of prev_calculated for next call

   return(rates_total);
  }
  
 
//+------------------------------------------------------------------+

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2022.11.12
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
[Deleted]  

Failed to work? That doesn't explain anything! We cannot read your mind!

Describe your issue in detail! We are not going to debug it for you.