I'd like to know how you convert these data series Data, Time, and Price to OHLC or Open, High, Low, Close.
I am working on a bitcoin project and would like to see these data as a candlestick chart. I have seen some threads here in stockoverflow regarding the computation but I don't understand the script they were using "create an OHLC series from ticker data using R" I am referring to "Kevin"'s answer
Providing a partial data here
Date, strTime, dblTime, Price, Volume,SideVolume
2014-06-04,17:00:00.027,0.708333645833333,192575,1,1
2014-06-04,17:00:00.090,0.708334375,192575,1,1
2014-06-04,17:00:00.178,0.708335393518519,192550,1,-1
2014-06-04,17:00:01.019,0.708345127314815,192575,1,1
2014-06-04,17:00:01.021,0.708345150462963,192575,1,1
2014-06-04,17:00:01.037,0.708345335648148,192575,3,3
2014-06-04,17:00:01.037,0.708345335648148,192575,3,3
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,10,10
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,10,10
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.038,0.708345347222222,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,2,2
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192575,1,1
2014-06-04,17:00:01.039,0.708345358796296,192600,15,15
how do you compute these data for OHLC using C#? I am using SciChart by the way for candlestick chart.
regards .
You have the data "tick by tick" you have one line per trade. To create the Open, Low, High, Close, you need to create a logic that process each tick.
for each tick: - If is the first tick of the day, "open" price" = price, low = price, high = price. The close price of the previous day equals the last price. - If not first tick of the day, update low if the price is smaller than low. - If not first tick of the day, update high if the high price is greater than high.
Also, is a good idea to accumulate "Volume" for each day. It's a very important indicator, since if you have a big difference o prices with almost no volume, is a signal of possible market manipulation.
In technical terms, it's just CSV parsing and simple logic. If you have trouble with the logic, please, let me know. I'm suposing that your problem is to understand the market logic, not the C# logic.
来源:https://stackoverflow.com/questions/24780823/create-an-ohlc-data-from-date-time-price-using-c-sharp