@ Josh1
tick is just a value.
ideally it does not have OHLC to it.
so like i said if we plot plotohlc(c,c,c,c------); all afls will work properly which r based on H and L values. and no problem will be faced in migrating from tick to other time frames.
I'm big zero in programming except AFL.
so i have one question and suggestion to get better chances of pulling the ticks from now.
Question : How is the logic of pulling values is done?
i hope it based on change in LTP and capturing tht change after some certain period.
Suggestion : in real ticks u may find lots of ticks identical. so ltp remains the same over the period but u may miss the volumes by the method u r applying for pulling.
wht i suggest is keep the current logic and just try with
(change in LTp ) OR (change in total traded volume)
this will decrease the probability of missing ticks.
change in LTP is always recorded as LTT thus if we take LTQ as base for volume, then even if LTP remain same with different LTQ the trades will always reflect in LTT. so taking each tick of LTT and recording the LTP/LTQ /bid price/ask price of that moment will give the exact and correct picture.
Currently, I am maintaining two arrays (Current and Previous ) of scrips read from settings.ini for storing and aggregating ticks . Both have a Push Flag in addition to data. Each new tick is first stored in Newdata structure. Flow is as below.
/********************************************************************************************************************
Data from RTD server comes in pairs of Topic_id and field_id. We have topic _id as row numbers of scrips
from settings.ini. Whereas field_ids are columns. We have enumerated these field_id in worker.h as
LTT=0, VOLUME_TODAY=1, OI=2,LTP=3. Fortunately RTD Server sends data of each topic_id together and also in
order of their ENUM. Hence data pairs come sequentially in the order LTT=0, VOLUME_TODAY=1, OI=2,LTP=3
Index does not have any field other than LTP. Equity will not have OI. However every scrip will have LTP.
Therefore LTP is kept last at no.3
Once LTP is received, bar for that scrip is completed and it can be written to current bar.
*********************************************************************************************************************/
1. A Quote is complete when LTP is received. (I don't remember why I did not keep the condition as change of topic_ID. I shall see that next week.)
(LTT is received in the format HH:MM:ss from RTD server. It is truncated to HH:MM if bar period is 60000)
2. Each newdata.LTT is not same as Current LTT and
a. Current.Push =1 then entire Current quote is copied to Previous quote , newdata quote is copied to Current quote and Current Push is set to 1.
b. If Current.Push =0 then Current.ltt and Current.vol_today is copied to Previous
LTP, Vol_today and OI are copied to Current. Volume = Current.vol_today - Previous.vol_today.
3. If newdata.LTT = Current.LTT then LTP, Vol_today and OI are copied to Current. Volume = Current.vol_today - Previous.vol_today. H and L are changed if LTP is higher or lower. and Current Push is set to 1
There is a second thread that does the work of pushing data to csv file and call Amibroker to import it. This is done every second.
1. It will send Previous quote to csv if Previous.Push =1 and set it to 0(zero).
2. Thereafter, it will send Current quote to csv if Current.Push =1 and set it to 0(zero).
I am getting 99.9% accuracy with this logic. When there is high activity on exchange, RTD server hangs for few seconds but thereafter disburses data in bursts. I am getting H and L and Volume correct though a bit late in that case. If I backfill all scrips at EOD, I do not see any difference in charts. Therefore I stopped doing backfill at EOD. (Loveenajyoti also confirmed that)
Last week I changed the code slightly to add LTQ instead of using Volume Traded Today. This I shall test next week and if successful, I shall reduce bar period.
Old code is available from my signature. I did not upload it on git since TB had removed his code from there and I had no energy left after learning C++