Join the 80,000 other DTN customers who enjoy the fastest, most reliable data available. There is no better value than DTN!

(Move your cursor to this area to pause scrolling)




"Excellent datafeed !!!" - Comment from Arely
"DTN has never given me problems. It is incredibly stable. In fact I've occasionally lost the data feed from Interactive Brokers, but still been able to trade because I'm getting good data from DTN." - Comment from Leighton
"I used to have *******, but they are way more money for the same thing. I have had no probs with data from DTN since switching over." - Comment from Public Forum Post
"I am enjoying the feed very much - so superior to the broker provided feed I was previously using." - Comment from George
"I have been using IQFeed now for a few years in MultiCharts and I have zero complaints. Very, very rare to have any data hiccups or anything at all go wrong." - Comment from Public Forum
"I like you guys better than *******...much more stable and a whole lot fewer issues." - Comment from Philip
"IQFeed version 4 is a real screamer compared to anything else I have seen." - Comment from Tom
"I've never had DTN go out on me since switching. ******* would go down a couple times every month when I was using them." - Comment from Bryce in AL.
"I would just like to say that IQFeed version 4 is running very well and I am very happy with its performance. I would also like to extend a big thanks for the fast and efficient help that I always receive. My questions and concerns are always addressed promptly. Way to go!" - Comment from Josh in CO.
"Thanks for the great product and support. During this week of high volume trading, my QuoteTracker + IQ Feed setup never missed a beat. Also, thanks for your swiftness in responding to data issues. I was on ******* for a few years before I made the switch over early this year, and wish I had done it a long time ago." - Comment from Ken
Home  Search  Register  Login  Recent Posts

Information on DTN's Industries:
DTN Oil & Gas | DTN Trading | DTN Agriculture | DTN Weather
Follow DTNMarkets on Twitter
DTN.IQ/IQFeed on Twitter
DTN News and Analysis on Twitter
»Forums Index »IQFeed Developer »IQFeed Developer Support »Framing update messages by 5 min candles
Author Topic: Framing update messages by 5 min candles (8 messages, Page 1 of 1)

askarali
-Interested User-
Posts: 5
Joined: Aug 23, 2021


Posted: Aug 23, 2021 05:45 PM          Msg. 1 of 8
Hello!

I have a question about update messages.
To form 5 min candles from update messages, what time stamp should be used?
Most recent time or time stamp in T messages?

Thanks.

stargrazer
-DTN Guru-
Posts: 276
Joined: Jun 13, 2005

Right Here & Now


Posted: Aug 23, 2021 06:26 PM          Msg. 2 of 8
Neither?

You need to identify when your candle ends. All trades prior to and including that time are included in the candle. When the next update comes in greater than the end time, emit the candle (with the pre-calculated timestamp) and start the next. Note that sometimes a candle is not emitted if there were no trades within that timeframe.

askarali
-Interested User-
Posts: 5
Joined: Aug 23, 2021


Posted: Aug 23, 2021 07:06 PM          Msg. 3 of 8
Thank you for your reply.

What I would like to do is to create candles synced with other software, e.g. Lightspeed Trader, Webull, Tradingview, etc.
To create the timeframes, would it be good to use local time in EST time-zone?
And I will use the "Most Recent Trade Time" field to include the updates to a timeframe.
Correct?

askarali
-Interested User-
Posts: 5
Joined: Aug 23, 2021


Posted: Aug 23, 2021 11:17 PM          Msg. 4 of 8
I think it doesn't make sense what computer time (EST, EDT, UTC, etc) to use.
I just need to create time-frames first and include the updates in them.
But I will use the timestamp of the update messages for this.
Correct?

askarali
-Interested User-
Posts: 5
Joined: Aug 23, 2021


Posted: Aug 24, 2021 07:57 PM          Msg. 5 of 8
Do the questions not have any sense?

stargrazer
-DTN Guru-
Posts: 276
Joined: Jun 13, 2005

Right Here & Now


Posted: Aug 24, 2021 09:23 PM          Msg. 6 of 8
You can do pretty much anything you want.

