Errors, bugs, questions - page 1460

 
can't find the iBarsShiaft analogue in MQL5 . suggest ....
 
Vladimir Pastushak:
can't find the iBarsShiaft analogue in MQL5 . suggest ....
int iBarShift(string symbol,
                  int tf,
                  datetime time,
                  bool exact=false)
  {
   if(time<0) return(-1);
   ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
   datetime Arr[],time1;
   CopyTime(symbol,timeframe,0,1,Arr);
   time1=Arr[0];
   if(CopyTime(symbol,timeframe,time,time1,Arr)>0)
     {
      if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
      if(time<time1) return(1);
      else return(0);
     }
   else return(-1);
  }
 
Vladislav Andruschenko:

I did it a little differently, I think it's more reliable:

//+------------------------------------------------------------------+
int BarsShift(const string sym,const ENUM_TIMEFRAMES tim,const datetime time)
  {
   if(time<0)return -1;
   datetime mas[]; int z=-1;
   while(z++<3)
      if(CopyTime(sym,tim,TimeCurrent(),time,mas)>0)
         return ArraySize(mas);
   else
      Sleep(500);
   Print(" Erorr Search BarsShift ",GetLastError());
   return -1;
  }
//+------------------------------------------------------------------+

What do you think?

 

Dear colleagues, who can tell me what the problem is and why the indicator is crumbling (lots of extra arrows) after a while of operation?

I noticed it only on m1. After I re-trigger the TF, all is displayed normally.

Is the problem in the indicator or in the terminal and m1 quotes?


 
Aleksandr Novikov:

Dear colleagues, who can tell me what the problem is and why the indicator is crumbling (lots of extra arrows) after a while of operation?

I noticed it only on m1. After I re-trigger the TF, all is displayed normally.

The problem with the indicator or the terminal and the m1 quotes?


Zero the buffers inside the loop at the very beginning, before calculation of buffer values.
Buffer[i]=0;
 
Vladimir Pastushak:
I cannot find iBarsShiaft analogue in MQL5 . suggest ....
Actually the 2nd variant of Bars function is a direct analogue, but it has some glitches. To be more precise, they used to in the beginning of the year, maybe they were already fixed.
 

Compiler thinks and thinks and silently dies with editor on this short program (32,64 bit, including different OS - same):

struct TCoord {
        int x, y;
};

void OnStart() {        
        TCoord coord = {100, 100};
        TCoord defaultCoord = {0,0};
        coord = (2 == 2) ? coord : defaultCoord;
}
Somewhere a bug in the optimizer.
By the way, when MetaEditor crashes, its state(open files, interface settings) is not saved.
 
Aleksandr Novikov :


When this happens the indicator restarts ... and everything goes back to normal.
 
Rodrigo da Silva Boa:
When this happens the indicator restarts ... and everything goes back to normal.

There is no need to restart anything. It is the rubbish in the buffers that needs to be cleaned in the indicator cycle. For example:

   for(int i=limit; i>=0; i--) {
      BufferPatternDN[i]=0;               // без обнуления буферов мусор в них появляется постоянно
      BufferPatternUP[i]=0;
      BufferLevelDN[i]=EMPTY_VALUE;
      BufferLevelUP[i]=EMPTY_VALUE;
      // ... остальной код расчёта буферов
      // ...
   }  // конец цикла

You just need to add buffer zeroing to the beginning of the cycle, instead of restarting the indicator constantly when there is junk on the chart

 

How do I defeat this? Ubuntu in a virtual box, all programs go online without a proxy, direct connection everywhere

but the terminal keeps asking for a proxy.

Reason: