I'm having an issue with data plugin where historical data is loaded and charted OK, but real time data isn't.
The first time GetQuotesEx is called (lastValid = -1, size = 3000) plugin gets all 3000 ticks and stores them into quotes array passed to GetQuotesEx (starting at index 0, incrementing lastValid on the way up to 2999) and displays the chart correctly.
The only thing suspicious I'm noticing at this point is that timestamps displayed on chart are offset by -1 second, so instead of displaying the timestamp obtained from the API (seen in log bellow) "21.3.2018 3:15:00" it instead displays "21.3.2018 3:14:59" (this feels strange already and I don't know why it happens...could be the source of issue?).
Being offset by 1s doesn't bother me that much, but the problem is when AmiBroker requests next (real time) tick...the API returns a correct timestamp (as seen in log bellow) and inserts the quotation into quotes at index 2999 (lastValid: 2998, size: 3000), but for some reason chart doesn't display this last tick (or any new tick from here on)...instead it seems that it only overwrites the last candle charted instead of adding a new one at "21.3.2018 3:29:59".
To elaborate, last 2 candles displayed on chart after 2nd call to GetQuotesEx have timestamps "21.3.2018 2:59:59" (correct) and "21.3.2018 3:00:00" (wrong - latest tick obtained via API has a timestamp "21.3.2018 3:15:00" and should be charted as "21.3.2018 3:14:59"...and I think as a consequence last 2 candles at "21.3.2018 3:14:59" and "21.3.2018 2:29:59" are now missing.
Would anyone know why AmiBroker would behave this way?
Am I filling the quotes wrong?
Is the source of problem timestamps being offset by 1s?
I already tried by starting to fill quotes at index 1 (instead of 0) but that doesn't solve the problem.
Here is the log produced by plugin (all seems OK here):
21.3.2018 4:23:43: periodicity: FifteenMinutes, lastValid: -1, size: 3000, lastDateTime:1.1.1970 0:00:00
21.3.2018 4:23:43: 3000 ticks of data requested (async)...
21.3.2018 4:23:43: 0: 17.2.2018 21:30:00,10776,10824,10776,10817,211.5846
21.3.2018 4:23:43: 1: 17.2.2018 21:45:00,10817,10825,10799.55,10808,206.3401
...
21.3.2018 4:24:12: 2998: 21.3.2018 3:00:00,8938.2,8960,8928.8,8938.3,228.258
21.3.2018 4:24:12: 2999: 21.3.2018 3:15:00,8936.5,8957.3,8920.6,8947,247.9846
21.3.2018 4:24:12: Downloaded next 1000 tick(s) (3000/3000 imported).
21.3.2018 4:24:12: periodicity: FifteenMinutes, lastValid: -1, size: 3000, lastDateTime:1.1.1970 0:00:00
21.3.2018 4:24:12: Imported 3000/3000 tick(s). Last valid quote at index 2999.
21.3.2018 4:30:01: periodicity: FifteenMinutes, lastValid: 2998, size: 3000, lastDateTime:21.3.2018 3:00:00
21.3.2018 4:30:01: 1 ticks of data requested (sync)...
21.3.2018 4:30:01: 0: 21.3.2018 3:30:00,8957.3,8959.7,8954.4,8957,2.355983
21.3.2018 4:30:01: Downloaded next 1 tick(s) (1/1 imported).
21.3.2018 4:30:01: Imported 1/1 tick(s). Last valid quote at index 2999.
Btw, I'm using a separate thread (async) to obtain ticks if there are many (+ notifying AmiBroker main window via SendMessage) and for getting 1 tick I obtain the data inside UI thread (that's why GetQuotesEx is called 2x when obtaining historical data - seen in log above).