//+------------------------------------------------------------------+
//|                                             NasInfinityAlgo.mq5 |
//|                        Copyright 2024, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "2024"
#property link      "http://www.metaquotes.net/"
#property version   "1.00"
#property indicator_separate_window false
#property indicator_buffers 4
#property indicator_color1 Blue   // Color for up trend line
#property indicator_color2 Red    // Color for down trend line
#property indicator_color3 Lime   // Color for buy signal
#property indicator_color4 Red    // Color for sell signal

//--- input parameters
input int Periods = 40;                  // ATR Period
input double Multiplier = 7.2;           // Sensitivity
input bool changeATR = true;            // Change ATR setting
input bool showsignals = true;          // Show buy/sell signals
input bool highlighting = false;        // Highlighting

//--- indicator buffers
double UpBuffer[];
double DownBuffer[];
double BuySignalBuffer[];
double SellSignalBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   //--- indicator buffers
   SetIndexBuffer(0, UpBuffer);
   SetIndexBuffer(1, DownBuffer);
   SetIndexBuffer(2, BuySignalBuffer);
   SetIndexBuffer(3, SellSignalBuffer);

   //--- set buffer properties
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexStyle(3, DRAW_ARROW);

   SetIndexArrow(2, 233); // Arrow up symbol
   SetIndexArrow(3, 234); // Arrow down symbol

   ArraySetAsSeries(UpBuffer, true);
   ArraySetAsSeries(DownBuffer, true);
   ArraySetAsSeries(BuySignalBuffer, true);
   ArraySetAsSeries(SellSignalBuffer, true);

   //--- initialization done
   return(INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,    // Number of bars
                const int prev_calculated,// Number of bars previously calculated
                const datetime &time[],   // Time array
                const double &open[],     // Open price array
                const double &high[],     // High price array
                const double &low[],      // Low price array
                const double &close[],    // Close price array
                const long &tick_volume[],// Tick volume array
                const long &volume[],     // Real volume array
                const long &spread[])     // Spread array
  {
   // Check if enough data is available
   if (rates_total < Periods) return(0);

   // Define buffers for ATR calculation
   double ATR[];
   ArraySetAsSeries(ATR, true);
   
   // Calculate ATR values
   if (CopyATR(NULL, 0, Periods, 0, ATR) <= 0) return(0);

   // Define buffers for calculations
   double Src[];
   ArraySetAsSeries(Src, true);
   ArrayCopy(Src, (high + low) / 2, 0);

   // Arrays for storing trend and signal values
   double up[], down[];
   ArraySetAsSeries(up, true);
   ArraySetAsSeries(down, true);

   // Main calculation loop
   for (int i = rates_total - 1; i >= Periods; i--)
     {
      double atrValue = ATR[i];
      
      up[i] = Src[i] - Multiplier * atrValue;
      down[i] = Src[i] + Multiplier * atrValue;

      if (i < rates_total - 1)
        {
         up[i] = (close[i + 1] > up[i + 1]) ? MathMax(up[i], up[i + 1]) : up[i];
         down[i] = (close[i + 1] < down[i + 1]) ? MathMin(down[i], down[i + 1]) : down[i];
        }

      if (i > 0)
        {
         UpBuffer[i] = (close[i] > down[i + 1]) ? up[i] : EMPTY_VALUE;
         DownBuffer[i] = (close[i] < up[i + 1]) ? down[i] : EMPTY_VALUE;

         BuySignalBuffer[i] = (UpBuffer[i] != EMPTY_VALUE && UpBuffer[i + 1] == EMPTY_VALUE) ? low[i] - 0.5 * (high[i] - low[i]) : EMPTY_VALUE;
         SellSignalBuffer[i] = (DownBuffer[i] != EMPTY_VALUE && DownBuffer[i + 1] == EMPTY_VALUE) ? high[i] + 0.5 * (high[i] - low[i]) : EMPTY_VALUE;
        }
     }

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


quero converter o codigo acima para ser funcional como um indicador no mt5