BARS returning 0 ?

 

Hi.

I was using the recommended code to get Bars between two dates:

int bars=Bars(_Symbol,_Period, Start_Date, End_Date); 
   if(bars>0) 
     { 
      Print("Number of bars in the terminal history for the symbol-period at the moment = ",bars); 
     } 
   else  //no available bars 
     { 
      //--- data on the symbol might be not synchronized with data on the server 
      bool synchronized=false; 
      //--- loop counter 
      int attempts=0; 
      // make 5 attempts to wait for synchronization 
      while(attempts<5) 
        { 
         if(SeriesInfoInteger(Symbol(),0,SERIES_SYNCHRONIZED)) 
           { 
            //--- synchronization done, exit 
            synchronized=true; 
            break; 
           } 
         //--- increase the counter 
         attempts++; 
         //--- wait 10 milliseconds till the next iteration 
         Sleep(10); 
        } 
      //--- exit the loop after synchronization 
      if(synchronized) 
        { 

	 bars = Bars(_Symbol, _Period, Start_Date, End_Date);
         Print("Number of bars in the terminal history for the symbol-period at the moment = ",bars); 
         Print("The first date in the terminal history for the symbol-period at the moment = ", 
               (datetime)SeriesInfoInteger(Symbol(),0,SERIES_FIRSTDATE)); 
         Print("The first date in the history for the symbol on the server = ", 
               (datetime)SeriesInfoInteger(Symbol(),0,SERIES_SERVER_FIRSTDATE)); 
        } 
      //--- synchronization of data didn't happen 
      else 
        { 
         Print("Failed to get number of bars for ",_Symbol); 
        } 
     }


I guess after the update to version 3135 it had stoped - the function returns non-zero only if I don't define interval. Interesting notice that, seeing the above code:

- Bars are synchronized as well.

- The total amount of bars exceeds the amount I expect to get (just 4 months), so, I conclude the BARS( _Symbol, _Period) are available.

- The chart has the candles of the period of time I need to know how many bars exist.

- The _Period is M3.


Do you have any idea about what is going wrong on above code?
Thanks!

Documentation on MQL5: Timeseries and Indicators Access / Bars
Documentation on MQL5: Timeseries and Indicators Access / Bars
  • www.mql5.com
Bars - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
And what are the Start_Date, End_Date ?
 
Alain Verleyen #:
And what are the Start_Date, End_Date ?

They are defined as parameters as:

input datetime  Start_Date           = D'2021.08.02';   // INICIO (yyyy.mm.dd hh:mm)
input datetime  End_Date             = D'2021.12.21';   // FINAL  (yyyy.mm.dd hh:mm)


Interesting that in my pair (truly, is not a FOREX pair but a brazilian stock-exchange index), the time starts at 9:00 am and ends at 5:00pm.

Even trying the iBarShift() to get the nearest bar, it also returns zero.

 
AliceRioBR #:

They are defined as parameters as:


Interesting that in my pair (truly, is not a FOREX pair but a brazilian stock-exchange index), the time starts at 9:00 am and ends at 5:00pm.

Even trying the iBarShift() to get the nearest bar, it also return zero.

Then say me which pair you are using I will try directly on this symbol.

Build 3135 is a beta, perfectly possible to have a bug. Use beta only if you want to be a beta-tester.

 
Alain Verleyen #:

Then say me which pair you are using I will try directly on this symbol.

Build 3135 is a beta, perfectly possible to have a bug. Use beta only if you want to be a beta-tester.

Thanks a LOT Alain but I guess you won't get success in get that symbol:  IND$N 

 

Hmmm.... I guess my META just noticed me about a new version, without any warning about being a BETA.

But really, in the past I checked if META had a BETA version to upgrade my one. Would be possible my program is set to upgrade ALWAYS to BETA versions because of it?

I appreciate your help.

 
AliceRioBR #:

Thanks a LOT Alain but I guess you won't get success in get that symbol:  IND$N 

Really ? why ?

Here is what it gives me :


 
AliceRioBR #:

Hmmm.... I guess my META just noticed me about a new version, without any warning about being a BETA.

But really, in the past I checked if META had a BETA version to upgrade my one. Would be possible my program is set to upgrade ALWAYS to BETA versions because of it?

I appreciate your help.

I can't say why you get a beta. Usually it happens because you connect to MetaQuotes-Demo server, or it can be done manually. Unfortunately I also have seen beta pushed through brokers.
 
Alain Verleyen #:

Really ? why ?

Here is what it gives me :


:D  OMG!!!

So, the problem is my META in fact...

I will try to download the latest non-beta version and install over my one.

Are you brazilian Alain?

 
AliceRioBR #:

:D  OMG!!!

So, the problem is my META in fact...

I will try to download the latest non-beta version and install over my one.

Are you brazilian Alain?

Nope. I have good friends ;-)

By the way, my account is a demo. Should not make a difference, but who knows.

But for sure it's not a 3135 bug (I was using it for this test, I forgot to say it).

 
Alain Verleyen #:

Nope. I have good friends ;-)

By the way, my account is a demo. Should not make a difference, but who knows.

But for sure it's not a 3135 bug (I was using it for this test, I forgot to say it).

Wow.... that's worst to me, since now I will have to understand what is going on here.

Thank you VERY  much for your help Alain.

I wish you a Merry Christmas and a healthy (and profitable!) New Year!

Reason: