1

I'm building my first indicator. I want to retrieve all the historical bars of a symbol in some graphical period; in concrete in H1 timeFrame.

But the next code returns very different results, depending of the Symbol().

For example, for USDCHF, it returns 19752, which seems to be correct;
but, for EURUSD, it returns only 2047, which, for me, seems rather a few bars.

int totalBars = Bars( Symbol(), PERIOD_H1 );

Any help will be appreciated.

Thanks!

user3666197
  • 1
  • 6
  • 50
  • 92
JLLMNCHR
  • 1,551
  • 5
  • 24
  • 50

1 Answers1

3

The posted numbers seem fair

Typically, until you hit a "ceiling", pre-set in MT4/Terminal settings, the number of Bars changes. From small numbers up. Say from a few thousands to more than 1.000.000 bars, if one wishes ( and takes care ).

Once you are comfortable with loading OHLCV-datapoints from your Broker, there is one more speciality in how #indicators handle their MQL4 code-execution, which is different from any your prior experience with { Script | ExpertAdvisor } code, but will not complicate the story right in the start.

MQL4 (un)predictable distributed storage

Well, your next surprise for today, webmeiker

MQL4 code cannot on it's own explicitly manage data access.

In principle, Broker defines it's data-retrieval policy. MT4/Terminal piece of software runs a localhost part of the circus.

A Graph constitutes a view into a (hidden) model.

F2 may introduce you to the History Center interface, which may help you inspect how deep into past your Bar-inventory goes.

Load 'em ALL!

Well, the ALL itself is not under your control.

If and only if your Broker allows, you may do a few tricks to receive more "historical" datapoints.

Time, as usual, works against you in this dilemma. After some time, Broker need not allow you anymore to re-load history and your "missed" part of the OHLCV-world will then remain un-retrievable.

So a due care is in place.

If interested in how to load more bars from your Broker, do not hesitate to raise a question on this trick.

user3666197
  • 1
  • 6
  • 50
  • 92
  • Oughhh, I am very newbie to assimilate all this information. I dont find the MT4/Terminal settings option to hit the ceilling preset you mentions. Also I have no previous experience with the History Center ... – JLLMNCHR Aug 24 '15 at 14:39
  • :o) hope you enjoyed the Janet Bernanke joke – user3666197 Sep 18 '15 at 22:32