Стоп стоп все сначала !!!

 

Чтобы далеко не уходить в дебри подскажите пожалуйста как можно написать на MQL5  cтроки из индикатора на MQL4

    AO=iAO(NULL,0,pos);
    AO1=iAO(NULL,0,pos+1);
    AO2=iAO(NULL,0,pos+2);

 

Или эти строки

//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    BarShift - номер бара сигнала                                           |
//|    AlligtorShift - номер бара Аллигатора                                   |
//|    TF - таймфрейм (количество минут)      (0 - текущий ТФ)                |
//|    SY - символ                                                             |
//+----------------------------------------------------------------------------+
bool Fractal_Up(int BarShift=0,int AlligtorShift=0,string SY="",int TF=0)
{
return(((iHigh(SY,TF,BarShift)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+1)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+2)>iHigh(SY,TF,BarShift+3) && 
         iHigh(SY,TF,BarShift+2)>iHigh(SY,TF,BarShift+4)) ||

        (iHigh(SY,TF,BarShift)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+1)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+2)==iHigh(SY,TF,BarShift+3) && 
         iHigh(SY,TF,BarShift+3)>iHigh(SY,TF,BarShift+4) && 
         iHigh(SY,TF,BarShift+3)>iHigh(SY,TF,BarShift+5)) ||
       
        (iHigh(SY,TF,BarShift)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+1)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+2)==iHigh(SY,TF,BarShift+3) && 
         iHigh(SY,TF,BarShift+3)==iHigh(SY,TF,BarShift+4) && 
         iHigh(SY,TF,BarShift+4)>iHigh(SY,TF,BarShift+5) && 
         iHigh(SY,TF,BarShift+4)>iHigh(SY,TF,BarShift+6)) ||
        
        (iHigh(SY,TF,BarShift)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+1)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+2)>iHigh(SY,TF,BarShift+3) && 
         iHigh(SY,TF,BarShift+2)==iHigh(SY,TF,BarShift+4) && 
         iHigh(SY,TF,BarShift+4)>iHigh(SY,TF,BarShift+5) && 
         iHigh(SY,TF,BarShift+4)>iHigh(SY,TF,BarShift+6)) ||
        
        (iHigh(SY,TF,BarShift)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+1)<iHigh(SY,TF,BarShift+2) && 
         iHigh(SY,TF,BarShift+2)>iHigh(SY,TF,BarShift+3) && 
         iHigh(SY,TF,BarShift+2)==iHigh(SY,TF,BarShift+4) && 
         iHigh(SY,TF,BarShift+4)>iHigh(SY,TF,BarShift+5) && 
         iHigh(SY,TF,BarShift+4)==iHigh(SY,TF,BarShift+6) && 
         iHigh(SY,TF,BarShift+6)>iHigh(SY,TF,BarShift+7) &&  
         iHigh(SY,TF,BarShift+6)>iHigh(SY,TF,BarShift+8)) )&&
         iHigh(SY,TF,BarShift+2)>iAlligator(SY,TF, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 1)
        
        );
}
 

        double lips, jaw, teeth, ao0, ao1, data[2];
        int ind, n;
        ResetLastError();
        // аллигатор
        ind=iAlligator(smb, tf, pJaws, sJaws, pTeeth, sTeeth, pLips, sLips, ModeMA, PriceMA);
        n=CopyBuffer(ind, GATORJAW_LINE, iB, 1, data); if (n<1) return(false); jaw=data[0]; // скопировали значение индикатора
        n=CopyBuffer(ind, GATORTEETH_LINE, iB, 1, data); if (n<1) return(false); teeth=data[0]; // скопировали значение индикатора
        n=CopyBuffer(ind, GATORLIPS_LINE, iB, 1, data); if (n<1) return(false); lips=data[0]; // скопировали значение индикатора

        // АО
        ind=iAO(smb, tf);
        n=CopyBuffer(ind, MAIN_LINE, iB, 2, data); if (n<2) return(false); ao0=data[0]; ao1=data[1]; // скопировали значение индикатора

        if (ao0>ao1) return(false); // гистограмма индикатора АО для этого бара - зелёная.

 
а вместо
iHigh

вам прийдётся делать через CopyHigh

 

Извините за назойливость вот что не так сделал ?

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   2
//---- plot UpSignal
#property indicator_label1  "UpSignal"
#property indicator_type1   DRAW_COLOR_ARROW
#property indicator_color1  Red,DodgerBlue
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//---- plot DnSignal
#property indicator_label2  "DnSignal"
#property indicator_type2   DRAW_COLOR_ARROW
#property indicator_color2  Red,Red
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1


input    ENUM_TIMEFRAMES WorkTimeFrame=0 ;
//int      ENUM_TIMEFRAMES TF;


//--- indicator buffers
double         UpSignalBuffer[];
double         UpSignalColors[];
double         DnSignalBuffer[];
double         DnSignalColors[];

int    AOpoint;
double AOBuff  [];
double High[],Low[];
string SY;
//+------------------------------------------------------------------+
//| Получим Low для заданного номера бара                            |
//+------------------------------------------------------------------+
double iLow(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double low=0;
   ArraySetAsSeries(Low,true);
   int copied=CopyLow(symbol,timeframe,0,Bars(symbol,timeframe),Low);
   if(copied>0 && index<copied) low=Low[index];
   return(low);
  }
//+------------------------------------------------------------------+
//| Получим High для заданного номера бара                           |
//+------------------------------------------------------------------+
double iHigh(string symbol,ENUM_TIMEFRAMES timeframe,int index)
  {
   double high=0;
   ArraySetAsSeries(High,true);
   int copied=CopyHigh(symbol,timeframe,0,Bars(symbol,timeframe),High);
   if(copied>0 && index<copied) high=High[index];
   return(high);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,UpSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,UpSignalColors,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(2,DnSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,DnSignalColors,INDICATOR_COLOR_INDEX);
//   if (WorkTimeFrame==0) TF=Period();
//   else TF=WorkTimeFrame ;
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| 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[])
  {
   AOpoint=iAO(SY,WorkTimeFrame);
//--- check if all data calculated
   if(BarsCalculated(AOpoint)<rates_total) return(0);
//--- we can copy not all data
   int to_copy;
   if(prev_calculated>rates_total || prev_calculated<=0) to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
      //--- last value is always copied
      to_copy++;
     }
   if(CopyBuffer(AOpoint,0,0,to_copy,AOBuff)<=0) return(0);
   for (int i=0;i<Bars(SY,WorkTimeFrame)-3;i++)
   {
    if (AOBuff[i]>AOBuff[i+1] && 
        AOBuff[i+2]>AOBuff[i+1]&&
        AOBuff[i]>0 &&
        AOBuff[i+2]>0) UpSignalBuffer[i]=iHigh(SY,WorkTimeFrame,i);
    
    if (AOBuff[i]<AOBuff[i+1] && 
        AOBuff[i+2]<AOBuff[i+1]&&
        AOBuff[i]<0 &&
        AOBuff[i+2]<0) DnSignalBuffer[i]=iLow (SY,WorkTimeFrame,i);
   }


//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Причина обращения: