Custom symbol - sequence of events

 

I have created a custom symbol using CustomSymbolCreate(). The sole purpose of this symbol is to create a chart that will be used for displaying data, so I am not interested in any tick data.

When I run my EA, I switch to the new symbol using...

ChartSetSymbolPeriod(0, "MySymbol", PERIOD_M1);

My custom chart is then reloaded, but none of the information that I want to display on the chart is displayed.

I figured the problem may be caused by a lack of data, so as a test I added the following code to a timer event in my EA (just to generate some data)...

        MqlTick ta[1];
        ta[0].time = D'2024.01.08 00:00';
        CustomTicksAdd(_Symbol, ta);

        ta[0].time = D'2024.01.09 01:00';
        CustomTicksAdd(_Symbol, ta);

        ta[0].time = D'2024.01.10 02:00';
        CustomTicksAdd(_Symbol, ta);

I put a break point in the OnTick() function, but the break point was never hit. I ran the EA multiple times over a period of time (15-20 minutes), but with the same result. I then stopped and restarted MT5 and tried again, but still no luck. I then checked the MT5\Bases\Custom\ticks folder but could not see a folder for my custom symbol. I restarted MT5 3-4 more times and eventually the break point in the OnTick() function was hit and the chart displayed the contents as expected. I then checked the 

MT5\Bases\Custom\ticks folder again, and this time a folder for my custom symbol was present.

So my code is now doing what I expect, but I would like to get a better understanding of the sequence of events that led to it working.

So if I was to delete everything and start again, can anyone enlighten me with regards to the minimum steps that I need to take to ensure the successful creation of a chart that gets updated correctly?

Currently my observations, which are not correct, are...

  1. Create custom symbol
  2. Switch to custom symbol
  3. Generate some data
  4. Restart (trial-and-error) until the EA works as expected.