Is it possible to load only 100 bars of the complete history?

 

Hello,

I code a scanner which scans around 30 pairs and 6 timeframes. I use only one open chart for the scanner and to make sure that the necessary historical data is loaded I use Bars().

Is there a possibility to do it another (faster) way because I only check the last 100 bars for my calculation?

This is a part of my code:

for (int i=0; i<ArraySize(pairs); i++) {
   for (int j=0; j<ArraySize(timeframes); j++) {
      int bars=Bars(pairs[i], timeframes[j]);      // loads history of specified pair and timeframe
   }
}

Thank you!

 
  1. Your comment is wrong. It does not “loads history,” it queues the download to start.

    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 2019.05.20

    The function linked to, opens a hidden chart for the symbol/TF in question (if not already open), thus updating history, and temporarily placing the symbol on Market Watch (if not already there), so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero on the first call.

    On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
              Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 2020.12.15
              Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum 2019.05.31
              Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
              Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 2018.07.17
              SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum 2019.09.03
              OnCalculate during weekend MT5 - General - MQL5 programming forum

  2. Fast is irrevalent; it takes time to go to the server and download history. Once you activate those symbols/TF they will be maintained continuously (as long as you keep using them).

 
William Roeder:
  1. Your comment is wrong. It does not “loads history,” it queues the download to start.

  2. Fast is irrevalent; it takes time to go to the server and download history. Once you activate those symbols/TF they will be maintained continuously (as long as you keep using them).

Thank you very much for the links. I will read them and hopefully find a solution to download the histories in the background.