CopyTicks in indicator

 
According to docs, "when called from an indicator, CopyTick() immediately returns all available ticks of a symbol, and will launch synchronization of the tick database, if available data is not enough." 

My question is, how can i check data is sync, if it returns immediately without error and with result>0 ?

I tried  SymbolIsSynchronized(_Symbol) function, but it returns true event if all data gaps have not be filled by trading server yet.

 

Normally SymbolIsSynchronized should work (and worked for me). If you can locate the problem feel free to post a test case for the bug.

Also you probably want to check TerminalInfoInteger(TERMINAL_CONNECTED) before all other checks, and also look at SeriesInfoInteger(_Symbol, _Period, SERIES_SYNCHRONIZED).

 
Stanislav Korotky #:

Normally SymbolIsSynchronized should work (and worked for me). If you can locate the problem feel free to post a test case for the bug.

Also you probably want to check TerminalInfoInteger(TERMINAL_CONNECTED) before all other checks, and also look at SeriesInfoInteger(_Symbol, _Period, SERIES_SYNCHRONIZED).

I tried to also add these checks before copyTicks call, but alway give me true.

The simple test i do is disable network on my pc, wait some minutes, and reconnect. Indicator pass all three checks - TerminalInfoInteger(TERMINAL_CONNECTED) and  SeriesInfoInteger(_Symbol, _Period, SERIES_SYNCHRONIZED) and SymbolIsSynchronized(_Symbol) - call copyTicks using "from time" the time before disconnection, but give me only current tick, skipping the precedent ones... 

onCalculate is called with prev_calculated=0, more than one time, so terminal "signaling" indicator it is filling gaps, but i need to call copyTicks just when history is synch, not before. Is there no way to check this?

 
antony23 #:

I tried to also add these checks before copyTicks call, but alway give me true.

The simple test i do is disable network on my pc, wait some minutes, and reconnect. Indicator pass all three checks - TerminalInfoInteger(TERMINAL_CONNECTED) and  SeriesInfoInteger(_Symbol, _Period, SERIES_SYNCHRONIZED) and SymbolIsSynchronized(_Symbol) - call copyTicks using "from time" the time before disconnection, but give me only current tick, skipping the precedent ones... 

onCalculate is called with prev_calculated=0, more than one time, so terminal "signaling" indicator it is filling gaps, but i need to call copyTicks just when history is synch, not before. Is there no way to check this?

Seems i found the problem, when copyTicks result is greater than 0, we need also check the error code. In fact, i get 2 ticks as result of CopyTicks and error code ERR_HISTORY_TIMEOUT 4403. We have to check both, return value and error code.
 
antony23 #:
Seems i found the problem, when copyTicks result is greater than 0, we need also check the error code. In fact, i get 2 ticks as result of CopyTicks and error code ERR_HISTORY_TIMEOUT 4403. We have to check both, return value and error code.

This is not how it's supposed to work.

From documentation :

Returned value

The number of copied tick or -1 in case of an error.

Documentation on MQL5: Runtime Errors / Constants, Enumerations and Structures
Documentation on MQL5: Runtime Errors / Constants, Enumerations and Structures
  • www.mql5.com
GetLastError() is the function that returns the last error code that is stored in the predefined variable _LastError . This value can be reset to...