iBars() takes forever

 

Build 2190

My platform was crashing when I ran my code. I slimmed it right down to this

input ENUM_TIMEFRAMES    TF_Lowest         = PERIOD_D1;  // Time frame 1 (Lowest)
string       SymbolArray[];
bool         FirstTick=true;

//+------------------------------------------------------------------+
void OnTick()
  {
   if(FirstTick)
     {
      int TotalSymbols=SymbolsTotal(true);
      Print("Total Symbols = ",TotalSymbols);

      ArrayResize(SymbolArray,TotalSymbols);
      for(int x=0; x<TotalSymbols; x++)
         SymbolArray[x]=SymbolName(x,true);

      uint tc=GetTickCount();
      for(int x=TotalSymbols-1; x>=0; x--)
         //for(int x=100; x>=0; x--)
        {
         //Print("Symbol= ",SymbolArray[x]);
         int totalBars=iBars(SymbolArray[x],TF_Lowest);
        }
      Print("First Tick execution done in milliseconds - ",GetTickCount()-tc);

      FirstTick=false;
     }
//---
  }
//+------------------------------------------------------------------+

I ran the above code, there were no other indicators or EAs open on any of the charts.

2019.12.12 14:25:17.181 Update  Symbols (USDCHF,H4) Total Symbols = 1000

2019.12.12 14:58:45.864 Update  Symbols (USDCHF,H4) First Tick execution done in milliseconds - 2008688

Now I know that 1000 symbols is a lot to deal with, but over 33 minutes?????

Have I done something really daft that I just can't see?


 

Hi. My logs


MT4 TeleTrade

2019.12.12 14:51:37.193 Symbol GBPUSD,H1: Total Symbols = 116

2019.12.12 14:51:35.228 Symbol GBPUSD,H1 inputs: TF_Lowest=1440; 


MT5 2190

2019.12.12 14:50:29.357 Symbol (USDCNH,H1) First Tick execution done in milliseconds - 9579

2019.12.12 14:50:32.809 Symbol (USDCNH,H1) Total Symbols = 64


mayby small System perfomance? Try use MT4 he fasters

 

The odd thing is if I change the loop direction and only check the first 50 symbols in market watch

2019.12.12 21:08:19.262 Update  Symbols (USDCHF,H1) First Tick execution done in milliseconds - 0

Doesn't even register!

The first 100

2019.12.12 21:12:43.412 Update  Symbols (USDCHF,H1) First Tick execution done in milliseconds - 0

120

2019.12.12 21:26:08.184 Update  Symbols (USDCHF,D1) First Tick execution done in milliseconds - 265500

I got it to print out the symbols so that I could see where it stalls.

It seems that there are some symbols with no data at all and iBars can get stuck on these for minutes at a time for some reason.

Would have thought that it would just return 0,

 
Keith Watford:

The odd thing is if I change the loop direction and only check the first 50 symbols in market watch

2019.12.12 21:08:19.262 Update  Symbols (USDCHF,H1) First Tick execution done in milliseconds - 0

Doesn't even register!

The first 100

2019.12.12 21:12:43.412 Update  Symbols (USDCHF,H1) First Tick execution done in milliseconds - 0

120

2019.12.12 21:26:08.184 Update  Symbols (USDCHF,D1) First Tick execution done in milliseconds - 265500

I got it to print out the symbols so that I could see where it stalls.

It seems that there are some symbols with no data at all and iBars can get stuck on these for minutes at a time for some reason.

Would have thought that it would just return 0,

These "rogue" symbols cannot even be deleted from the MW window. This is ridiculous!

 
Maybe it is due to data needed to be downloaded.
 
Enrique Dangeroux:
Maybe it is due to data needed to be downloaded.

No Enrique, if I open the chart of one of these symbols it just stays in the state "Waiting for update".

 

I found similar problem about "rogue" symbols. It was not with Bars() but with SeriesInfoInteger() (takes around 4 minutes to return).

I asked clarification to Metaquotes but no answer until now.

 
Alain Verleyen:

I found similar problem about "rogue" symbols. It was not with Bars() but with SeriesInfoInteger() (takes around 4 minutes to return).

I asked clarification to Metaquotes but no answer until now.

Got an answer, they will check.
 

Other testing with iOpen() 

  static double op=0;
  double opNow=iOpen(_Symbol,PERIOD_M1,0);
  if(op!=opNow)
  {
  Print("Previous Open= ",DoubleToString(op,_Digits),"   This Open= ",DoubleToString(opNow,_Digits),"  Bar Time= ",TimeToString(iTime(_Symbol,PERIOD_M1,0)));
  op=opNow;
  }

