Исправить расположение линии

 

недавно был опубликован индикатор для мт4 и я решил переписать его на мт5 вот ссылка на оригинал https://www.mql5.com/en/code/49534?utm_source=mql5.com.tg&utm_medium=message&utm_campaign=articles.codes.repost

и теперь у меня красная линия находится над всеми оcтальными , подскажите как ее сделать в центре как у автора на этом изображении


сейчас вот так: 

 

#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_plots   5
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrBlue
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrWhite
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrLime
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrOrange
#property indicator_type5   DRAW_LINE
#property indicator_color5  clrRed
#property indicator_width5  1

input int                inpRsiPeriod        = 14;          // RSI period
input ENUM_APPLIED_PRICE inpPrice            = PRICE_CLOSE; // RSI price
input int                inpSmoothing        = 14;          // Smoothing period for RSI
input double             inpOverbought       = 70;          // Overbought level %
input double             inpOversold         = 30;          // Oversold level %
input double             inpUpperNeutral     = 55;          // Upper neutral level %
input double             inpLowerNeutral     = 45;          // Lower neutral level %

double Overbought[], UpperNeutral[], Oversold[], LowerNeutral[], Center[];

int RsiHandle = 0;

//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0, Overbought, INDICATOR_DATA);
   SetIndexBuffer(1, UpperNeutral, INDICATOR_DATA);
   SetIndexBuffer(2, Oversold, INDICATOR_DATA);
   SetIndexBuffer(3, LowerNeutral, INDICATOR_DATA);
   SetIndexBuffer(4, Center, INDICATOR_DATA);

   ArraySetAsSeries(Overbought, true);
   ArraySetAsSeries(UpperNeutral, true);
   ArraySetAsSeries(Oversold, true);
   ArraySetAsSeries(LowerNeutral, true);
   ArraySetAsSeries(Center, true);
   
   PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_LINE);
   PlotIndexSetInteger(0, PLOT_LINE_COLOR, clrBlue);
   PlotIndexSetInteger(0, PLOT_LINE_WIDTH, 1);

   PlotIndexSetInteger(1, PLOT_DRAW_TYPE, DRAW_LINE);
   PlotIndexSetInteger(1, PLOT_LINE_COLOR, clrWhite);
   PlotIndexSetInteger(1, PLOT_LINE_WIDTH, 1);

   PlotIndexSetInteger(2, PLOT_DRAW_TYPE, DRAW_LINE);
   PlotIndexSetInteger(2, PLOT_LINE_COLOR, clrLime);
   PlotIndexSetInteger(2, PLOT_LINE_WIDTH, 1);

   PlotIndexSetInteger(3, PLOT_DRAW_TYPE, DRAW_LINE);
   PlotIndexSetInteger(3, PLOT_LINE_COLOR, clrOrange);
   PlotIndexSetInteger(3, PLOT_LINE_WIDTH, 1);

   PlotIndexSetInteger(4, PLOT_DRAW_TYPE, DRAW_LINE);
   PlotIndexSetInteger(4, PLOT_LINE_COLOR, clrRed);
   PlotIndexSetInteger(4, PLOT_LINE_WIDTH, 1);
   
   RsiHandle = iRSI(_Symbol, _Period, inpRsiPeriod, inpPrice);
   if (RsiHandle == INVALID_HANDLE)
   {
      Print("Не удалось создать хэндл индикатора iRSI, код ошибки: ", GetLastError());
      return (INIT_FAILED);
   }

   return (INIT_SUCCEEDED);
}

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[])
{
   if (rates_total < inpRsiPeriod)
   {
      Print("Недостаточно данных для расчета RSI.");
      return 0;
   }

   int limit = rates_total - prev_calculated;
   if (prev_calculated == 0)
   {
      limit = rates_total - 1;
   }

   if (RsiHandle == INVALID_HANDLE)
   {
      Print("Хэндл индикатора iRSI недействителен.");
      return prev_calculated;
   }

   if (CopyBuffer(RsiHandle, 0, 0, rates_total, Center) < 0)
   {
      Print("Не удалось скопировать данные из индикатора iRSI, код ошибки: ", GetLastError());
      return prev_calculated;
   }

   for (int i = limit; i >= 0; i--) {
      Overbought[i] = iMAOnArray(Center, rates_total, inpSmoothing, i) - inpOverbought;
      Oversold[i] = iMAOnArray(Center, rates_total, inpSmoothing, i) - inpOversold;
      UpperNeutral[i] = iMAOnArray(Center, rates_total, inpSmoothing, i) - inpUpperNeutral;
      LowerNeutral[i] = iMAOnArray(Center, rates_total, inpSmoothing, i) - inpLowerNeutral;

      Center[i] -= 50;
   }


   return rates_total;
}

double iMAOnArray(const double &array[], int total, int period, int index)
{
   if (period <= 0)
      return 0.0;

   double sum = 0.0;
   int count = 0;
   for (int i = index - period + 1; i <= index; i++) {
      if (i >= 0) {
         sum += array[i];
         count++;
      }
   }

   if (count == 0)
      return 0.0;

   return sum / count;
}

void OnDeinit(const int reason)
{
   if (RsiHandle != INVALID_HANDLE)
      IndicatorRelease(RsiHandle);
}
RSI with channels
RSI with channels
  • www.mql5.com
standart RSI with dynamic levels
 
Oleg Kubenko:

недавно был опубликован индикатор для мт4 и я решил переписать его на мт5 вот ссылка на оригинал https://www.mql5.com/en/code/49534?utm_source=mql5.com.tg&utm_medium=message&utm_campaign=articles.codes.repost

и теперь у меня красная линия находится над всеми оcтальными , подскажите как ее сделать в центре как у автора на этом изображении

сейчас вот так: 

 
Файлы:
indi5.mq5  10 kb
 
Vitaly Muzichenko #:
 

вот спасибо тебе добрый человек, встречу угощу пивом с баранками

Причина обращения: