//+------------------------------------------------------------------+
//|                                                          ATR.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0


//— input parameters
input int InpAtrPeriod = 10; // ATR period

//— indicator buffers

//±-----------------------------------------------------------------+
//| Custom indicator initialization function                         |
//±-----------------------------------------------------------------+
int OnInit()
{
    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[])
  {
   
   double H_L[10];
   int m = 0;
   double openATR[10];

// Calculate moving average and MADiff
   for(int i = rates_total-1; i > rates_total-InpAtrPeriod-1; i--)
     {
       double maxHigh = high[i];
       double minLow = low[i];
       openATR[m] = open[i];
       H_L[m] = NormalizeDouble(maxHigh - minLow,_Digits);
       m++;
     }

   double ATR = 0;
   for(int i=0;i<9;i++)
     {
      double sum = H_L[i]+H_L[i+1];
      ATR += sum/2/openATR[i+1]*100;
     }
     
   double ATRavg = NormalizeDouble(ATR/9,2);

   
   double priceHigh = openATR[0] + (openATR[0]*ATRavg/100);
   double priceLow = openATR[0] - (openATR[0]*ATRavg/100);
   double priceHigh_2 = openATR[0] + (openATR[0]*ATRavg/200);
   double priceLow_2 = openATR[0] - (openATR[0]*ATRavg/200);
   
   datetime time_end = iTime(NULL, 0, 0);
   
   // Вычисляем время на 10 свечей назад от текущего времени
   datetime time_start = iTime(NULL, 0, 10);
   
   ObjectCreate(0, "priceHigh", OBJ_TREND, 0, time_start, priceHigh, time_end, priceHigh);
   ObjectCreate(0, "priceLow", OBJ_TREND, 0, time_start, priceLow, time_end, priceLow);
   ObjectCreate(0, "priceHigh_0.5", OBJ_TREND, 0, time_start, priceHigh_2, time_end, priceHigh_2);
   ObjectCreate(0, "priceLow_0.5", OBJ_TREND, 0, time_start, priceLow_2, time_end, priceLow_2);
   
   ObjectSetInteger(0, "priceHigh", OBJPROP_COLOR, clrCrimson);
   ObjectSetInteger(0, "priceLow", OBJPROP_COLOR, clrCrimson);
   ObjectSetInteger(0, "priceHigh_0.5", OBJPROP_COLOR, clrBlue);
   ObjectSetInteger(0, "priceLow_0.5", OBJPROP_COLOR, clrBlue);
   
   ObjectSetInteger(0, "priceHigh", OBJPROP_WIDTH, 2);
   ObjectSetInteger(0, "priceLow", OBJPROP_WIDTH, 2);
   ObjectSetInteger(0, "priceHigh_0.5", OBJPROP_WIDTH, 2);
   ObjectSetInteger(0, "priceLow_0.5", OBJPROP_WIDTH, 2);
   
   return(rates_total);
  
  }
//±-----------------------------------------------------------------+
 нужно что бы на каком бы я таймфрейме не находился он считал как будто  я на ммесячном