You probably want to study market data to see how others select bar start/intervals.

Here is one example of bar building:

https://github.com/rburkholder/trade-frame/blob/master/lib/TFTimeSeries/BarFactory.h
https://github.com/rburkholder/trade-frame/blob/master/lib/TFTimeSeries/BarFactory.cpp

askarali
-Interested User-
Posts: 5
Joined: Aug 23, 2021


Posted: Aug 24, 2021 10:52 PM          Msg. 7 of 8
OK. I am using similar logic.
But there are fields “Last” and “Most Recent Trade” for price.
Which one can be used as a close price?
Note: for a new candle, this will be an open price.

DTN_Gary_Stephen
-DTN Evangelist-
Posts: 210
Joined: Jul 3, 2019


Posted: Aug 25, 2021 03:14 PM          Msg. 8 of 8
Hello Askrali, I have answers for your questions:

Quote: what time stamp should be used?
Most recent time or time stamp in T messages?


The "T" messages are provided by the IQFeed server. The timestamps messages within each tick are provided by the change, and they reflect the time the tick actually happened. For example:

T,20210825 10:49:43
Q,MSFT,301.7400,10,10:49:42.839858,19,5676548,301.7400,300,301.7600,200,304.3000,304.5900,301.1200,302.6200,ba,87,
Q,MSFT,301.7400,10,10:49:42.839858,19,5676548,301.7400,300,301.7600,100,304.3000,304.5900,301.1200,302.6200,ba,87,

These ticks occurred at 10:49:42.839858, but were not sent out as API messages until after the local server time was 10:49:43. Ticks take some time to travel through the internet, and the synchronization may not be exact.

You probably want to use the timestamps in the tick messages, because these reflect the actual time the tick occurred.

Quote: To form 5 min candles from update message


By the way, yhe IQFeed API has a command that will build 5-minute intervals for you. You can connect to port 9400 and send a command like:

BW,TSLA,300,20210825 090000

300 is the number of seconds in the bar, so 5 minutes. This will give you historical bars as far back as you specify, and will built live ones for you. The response will be like:

BH,TSLA,2021-08-25 09:05:00,706.9800,707.2000,706.9800,707.2000,75526,1792,0,
BH,TSLA,2021-08-25 09:10:00,707.0100,707.5000,707.0100,707.0500,78801,1480,0,
BH,TSLA,2021-08-25 09:15:00,707.1500,707.5100,707.1500,707.2500,83120,2551,0,
...etc...
BC,TSLA,2021-08-25 11:25:00,709.8100,710.3944,709.2500,709.9600,5425296,41704,,
BC,TSLA,2021-08-25 11:30:00,709.9900,710.7500,709.7500,710.5000,5487078,38044,,

"BH" means the message was built from historical data, while "BC" means the message was built from live data. "BU" means a past bar has been updated.

Quote: To create the timeframes, would it be good to use local time in EST time-zone?


All IQFeed timestamps for all exchanges use the US Eastern time zone. This includes exchanges that are not based in that time zone.

Quote: But there are fields “Last” and “Most Recent Trade” for price.
Which one can be used as a close price?


The difference between the "Last" and "Most Recent Trade" fields is this: "Last" includes only "last-eligible" trades. This means trades for more than 100 units. Such trades are allowed to set a high, low, open, or close.

"Most Recent" includes non-eligible trades. They may be for less than 100 units. Such trades cannot set an official high, low, open, or close. If the current High is $8.00 and I buy 99 units for $8.01, the High does not change to $8.01.

You can whichever of the two you want, just understand the difference. If your close price you calculate must match the offical close price, then use Last. If you want to calculate your own close price, and you want it to include all trades, use Most Recent. By the way, these are two different fields in Level 1 and you can watch both of them.



Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist

Edited by DTN_Gary_Stephen on Aug 25, 2021 at 04:43 PM
 

 

Time: Thu September 16, 2021 6:22 AM CFBB v1.2.0 16 ms.
© AderSoftware 2002-2003