Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 849

 
Sergey Voytsekhovsky:

If you can't see the log in the picture, here are a few of the most recent entries

Sorry, there was an error in Print() for the down arrow, the time of the up arrow was being substituted, corrected it, but it doesn't matter now.

 
Sergey Voytsekhovsky:

if you can't see the logbook in the picture, here are a few of the most recent entries

Is the time of the rightmost candle 10:00 on the hourly chart?

 
Alexey Viktorov:

Is the time of the rightmost candle 10:00 on the hourly chart?

That's what I'm talking about, the Expert Advisor can't see the edge candle, and I can't get to the error, so I'm shouting for help

https://www.mql5.com/ru/forum/160683/page848#comment_11761231

Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
Любые вопросы новичков по MQL4 и MQL5, помощь и обсуждение по алгоритмам и кодам
  • 2019.05.20
  • www.mql5.com
В этой ветке я хочу начать свою помощь тем, кто действительно хочет разобраться и научиться программированию на новом MQL4 и желает легко перейти н...
 

Here is a picture of the corrected Print() for the Down arrow


 
void OnTick()
  {
   if (CopyBuffer(CrossAD, 1, 0, period_find, Buf_Arrow_Buy) != period_find)
      {  
         Print("НЕ удалось правильно скопировать данные из 1-го буфера индикатора iCrossAD, error code %d",GetLastError());
         return;
      }
         for(int n=0; n<(int)period_find; n++)
            {
               if(Buf_Arrow_Buy[n]!=EMPTY_VALUE)
               {
                  Last_Arrow_Buy_volume = iOpen(_Symbol,_Period,n);
                  Last_Arrow_Buy_time   = iTime(_Symbol,0,n);
                  Last_Arrow_Buy_index  = n;
                  Print("Last_Arrow_Buy_volume = ",Last_Arrow_Buy_volume,", Last_Arrow_Buy_index = ",Last_Arrow_Buy_index,", Last_Arrow_Buy_time = ",Last_Arrow_Buy_time);
                  break;
               }   
            }
         
   if (CopyBuffer(CrossAD, 2, 0, period_find, Buf_Arrow_Sell) != period_find)
      {  
         Print("НЕ удалось правильно скопировать данные из 2-го буфера индикатора iCrossAD, error code %d",GetLastError());
         return;
      }
         for(int n=0; n<(int)period_find; n++)
            {
               if(Buf_Arrow_Sell[n]!=EMPTY_VALUE)
               {
                  Last_Arrow_Sell_volume = iOpen(_Symbol,_Period,n);
                  Last_Arrow_Sell_time   = iTime(_Symbol,0,n);
                  Last_Arrow_Sell_index  = n;
                  Print("Last_Arrow_Sell_volume = ",Last_Arrow_Sell_volume,", Last_Arrow_Sell_index = ",Last_Arrow_Sell_index,", Last_Arrow_Sell_time = ",Last_Arrow_Sell_time);
                  break;
               }
            }
      
Comment("-------------------------", 
         "\n Last_Arrow_Buy_volume     = ",Last_Arrow_Buy_volume,
         "\n Last_Arrow_Buy_index        = ",Last_Arrow_Buy_index,
         "\n Last_Arrow_Buy_time         = ",Last_Arrow_Buy_time,
         "\n ---------------------- ",
         "\n Last_Arrow_Sell_volume     = ",Last_Arrow_Sell_volume,
         "\n Last_Arrow_Sell_index        = ",Last_Arrow_Sell_index,
         "\n Last_Arrow_Sell_time         = ",Last_Arrow_Sell_time
         ); 
  }
Files:
 
Sergey Voytsekhovsky:

Did you do ArraySetAsSeries() on both arrays ?

Документация по MQL5: Операции с массивами / ArraySetAsSeries
Документация по MQL5: Операции с массивами / ArraySetAsSeries
  • www.mql5.com
//| Custom indicator initialization function                         | //| Custom indicator iteration function                              |
 
Artyom Trishkin:

Did you do ArraySetAsSeries() on both arrays?

Yes, to both.

int OnInit()
  {
   ArraySetAsSeries(Buf_Arrow_Buy, true);
   ArraySetAsSeries(Buf_Arrow_Sell, true);
//---
   CrossAD = iCustom(asymbol.Name(), _Period, "iCrossAD");
   if (CrossAD == INVALID_HANDLE)
   {
      Print("Не удалось создать описатель индикатора iCrossAD!");
      return(INIT_FAILED);
   }
      else Print("Хендл iCrossAD = ",CrossAD);
//---
   return(INIT_SUCCEEDED);
  }

I noticed that on theiCustom indicator activated in parallel on the chart, the arrows on the main chart do not show up. Can it be the reason?

 
Sergey Voytsekhovsky:

Yes, to both.

I noticed that on theiCustom indicator activated in parallel on the chart, the arrows on the main chart do not show up. Can this be the reason,...?

In the loop, when n==0 print the time of bar n - you will immediately understand where the loop begins.

 
Sergey Voytsekhovsky:

Yes, to both.

I noticed that on theiCustom indicator activated in parallel on the chart, the arrows on the main chart do not show up. Can this be the reason?

I removed and put the indicator back on, arrows appeared, EA still does not see the arrow

 
Sergey Voytsekhovsky:

Took it down and put the indicator back up, arrows appeared, EA still does not see the arrow at the end

I compiled the Expert Advisor - the arrows of the parallel running indicator on the main chart have disappeared. Some kind of hobgoblin has started or what?

Reason: