//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0

//— входные параметры
input int InpAtrPeriod = 10; // Период ATR

//±-----------------------------------------------------------------+
//| Функция инициализации пользовательского индикатора              |
//±-----------------------------------------------------------------+
int OnInit()
  {
   return (INIT_SUCCEEDED);
  }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectDelete(0,"priceHigh");
   ObjectDelete(0,"priceLow");
   ObjectDelete(0,"priceHigh_0.5");
   ObjectDelete(0,"priceLow_0.5");
  }

//±-----------------------------------------------------------------+
//| Функция итерации пользовательского индикатора                   |
//±-----------------------------------------------------------------+
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];
   double openATR[10];
   int m = 0;

// Расчет значений ATR с использованием данных месячного таймфрейма
   for(int i = 0; i < InpAtrPeriod && i < iBars(_Symbol, PERIOD_MN1); i++)
     {
      int shift = i;
      double maxHigh = iHigh(_Symbol, PERIOD_MN1, shift);
      double minLow = iLow(_Symbol, PERIOD_MN1, shift);
      openATR[m] = iOpen(_Symbol, PERIOD_MN1, shift);
      H_L[m] = NormalizeDouble(maxHigh - minLow, _Digits);
      m++;
     }

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

   double ATRavg = NormalizeDouble(ATR / (m - 1), 2);

   if(m > 0)
     {
      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_start = iTime(_Symbol, PERIOD_MN1, 0);
      datetime time_end = time_start + 31 * 24 * 60 * 60;


      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);
  }

//+------------------------------------------------------------------+
 нужно переделать для недельного периода с периодом 52