GetSeries different Last Values Close and Open - help, is this expected?
GetSeries different Last Values Close and Open - help, is this expected?
06 Feb 2017, 01:00
Hi
I am trying to get the close values for different timeFrames.
So for example if my Robot runs at 10 min bars as the set timeframe for the robot.
MarketSeries _series1 = MarketData.GetSeries(TimeFrame.Hour); Print("TimeFrame {0}, Value: {1}", _series1.TimeFrame, _series1.Open.LastValue);
Logs:
as you can see this is what I was expecting and is correect for "series.Open.LastValue", i.e the value only changes on the hour for the
"TimeFrame.Hour - MarketSeries":
01/10/2015 23:20:01.901 | TimeFrame: Hour, Value: 0.7394 01/10/2015 23:10:10.962 | TimeFrame: Hour, Value: 0.7394 01/10/2015 23:00:00.581 | TimeFrame: Hour, Value: 0.7394 01/10/2015 22:50:02.962 | TimeFrame: Hour, Value: 0.73922
But if I now change this to "series.Close.LastValue" - using a different time sample in the logs:
MarketSeries _series1 = MarketData.GetSeries(TimeFrame.Hour); Print("TimeFrame: {0}, CloseValue: {1}", _series1.TimeFrame, _series1.Close.LastValue);
Logs - whish I am not expecting to have different prices for each 10 min bar for a 1Hour timeframe:
01/09/2015 16:30:00.037 | TimeFrame: Hour, CloseValue: 0.73563 01/09/2015 16:20:00.299 | TimeFrame: Hour, CloseValue: 0.73527 01/09/2015 16:10:00.242 | TimeFrame: Hour, CloseValue: 0.73446 01/09/2015 16:00:00.000 | TimeFrame: Hour, CloseValue: 0.73427
As you can see in the last set of logs those prices when verified using the visual graph are actually the close prices for the 10 min bars!
Is this a bug - or am I missing something?
Any help would be awesome - thanks.
BeardPower
07 Feb 2017, 00:43
It's not a bug
Hi,
No, this is not a bug, it's just how the actual bar on a higher timeframe is formed.
The open price is the same throughout the hour, because it will not change, but all others will.
Whithin 1 hour, there are 6 ten-minute bars created, which all form an hour-bar. While the ten-minute bars are forming, the close price of the one-hour bar is not finished yet, but every close of each ten-minute bar happens before the closing of an hour-bar. That's why you see the close price of the ten-minute bars after the open of an hour bar.
See /api/reference/dataseries/lastvalue
You need to reference the index of the bar relatively to the current bar of your one-hour MarketSeries.
See /api/reference/internals/marketseries
Replacing MarketSeries.<> with _series1.<> will give you the last prices of one-hour bar.
@BeardPower