Errors, bugs, questions - page 109

 

Hello all! I am trying to write a Pivot Point indicator, the calculations are correct, but the line is not drawn correctly, please help me to understand the problem in my code or in the terminal

#property indicator_chart_window

#property indicator_buffers 1
#property indicator_plots   1
#property indicator_type1   DRAW_LINE
#property indicator_color1  Orange

double PBuffer[];

double H[1];
double L[1];
double C[1];
datetime Time[2];

MqlDateTime str1;
MqlDateTime str2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,PBuffer,INDICATOR_DATA);
//---
   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[])
  {
//---
//--- return value of prev_calculated for next call
//int    limit=Bars(_Symbol,PERIOD_CURRENT)-1;
   //int    limit=rates_total-1;
   int n=0;

   ArraySetAsSeries(H,true);
   ArraySetAsSeries(L,true);
   ArraySetAsSeries(C,true);
   ArraySetAsSeries(Time,true);

   CopyHigh(_Symbol,PERIOD_D1,1,1,H);
   CopyLow(_Symbol,PERIOD_D1,1,1,L);
   CopyClose(_Symbol,PERIOD_D1,1,1,C);

//for(int i=10; i>=0;i--)
   for(int i=0;i<24;i++)
     {
      //Print(i," - й проход");
      //Print("Н[0] = ",H[0],", L[0] = ",L[0],", C[0] = ",C[0]);
      CopyTime(_Symbol,PERIOD_CURRENT,i+1,2,Time);
      TimeToStruct(Time[0],str1);
      TimeToStruct(Time[1],str2);
      //Print("str1.day = ",str1.day,", str2.day = ",str2.day);
      if(str1.day!=str2.day)
        {
         //Print("Сработало условие str1.day!=str2.day");
         n++;
         CopyHigh(_Symbol,PERIOD_D1,n+1,1,H);
         CopyLow(_Symbol,PERIOD_D1,n+1,1,L);
         CopyClose(_Symbol,PERIOD_D1,n+1,1,C);
         //Print("Получили новые данные для Н[0] = ",H[0],", L[0] = ",L[0],", C[0] = ",C[0]);
        }
      PBuffer[i]=(H[0]+L[0]+C[0])/3;
      //Print("PBuffer[",i,"] = ",PBuffer[i]);
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования - Документация по MQL5
Files:
 

Can you tell me what I'm doing wrong?

Alert(" фрактал нижний=",Фракталы(Symbol(),PERIOD_CURRENT,1,4)," фрактал верхний=",Фракталы(Symbol(),PERIOD_CURRENT,0,4));



double Фракталы(string символ,ENUM_TIMEFRAMES период,int буфер,int бар)
  {          //Номера буферов: 0 - UPPER_LINE, 1 - LOWER_LINE.
   double ЗначениеФрактал[1];
   int Fractals=iFractals(символ,период);
   CopyBuffer(Fractals,буфер,бар,1,ЗначениеФрактал);
   return(ЗначениеФрактал[0]);
  }

If the bar hits a fractal, the value is correct. But if it misses, it returns the maximal value of double type 1.7976931348623158e+308

and zero should be returned

 
Dmitriy2:

Can you tell me what I'm doing wrong?

If the bar hits a fractal, the value is correct. But if it misses, it returns the maximal value of double type 1.7976931348623158e+308

and zero should be returned

EMPTY_VALUE is given to you, you can read it here
 

Good afternoon!

I've started studying MQL5, but so far I'm not very good at it. How do I convert this function to MQL5 ?

val1=(Low[iLowest(NULL,PERIOD_M15,MODE_LOW,3,1)]

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков - Документация по MQL5
 

mql5:
Вам отдаётся EMPTY_VALUE, прочитать можно тут

I see, thank you.
 
abeiks:

Good afternoon!

I've started studying MQL5, but so far I'm not very good at it. How do I convert this function to MQL5 ?

val1=(Low[iLowest(NULL,PERIOD_M15,MODE_LOW,3,1)]

Are you familiar with the article Migration from MQL4 to MQL5?
 
Interesting:
Have you already read the article " Migration from MQL4 to MQL5 "?

I am looking at this article, but not everything is clear to me as a non-programmer. That's why I would like to see the converted function in MQL5, in order to compare it with the one I understand in MQL4.

 
Interesting:
Have you already read the article Migration from MQL4 to MQL5?

I also had a simple function if(DayOfWeek()==5) {.

But now I don't know how to convert it to MQL5.

 

Has anyone by any chance donesuch a library (russified stdlib.mqh) on MKL5? I mean with new codes

Русифицированная и немного переделанная stdlib.mqh - может кому пригодится. . . - MQL4 форум
  • www.mql5.com
Русифицированная и немного переделанная stdlib.mqh - может кому пригодится. . . - MQL4 форум
 
Dmitriy2:

Has anyone by any chance donesuch a library (russified stdlib.mqh) on MKL5? I mean with new codes

For error codes there is ErrorDescription.mqh
Reason: