Traderji.com - Discussion forum for Stocks Commodities & Forex

How to convert tick data into Candlestick chart

Discuss How to convert tick data into Candlestick chart at the Development of Software Utilities within the Traderji.com - Discussion forum for Stocks Commodities & Forex; Dear friends, I am writing a personal application extracting NSE data from Yahoo website to ...


Go Back   Traderji.com - Discussion forum for Stocks Commodities & Forex > TOOLS & RESOURCES > Development of Software Utilities


Development of Software Utilities Discuss the development of software tools and utilities here.


Advertise Here

Reply
 
Thread Tools
  #1  
Old 17th February 2009, 10:21 PM
Member
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 16 Times in 10 Posts
kesk is on a distinguished road
Default How to convert tick data into Candlestick chart


Dear friends,

I am writing a personal application extracting NSE data from Yahoo website to be used as a Intraday quote application. I have added database functionality and a line chart feature function. So far this works. If people are interested, i am willing to share the application with others.

I also need some help: How to convert the tick data to OHLC values for a 1 min chart ? I am doing the program in vb.net. Any ideas/suggestion would be greatly appreciated. If you need to contact me personally means, pls use this id : kesk32 at yahoo co in

Thanks

kesk
Reply With Quote
Sponsored Links
  #2  
Old 19th February 2009, 02:01 PM
Member
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 16 Times in 10 Posts
kesk is on a distinguished road
Default Re: How to convert tick data into Candlestick chart

Would updating the data with tick data every 5 sec and then deciding the O,H,L,C values from a 1 min query and populating the database work ?

Any ideas?

kesk
Reply With Quote
  #3  
Old 19th February 2009, 03:35 PM
rajendrani's Avatar
Member
 
Join Date: Sep 2008
Location: Pune
Posts: 1,057
Thanks: 1,474
Thanked 1,624 Times in 598 Posts
rajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant future
Default Re: How to convert tick data into Candlestick chart

Quote:
Originally Posted by kesk View Post
Dear friends,

I am writing a personal application extracting NSE data from Yahoo website to be used as a Intraday quote application. I have added database functionality and a line chart feature function. So far this works. If people are interested, i am willing to share the application with others.

I also need some help: How to convert the tick data to OHLC values for a 1 min chart ? I am doing the program in vb.net. Any ideas/suggestion would be greatly appreciated. If you need to contact me personally means, pls use this id : kesk32 at yahoo co in

Thanks

kesk
Buddy, I guess when you have line chart function which uses only the close price or the ltp, for candlestick you also need to have the open, high, low values also, so just getting those values also will serve the purpose, then instead on line chart you can have a candlestick chart.

This would be of great help for you
http://67.220.225.70/~gumm5981/downl...ock-prices.htm
Reply With Quote
  #4  
Old 19th February 2009, 03:39 PM
rajendrani's Avatar
Member
 
Join Date: Sep 2008
Location: Pune
Posts: 1,057
Thanks: 1,474
Thanked 1,624 Times in 598 Posts
rajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant futurerajendrani has a brilliant future
Default Re: How to convert tick data into Candlestick chart

Play around with the excel file and you will be able to get what you really want to

otherwise just go to

http://67.220.225.70/~gumm5981/INVESTING-7.htm

or just
http://www.gummy-stuff.org/ for a wealth of information.

thanks and regards,
rajendrani
Reply With Quote
  #5  
Old 19th February 2009, 05:36 PM
Member
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 16 Times in 10 Posts
kesk is on a distinguished road
Default Re: How to convert tick data into Candlestick chart

Hi Mr Rajendrani,

Thanks for the info. The Open, High, Low and Close values that any page displays is the day's OHLC. If you use that, then almost all the candles will look similar as the O, H and L will remain mostly constant.

The quote or tick values in a minute period should be converted to OHLC values, thats what my question is all about. How to manage that, either in memory or in a database?

senthil
Reply With Quote
  #6  
Old 14th August 2009, 11:51 PM
Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Redeemer is on a distinguished road
Lightbulb Re: How to convert tick data into Candlestick chart

Hello Kesk,

Is your charting real time? And are you using a full fleged database? or a file based one like BerkelyDB or Access?

If it is real time, them do the ohlc calculations in memory. Cause you are drawing as you get the data, so no point writing to the DB.

If it isnt real time (as in, drawing the days chart at the end of the day) then either approach will do. The in memory approach might actually be more efficient, since not a lot of DB io/network access is happening (especially if not a file based DB)

Since you have 5 sec tick, so 60/5 == 12 data points.

So you data structure will need to be an aggregator, that accepts values one at a time, updates its internal strucutre (setting O, H, L, C values) and when it hits 12, you can write it to the DB or display it, and clear the structure for the new set.

Hope this Helps
Reply With Quote
  #7  
Old 15th August 2009, 09:38 AM
Member
 
Join Date: Jul 2008
Posts: 24
Thanks: 1
Thanked 16 Times in 10 Posts
kesk is on a distinguished road
Default Re: How to convert tick data into Candlestick chart

Hi Reedeemer,

Thanks for your reply. I am not a full time programmer or programmer in the real sense, just a hobby programmer, so you can understand my shortcomings.

I am very good at database both in Access and SQL server and somewhat familiar with vb.Net. Hence i went ahead and wrote the program in Access and vb.Net. The program is real time, fetches data from Yahoo. The line drawing is Ok so far. Since candlesticks might give a better understanding of the prevailing market, I decided to incorporate that also, and thats where my limitation kicks in.

To my understanding, if we can store the values in a db all the intraday values, it might come in handy for looking back the resistance and support areas and thats why choose to save them.

Coming to the question of in-memory sorting/storing values for a min, i simply dont understand it. If you can post some kind of code, example, a URL, that would be very helpful to me.

If you are interested in helping me, please PM me or my email is 'kesk32 at yahoo dot co dot in'.

Once again thank you for your reply.
Reply With Quote
  #8  
Old 15th August 2009, 11:36 PM
Member
 
Join Date: Jun 2007
Posts: 219
Thanks: 562
Thanked 94 Times in 56 Posts
terminator_123 will become famous soon enoughterminator_123 will become famous soon enough
Default Re: How to convert tick data into Candlestick chart

Sort tick data by time stamp. Loop through your data checking time stamp. Neglect seconds and keep track of high,low for current minute. At the end of the current minute, the last value wd be the close, first value of the minute becomes open.
For charting use zedgraph graph control (which has inbuilt support for candle sticks).
Reply With Quote
  #9  
Old 16th August 2009, 01:38 PM
Member
 
Join Date: Aug 2009
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
Redeemer is on a distinguished road
Lightbulb Re: How to convert tick data into Candlestick chart

Hello Kesk,

I mostly hang out on programming forums, and would prolly get yelled at there for giving out detailed code (since we mostly prefer to explain stuff and then let a programmer think for himself)
But since this is not a programming forum and I'm bored.... its your lucky day

Code:
--For the DB: 
--(assuming you have made a standard instrument table to store data)
-- Note: DBs arent really my strong points, 
--         so you might actually have a better way of doing this

-- For H and L
SELECT MAX(price), MIN(price) from INSTRUMENT_INTRADAY 
WHERE series='EQ' 
   AND imnt='%SYMBOL%' 
   AND day='%DATE_YOU_WANT%' 
GROUP BY HOUR(day), MINUTE(day) 
ORDER BY HOUR(day), MINUTE(day)

-- For O and C
SELECT price AS "Open", from INSTRUMENT_INTRADAY 
WHERE series='EQ' 
   AND imnt='%SYMBOL%' 
   AND day='%DATE_YOU_WANT%' 
   AND SECOND(day) = MIN(SECOND(day))
GROUP BY HOUR(day), MINUTE(day) 
ORDER BY HOUR(day), MINUTE(day)

SELECT price AS "Close", from INSTRUMENT_INTRADAY 
WHERE series='EQ' 
   AND imnt='%SYMBOL%' 
   AND day='%DATE_YOU_WANT%' 
   AND SECOND(day) = MAX(SECOND(day))
GROUP BY HOUR(day), MINUTE(day) 
ORDER BY HOUR(day), MINUTE(day)
Code:
//For In memory

class Aggregator:
    members:
        float open
        float high = -1
        float low = +Infinity
        float close
        
        int tick

    methods:
        // If this method returns true, 
        // then you get the ohlc from it, and display it
        addTickData price
            if tick == 0
                resetOHLCValues

            periodOver = false
            increment tick

            if tick == 1
                open = price

            if tick % 12 == 0
                close = price
                periodOver = true
                tick = 0

            high = Max(high, price)
            low = Min(low, price)

            return periodOver


Reply With Quote
The Following User Says Thank You to Redeemer For This Useful Post:
terminator_123 (16th August 2009)
Reply

Bookmarks


Advertise Here


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT +5.5. The time now is 01:10 AM.

Indemnity, Disclaimer & Disclosure Notice:
• By visiting Traderji.com you automatically indicate that you agree to our Forum Rules, Indemnity, Disclaimer & Disclosure Notice and General Content Disclaimer Notice and indemnify Traderji.com, its associates and related parties of all claims howsoever resulting from the usage of the forum/site.
Disclaimer: Trading or investing in stocks & commodities is a high risk activity. Any action you choose to take in the markets is totally your own responsibility. You are recommended to make appropriate enquiries and seek appropriate advise before sending money, incurring any expenses, acting on recommendations or entering into any commitment in relation to any advertisement published here. Traderji.com does not vouch for any claims made by the advertisers of products and services. Traderji.com will not be held liable for any consequences in the event such claims are not honoured by the advertisers. Traderji.com will not be liable for any, direct or indirect, consequential or incidental damages or loss arising out of the use of any information by anybody mentioned anywhere on this site.
Disclosure: The information in this forum is neither an offer to sell nor solicitation to buy any of the securities mentioned herein. The writers may or may not be trading in the securities mentioned.
• All names or products mentioned are trademarks or registered trademarks of their respective owners.
General Content Disclaimer Notice:
In light of our policy of encouraging candid, open exchanges of views and the rapid distribution of information originating from many sources, Traderji.com cannot determine the accuracy of information that may be uploaded to the forum. Opinions, advice and all other information expressed by participants in discussions are those of the author. You rely on such information at your own risk. You are urged to seek professional advice for specific, individual situations and not rely solely on advice or opinions given in the discussions. Since Traderji.com is an open and free discussion forum, any comments made by members of this forum in their posts reflect their own views and not of the owner or administrator of Traderji.com. Thus the owner/administrator indemnify themselves of all claims whatsoever and will not be liable or responsible for any members comments/views in this forum Traderji.com. If you find any objectionable or offensive posts made by members of this forum which you would like to bring to our notice for removal then please Contact Us.
 


Copyright © 2001 - 2010, Traderji.com All Rights Reserved.

Recommended Websites - www.TradersEdgeIndia.com - www.TradingPicks.com - www.MasterOfTrading.com