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

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

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

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

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

// Calculate ATR values using weekly timeframe data
   for(int i = 0; i < InpAtrPeriod && i < iBars(_Symbol, PERIOD_W1); i++)
     {
      int shift = i;
      double maxHigh = iHigh(_Symbol, PERIOD_W1, shift);
      double minLow = iLow(_Symbol, PERIOD_W1, shift);
      openATR[m] = iOpen(_Symbol, PERIOD_W1, 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_W1, 0);
      datetime time_end = time_start + 7 * 24 * 60 * 60;


      ObjectCreate(0, "priceHigh_W", OBJ_TREND, 0, time_start, priceHigh, time_end, priceHigh);
      ObjectCreate(0, "priceLow_W", OBJ_TREND, 0, time_start, priceLow, time_end, priceLow);
      ObjectCreate(0, "priceHigh_0.5_W", OBJ_TREND, 0, time_start, priceHigh_2, time_end, priceHigh_2);
      ObjectCreate(0, "priceLow_0.5_W", OBJ_TREND, 0, time_start, priceLow_2, time_end, priceLow_2);

      ObjectSetInteger(0, "priceHigh_W", OBJPROP_COLOR, clrGreen);
      ObjectSetInteger(0, "priceLow_W", OBJPROP_COLOR, clrGreen);
      ObjectSetInteger(0, "priceHigh_0.5_W", OBJPROP_COLOR, clrDeepPink);
      ObjectSetInteger(0, "priceLow_0.5_W", OBJPROP_COLOR, clrDeepPink);

      ObjectSetInteger(0, "priceHigh_W", OBJPROP_WIDTH, 2);
      ObjectSetInteger(0, "priceLow_W", OBJPROP_WIDTH, 2);
      ObjectSetInteger(0, "priceHigh_0.5_W", OBJPROP_WIDTH, 2);
      ObjectSetInteger(0, "priceLow_0.5_W", OBJPROP_WIDTH, 2);
     }


   return (rates_total);
  }

//+------------------------------------------------------------------+


у меня есть такая программа мне нужно что бы ты улучшил программу и она считала уровни и для прошлых недель