Does Bars() actually pull data for higher TF?

To add comments, please log in or register
Anthony Garot
1813
Anthony Garot  

I have an indicator that runs on D1 and pulls a values from W1 using iBarShift(). When the data isn't there, it isn't there, so I need to pull it.

The first script example of https://www.mql5.com/en/docs/series/bars has a synchronization technique that I hadn't seen before. It appears that the call to Bars() instantiates the pull request, and repeated checks on SERIES_SYNCHRONIZED tells whether the data has come in yet.

But there is nothing in the documentation to suggest that Bars() requests a pull of data.

Implementing this technique, my indicator does indeed request higher TF values when I add the indicator in Terminal to a chart.

Problems with back testing:

When I run my indicator through the Tester, the Bars() technique does not pull the higher TF data. Bars() always returns 0, and iBarShift() returns -1 always.

Weird.

Getting it to work:

So, I revamped my synchronization technique to use CopyTime() instead. At least with CopyTime(), the documentation is explicit:

 the function will immediately return -1, but the process of downloading/building will be initiated.

And now my indicator works in Terminal and also in the Tester. So, I should have done this in the first place.


So I guess I am confused about the script in the Bars() documentation that supposedly synchronizes data. It misled me. What is this, and what would I use it for?

To add comments, please log in or register