in amongst the results

GG 0 13:16:00.689 Check iOpen (GBPUSD,D1) Previous Open= 1.33862   This Open= 1.33853  Bar Time= 2019.12.16 08:16

MI 0 13:17:01.524 Check iOpen (GBPUSD,D1) Previous Open= 1.33853   This Open= 1.33850  Bar Time= 2019.12.16 08:17

PK 0 13:17:29.484 Check iOpen (GBPUSD,D1) Previous Open= 1.33850   This Open= 0.00000  Bar Time= 1970.01.01 00:00

FL 0 13:17:29.939 Check iOpen (GBPUSD,D1) Previous Open= 0.00000   This Open= 1.33850  Bar Time= 2019.12.16 08:17

NN 0 13:18:00.413 Check iOpen (GBPUSD,D1) Previous Open= 1.33850   This Open= 1.33854  Bar Time= 2019.12.16 08:18

-------

DH 0 13:59:07.908 Check iOpen (GBPUSD,D1) Previous Open= 1.34152   This Open= 1.34132  Bar Time= 2019.12.16 08:59

FJ 0 14:00:10.441 Check iOpen (GBPUSD,D1) Previous Open= 1.34132   This Open= 0.00000  Bar Time= 1970.01.01 00:00

JL 0 14:00:11.117 Check iOpen (GBPUSD,D1) Previous Open= 0.00000   This Open= 1.34132  Bar Time= 2019.12.16 08:59

-------

JD 0 14:05:38.602 Check iOpen (GBPUSD,D1) Previous Open= 1.34112   This Open= 1.34121  Bar Time= 2019.12.16 09:04

ME 0 14:05:39.482 Check iOpen (GBPUSD,D1) Previous Open= 1.34121   This Open= 0.00000  Bar Time= 1970.01.01 00:00

IG 0 14:05:42.976 Check iOpen (GBPUSD,D1) Previous Open= 0.00000   This Open= 1.34121  Bar Time= 2019.12.16 09:04

That's 3 times returning 0 from running the code for about an hour.

 
Keith Watford:

Other testing with iOpen() 

in amongst the results

GG 0 13:16:00.689 Check iOpen (GBPUSD,D1) Previous Open= 1.33862   This Open= 1.33853  Bar Time= 2019.12.16 08:16

MI 0 13:17:01.524 Check iOpen (GBPUSD,D1) Previous Open= 1.33853   This Open= 1.33850  Bar Time= 2019.12.16 08:17

PK 0 13:17:29.484 Check iOpen (GBPUSD,D1) Previous Open= 1.33850    This Open= 0.00000  Bar Time= 1970.01.01 00:00

FL 0 13:17:29.939 Check iOpen (GBPUSD,D1) Previous Open= 0.00000   This Open= 1.33850  Bar Time= 2019.12.16 08:17

NN 0 13:18:00.413 Check iOpen (GBPUSD,D1) Previous Open= 1.33850   This Open= 1.33854  Bar Time= 2019.12.16 08:18

-------

DH 0 13:59:07.908 Check iOpen (GBPUSD,D1) Previous Open= 1.34152   This Open= 1.34132  Bar Time= 2019.12.16 08:59

FJ 0 14:00:10.441 Check iOpen (GBPUSD,D1) Previous Open= 1.34132    This Open= 0.00000  Bar Time= 1970.01.01 00:00

JL 0 14:00:11.117 Check iOpen (GBPUSD,D1) Previous Open= 0.00000   This Open= 1.34132  Bar Time= 2019.12.16 08:59

-------

JD 0 14:05:38.602 Check iOpen (GBPUSD,D1) Previous Open= 1.34112   This Open= 1.34121  Bar Time= 2019.12.16 09:04

ME 0 14:05:39.482 Check iOpen (GBPUSD,D1) Previous Open= 1.34121    This Open= 0.00000  Bar Time= 1970.01.01 00:00

IG 0 14:05:42.976 Check iOpen (GBPUSD,D1) Previous Open= 0.00000   This Open= 1.34121  Bar Time= 2019.12.16 09:04

That's 3 times returning 0 from running the code for about an hour.

I am afraid it's normal behaviour when getting OHLC from an other timeframe than the chart.
 
Alain Verleyen:
I am afraid it's normal behaviour when getting OHLC from an other timeframe than the chart.

If it is normal, then that is not good. I will have to remember to check the returned values and whether to exclude them, especially for the time.

Reason: