Questions from a "dummy" - page 38

 

And so. It's happening! Not even a year later. I made up my mind! I checked the documentation of MQL5. I started out very small: I minimized some code of some indicator in an attempt to simplify and understand its structure and operation. Then I got dazed.

First I dug Fractals - it appeared to be unexpectedly small and very simple. Then I reasoned logically: it's not reasonable to drag this code from one program to another, I should just call this indicator, copy and use the ready calculated buffer values. If I am not mistaken direction, I was carried to the near-standard step and brought to an example with iFractals ("Did I do it right?" (c)). I reduced code as much as possible, cleared all unnecessary and conventionally unnecessary, leaving only the essence. And what did I find? The code of the indicator call is no more compact than the original code of the indicator itself in terms of size and readability.

The questions.

1. What is the meaning of iFractals?

2. What is wrong with me?

Thanks!

P.S.: Or is it just a special case where there is no benefit in the amount of second code?

 
x100intraday:

2. What is wrong with me?

This is not a forum for psychiatrists, but for MQL programmers. You don't usually want to go poking around in other people's cockroaches.

Be more specific in your questions.
 

It's a matter of

of life and death...

What is the non-criminal way to get the value of open [15625] bar H1 of timeframe

I tried no matter how hard I tried it but it says critical error... I tried everything, so who knows... I know it's 3 lines of code... but which... the right... the right... so it doesn't throw an error...

 
BaTTLeBLooM:

It's a matter of

of life and death...

What non-criminal way to get open [15625] bar value of H1 timeframe

I tried my best to get a critical error... I tried all sorts of things, so who knows... I know it's 3 lines of code... but what are the... the right... the right... so it doesn't throw an error...


Please give me your code.

 
Renat:

Please give us your code.

here is

double MTime ( int mode )
{

double iOpen_min [], iOpen_hour [], iOpen_4hour [];

ArraySetAsSeries ( iOpen_min, true );
ArraySetAsSeries ( iOpen_hour, true );
ArraySetAsSeries ( iOpen_4hour, true );
int rates_open_min, rates_open_hour, rates_open_4hour;
int err = 0;
do
{
rates_open_min = CopyOpen ( NULL, PERIOD_M1, 0, 7501, iOpen_min );
rates_open_hour = CopyOpen ( NULL, PERIOD_H1, 0, 20000, iOpen_hour );
rates_open_4hour = CopyOpen ( NULL, PERIOD_H4, 0, 10000, iOpen_4hour );
err ++;
}
while ( ( rates_open_min <= 0 || rates_open_hour <= 0 || rates_open_4hour <= 0) && err < 10 );

double Minute2 = iOpen_min [ 0 ] - iOpen_min [ 2 ];
double Minute12 = iOpen_min [ 0 ] - iOpen_min [ 12 ];
double Hour = iOpen_min [ 0 ] - iOpen_min [ 60 ]; // Hour
double Hour5 = iOpen_min [ 0 ] - iOpen_min [ 300 ]; // 5 Hour
double Day = iOpen_min [ 0 ] - iOpen_min [ 1500 ]; // Day
double Week = iOpen_min [ 0 ] - iOpen_min [ 7500 ]; // Week
double Month = iOpen_hour [ 0 ] - iOpen_hour [ 625 ]; // Month
double Month5 = iOpen_hour [ 0 ] - iOpen_hour [ 3125 ]; // Half Year

double Month25 = iOpen_hour [ 0 ] - iOpen_hour [ 15625 ]; // 3 years

on the last line on the last operator, there is always a critical error... The Expert Advisor may even start to trade in the Strategy Tester, and then, after a year and a half of running, it generates an error and crashes

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

the critical error is exceeding the array's limits.

somehow you could try this:

      do
         {    
            //if(err>0) Sleep(10);//желательно с паузой
            rates_open_min = CopyOpen ( NULL, PERIOD_M1, 0, 7501, iOpen_min );
            rates_open_hour = CopyOpen ( NULL, PERIOD_H1, 0, 20000, iOpen_hour );
            rates_open_4hour = CopyOpen ( NULL, PERIOD_H4, 0, 10000, iOpen_4hour );           
            err ++;
         }
      while ( ( rates_open_min < 7501 || rates_open_hour < 20000 || rates_open_4hour < 10000) && err < 10 );   

   if(rates_open_min<7501 || rates_open_hour<20000 || rates_open_4hour<10000) return(-1);//Данные не скопированы
   else
      {
      double Minute2 = iOpen_min [ 0 ] - iOpen_min [ 2 ];
      double Minute12 = iOpen_min [ 0 ] - iOpen_min [ 12 ];
      double Hour = iOpen_min [ 0 ] - iOpen_min [ 60 ];   // Час
      double Hour5 = iOpen_min [ 0 ] - iOpen_min [ 300 ];     // 5 Часов
      double Day = iOpen_min [ 0 ] - iOpen_min [ 1500 ];   // День
      double Week = iOpen_min [ 0 ] - iOpen_min [ 7500 ];  // Неделя
      double Month = iOpen_hour [ 0 ] - iOpen_hour [ 625 ];   // Месяц
      double Month5 = iOpen_hour [ 0 ] - iOpen_hour [ 3125 ];  // Полугодие
      double Month25 = iOpen_hour [ 0 ] - iOpen_hour [ 15625 ];  // 3 года
      }
 
Swan:

critical error - exceeding the array limits.

somehow, we can try it this way:

This doesn't change the essence of the problem... If it does not copy the data further... The Expert Advisor will not trade as before, but with no error...

The problem is why this situation occurs in the first place, if the history is huge... and you can't use it...

 
Renat:

Please provide your code.

Well, since there's no answer, I'll just enter )))) manually, since there's only one value
 
BaTTLeBLooM:
Well, since there's no answer, I'll just enter )))) manually, since there's only one value.

You don't have any checks in your code. What do you want then?

 
BaTTLeBLooM:

This doesn't change the problem... if he doesn't copy the data further... The Expert Advisor will not trade as before, but with no error...

The problem is why this situation occurs at all, if the history is huge... and you can't use it...

The data will be copied, but not always at the first try ... and after a critical error, the Expert Advisor stops working.

while( ... rates_open_hour <= 0 // only the amount of data, available at the moment, will be copied, and the array, respectively, may be less than 15625.


The situation occurs due to lack of reading of manuals :)

Документация по MQL5: Программы MQL5 / Ошибки выполнения
Документация по MQL5: Программы MQL5 / Ошибки выполнения
  • www.mql5.com
Программы MQL5 / Ошибки выполнения - Документация по MQL5