OHLC Data not generated when programmatically loading tick data into a custom symbol using CustomTicksAdd() and CustomTicksReplace()

 

I have really struggled to find any information to help me resolve my issue, so am hoping someone on the forum can.

I have written an MQL5 script to create custom symbols and load tick data into them from csv files.

int numTicksLoaded = CustomTicksReplace("AUDNZD_T_SVS", milliSecondTime_FirstTick, milliSecondTime_LastTick, tick_data, WHOLE_ARRAY);

where tick_data has been populated from the csv.

This seemingly all works fine and I can go into the MT5 Symbol Manager and see the custom symbols and the tick data as shown here:

 


However, there is a difference in the behaviour compared to loading tick data manually via the MT5 user interface (using 'Import Ticks' button). When done from the UI, M1 OHLC also gets automatically generated in the same custom symbol. But when doing programmatically via CustomTicksAdd() and CustomTicksReplace() this does not happen. So when you try to view a chart, the following is shown instead of a chart:


Is there an additional step I need to take in code after I have executed CustomTicksAdd() / CustomTicksReplace() to force the M1 data to be generated, like it is automatically in the UI?

One additional thing I have tried is to also programmatically load the M1 OHLC data (using CustomRatesReplace()) into the same custom symbol I loaded the tick data into. This then does allow the chart to be viewed correctly but when using the 'real ticks' option in the Strategy Tester, issues are encountered and Visual mode does not show any M1 bars being generated, and as a result no trades are generated.

I would have expected  CustomTicksAdd() and CustomTicksReplace() to replicate the behaviour from loading ticks in the UI but this does not appear to be the case.

Any help appreciated. 

 

Tick data and and OHLC data are handled separately when done programmatically. You have to generate the M1 OHLC data as well yourself from your tick data.

At least that has been my experience. I don't know if it is mentioned in the documentation.

EDIT: It probably works like this so that users can generate non-standard time-frames (e.g. Renko). If the platform did it automatically, then it would not be possible to make those non-standard types.

 
Fernando Carreiro #:

Tick data and and OHLC data are handled separately when done programmatically. You have to generate the M1 OHLC data as well yourself from your tick data.

At least that has been my experience. I don't know if it is mentioned in the documentation.

EDIT: It probably works like this so that users can generate non-standard time-frames (e.g. Renko). If the platform did it automatically, then it would not be possible to make those non-standard types.

Hi Fernando

Thanks for the response. No the documentation doesn't mention that, but I do understand your reasoning.

However, as I said I did try to load the M1 Bar data (again in code) after the script had loaded the tick data. This meant that I could now view the custom symbol on a chart successfuly, but unfortunately when I attempted to backtest (using real ticks) it didn't work. Using visual mode I can see the bid and ask moving (which I assume is coming from the tick data I loaded), but M1 bars and the chart TF bars do not get drawn. In turn ths causes the EA to not make any trades (because of course the indicators rely on the bar data).

When I look at the custom symbol in the symbol manager I can see the bar data and it looks fine (just like the tick data also looks ok). They both look exactly like they do for a standard broker symbol. So I can't imagine what's happening behind the scenes to cause it to fail in the Strategy Tester?

I might just have to resort back to manual loading in the UI, but that will mean I can't automate the end-to-end process to update weekly :(

 
Martyn Tinsley #: Thanks for the response. No the documentation doesn't mention that, but I do understand your reasoning. However, as I said I did try to load the M1 Bar data (again in code) after the script had loaded the tick data. This meant that I could now view the custom symbol on a chart successfuly, but unfortunately when I attempted to backtest (using real ticks) it didn't work. Using visual mode I can see the bid and ask moving (which I assume is coming from the tick data I loaded), but M1 bars and the chart TF bars do not get drawn. In turn ths causes the EA to not make any trades (because of course the indicators rely on the bar data). When I look at the custom symbol in the symbol manager I can see the bar data and it looks fine (just like the tick data also looks ok). They both look exactly like they do for a standard broker symbol. So I can't imagine whats happening behind the scenes to cause it to fail in the Strategy Tester? I might just have to resort back to manual loading in the UI, but that will mean I can't automate the end-to-end process to update weekly :(

Since we can't see your computer nor your code that generates you Custom Symbol, it is difficult for us to comment on the issue.

Reason: