как запомнить значение?

 

все еще делаю индикаторов откатов, (если можно так выразиться) некоторое время вообще не было времени заняться MQL и те крохи знаний, которые были в голове, от меня ушли((

нашла на форуме как делают зиг заг на осцилляторе и на этом примере решила строить свой индюк. но не могу сообразить как сделать так, чтобы линия шла беспрерывно

линия строится по зонам перекуплености осциллятора на графике цены. на скрине начертила как хочу чтобы работал индюк.

будет 2 буфера для хая и для лоу. в коде на данный момент 1 буфер покажите на его примере пжл

//+------------------------------------------------------------------+
//|                                                           qw.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   1
//--- plot highlow
#property indicator_label1  "highlow"
#property indicator_type1   DRAW_COLOR_ARROW
#property indicator_color1  clrYellow,clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         highBuffer[];
double         highColors[];

//----------------------------------
#include <Trade\SymbolInfo.mqh>

CSymbolInfo    m_symbol;                     // symbol info object
//-----------------------------------
input int         WPRperiod   =  14;
input double      WPRmax      = -20;
input double      WPRmin      = -80;

int    h;
double wpr[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  
   h=iWPR(Symbol(),Period(),WPRperiod);
    if(h==INVALID_HANDLE)
    {
      Print("Can't load indicator");
      return(INIT_FAILED);
    }
    
    SetIndexBuffer(2,wpr,INDICATOR_CALCULATIONS); 
    
//--- indicator buffers mapping
   SetIndexBuffer(0,highBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,highColors,INDICATOR_COLOR_INDEX);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   PlotIndexSetInteger(0,PLOT_ARROW,159);
   
//---
   return(INIT_SUCCEEDED);
  }
  
  void OnDeinit(const int reason)
  {
   if(h!=INVALID_HANDLE)
    {
      IndicatorRelease(h);
    }
  }  
//+------------------------------------------------------------------+
//| 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[])
  {
  
  MqlRates rates[]; 
  ArraySetAsSeries(rates,true);
   if(CopyRates(m_symbol.Name(),Period(),0,3,rates)!=3)  
            
   double cl1   = rates[1].close;
   double op1   = rates[1].open;
   double high1 = rates[0].high;
   double low1  = rates[0].low;
//-----------------------------------
  int start;
 //Print(start);
  if(prev_calculated==0)
  {
   start=0;
  }
    else
    {
      start=prev_calculated-1;
    }
//Print(start);
   if(CopyBuffer(h,0,0,rates_total-start,wpr)==-1)
   {
    return(0);
   }
   //Print(high[i]);
   
   for(int i=start;i<rates_total;i++) 
   {
    highBuffer[i]=EMPTY_VALUE;
    if(wpr[i]>WPRmax){
      highBuffer[i]=high[i];
      highColors[i]=0;
   }

}
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Файлы:
u0wzuopmc2.png  47 kb
Причина обращения: