How to add MqlTick data to a custom symbol via CustomTicksUpdate function

To add comments, please log in or register
sezaru
25
sezaru  

I have a custom symbol that I created and I want to add MqlTick data to it using the function CustomTicksUpdate (In the documentation it's called CustomTicksAdd, but this function doesn't exists inside mql5, I think the documentation is outdated).

To do that, I have a timer in my EA and every time OnTimer is called, I try to add a MqlTick, the way I'm doing that for now as a test is like that:

void OnTimer()
{
   MqlTick ticks_array[1];
   ticks_array[0].ask = 1.32787;
   ticks_array[0].flags = TICK_FLAG_BID;
   ticks_array[0].time = TimeLocal();
   ticks_array[0].time_msc = 0;
   
   Print(CustomTicksUpdate(symbol, ticks_array));
}

As you can see, I create a MqlTick array, with one position, add a ask value, set the flag and time and send it as a parameter to CustomTicksUpdate.

As far as I know, this should work no problem, but every time CustomTicksUpdate is called, I receive a -1 as return value.

Calling GetLastError returns the error id 5304:

ERR_CUSTOM_SYMBOL_EXIST

5304

A custom symbol with the same name already exists


I don't get it, why is it returning this error? It's obvious that this symbol already exists, it's the symbol that I'm trying to update the ticks data..

Calling CustomRatesUpdate to add Rates data to that same symbol works flawlessly.

What I'm doing wrong?


Thanks.

fxsaber
10292
fxsaber  

MT5 1653 build.

sezaru
25
sezaru  
fxsaber:

MT5 1653 build.

How can I get this build version? Installing from the net installer always install build 1643.
Jose Francisco Casado Fernandez
5160
Jose Francisco Casado Fernandez  
sezaru:
How can I get this build version? Installing from the net installer always install build 1643.
Connect to the MetaQuotes demo server.  Regards.
To add comments, please log in or register