There's already a command that will build live bars for you: Streaming Intervals Bars (BW). Connect to port 9400 and send BW,Symbol,Interval in Seconds,Begin Date/Begin Time. This will give you history up to the current moment, then new incoming ticks as they happen.
http://www.iqfeed.net/dev/api/docs//Derivatives_StreamingIntervalBars_TCPIP.cfm goes into more detail.
If you want to build them yourself, there are a few considerations:
1. IQFeed only uses Last-Eligible and Extended ticks to build bars, ignoring Other. The Message Contents field in each ticks will tell you which it is.
2. Volume willl not consistently match the sum of all ticks. This is because Volume can include transactions that aren't ticks, like stock options and implied trades.
3. Make sure you know the difference between "Last" "Most Recent" and "Extended":
- “Last” includes only last -eligible trades.
- “Most Recent” includes all trades.
- “Extended” includes on extended trades (also call Form T or after hours trades).
You would have to consider both "Last" and "Extended" data to re-create bars as IQFeed builds them.
4. You can get tick data on premarket session, but you must be watching the "Extended" fields. "Last" includes only last-eligible trades, which do not occur outside of regular trading hours. These distinctions apply to the fields listed in
http://www.iqfeed.net/dev/api/docs/Level1UpdateSummaryMessage.cfm. You can view the one(s) you need.
I hope this is all helpful!
Sincerely,
Gary Stephen
DTN IQFeed Implementation Support Specialist