@TracerBullet
I think project is setup. Can you give me some lead now?
Edit - Arrays in C++ are quite similar to AmiBroker arrays. (AB was written in C++).
1. You are already creating two arrays. 1. Previous 2. Current
Yes, it maintains O/H/L/C of each scrip. So its one row per scrip
2. In Worker::amibrokerPoller()..... // Shared data access start, you fill the current array with data received from RTD Server.
Worker:oll() waits for message from callback. When it gets one, we call NEST RTD - RefreshData() - to get changed data and update current/previous.
Worker::amibrokerPoller() asynchronously reads this data ( Using Timer whose frequency we set in ini ) and sends it to amibroker if current is different from previous.
Once done, we copy current to previous and reset current to empty to get new O/H/L/C for future reads
3. You manipulate the Current array O H L C V and OI vis a vis Previous array. Use only Volume_Today of Previous for Volume calculation and ltt to skip quotes of same time (second).
If ltt is same we wait for more data. This is to prevent overwrite of bars.
We use almost all fields in previous actually because we compare the two.
((*_current) == (*_prev)) . Here, == will call Worker::ScripState:perator== ( operator overloading ).
4. Copy Current Array to Previous.
5. Reset Current
6. Send Current to CSV.
is that correct?
Where hove you defined -- topic_id_to_scrip_field_map.at( topic_id
)
yes.
topic_id_to_scrip_field_map is just a map of Topic ids for each field.
In RTD, Each combination of Scrip and field has an integer topic id that we decide and pass to Server. In future, all reference to that field is through this ID.
This is set in constructor - Worker::Worker().
We can also do this every call but i just saved it at start to avoid cpu usage.
RTD RefreshData() gives us topic id and its value. We use the map to resolve topic id into Scrip and Field.
We use field position in current/previous as base multiplier and each field is set based on its position in SCRIP_FIELDS ( In worker.h ).
Ex If we have two Scrips A and B in first and second position, then topics 0 to 3 are reserved for Scrip A and topics 4 to 7 are reserved for B.
If we get topic = 6, then it means Scrip id is 6 / 4 = 1 (= B) and field id is 6 % 4 = 2 ( = SCRIP_FIELDS::VOLUME_TODAY )
Its simple , just put some couts if you have doubt.