Can't obtain the correct values for Open, Close, Low & High from MarketSeries
Can't obtain the correct values for Open, Close, Low & High from MarketSeries
03 Dec 2017, 22:40
When I try to get the values for Open, Close, Low & High values from MarketSeries I allways get the same value for all, look my sample code.
protected override void OnBar() { base.OnBar(); Print("MarketSeries.TimeFrame: {0} | MarketSeries.Open: {1} | MarketSeries.Close: {2} | MarketSeries.Low: {3} | MarketSeries.High: {4}", MarketSeries.OpenTime.LastValue.ToString(), MarketSeries.Open.LastValue, MarketSeries.Close.LastValue, MarketSeries.Low.LastValue, MarketSeries.High.LastValue); }
A sample result:
12/11/2017 18:01:00.322 | MarketSeries.TimeFrame: 13/11/2017 12:01:00 a. m. | MarketSeries.Open: 1275.5 | MarketSeries.Close: 1275.5 | MarketSeries.Low: 1275.5 | MarketSeries.High: 1275.5
12/11/2017 18:02:00.199 | MarketSeries.TimeFrame: 13/11/2017 12:02:00 a. m. | MarketSeries.Open: 1275.57 | MarketSeries.Close: 1275.57 | MarketSeries.Low: 1275.57 | MarketSeries.High: 1275.57
12/11/2017 18:03:00.386 | MarketSeries.TimeFrame: 13/11/2017 12:03:00 a. m. | MarketSeries.Open: 1275.32 | MarketSeries.Close: 1275.32 | MarketSeries.Low: 1275.32 | MarketSeries.High: 1275.32
I tested with diferent symbols and time frames
Am I doing something wrong?
Regards
Replies
yuri_paez@hotmail.com
08 Dec 2017, 06:14
RE: RE:
Hi Andrey,
Thank you very much. This solve my problem.
Best Regards
Yuri Paez
Andrey Pisarev said:
Hi,
When OnBar is called, you have a new bar as last one. This Bar has only one tick in it, so Open, High, Low, Close are the same. If you want to get data of closed bar, you need to get previous bar:
Print("MarketSeries.TimeFrame: {0} | MarketSeries.Open: {1} | MarketSeries.Close: {2} | MarketSeries.Low: {3} | MarketSeries.High: {4}", MarketSeries.OpenTime.Last(1).ToString(), MarketSeries.Open.Last(1), MarketSeries.Close.Last(1), MarketSeries.Low.Last(1), MarketSeries.High.Last(1));Best Regards,
Andrey
yuri_paez@hotmail.com said:
When I try to get the values for Open, Close, Low & High values from MarketSeries I allways get the same value for all, look my sample code.
protected override void OnBar() { base.OnBar(); Print("MarketSeries.TimeFrame: {0} | MarketSeries.Open: {1} | MarketSeries.Close: {2} | MarketSeries.Low: {3} | MarketSeries.High: {4}", MarketSeries.OpenTime.LastValue.ToString(), MarketSeries.Open.LastValue, MarketSeries.Close.LastValue, MarketSeries.Low.LastValue, MarketSeries.High.LastValue); }
A sample result:
12/11/2017 18:01:00.322 | MarketSeries.TimeFrame: 13/11/2017 12:01:00 a. m. | MarketSeries.Open: 1275.5 | MarketSeries.Close: 1275.5 | MarketSeries.Low: 1275.5 | MarketSeries.High: 1275.5
12/11/2017 18:02:00.199 | MarketSeries.TimeFrame: 13/11/2017 12:02:00 a. m. | MarketSeries.Open: 1275.57 | MarketSeries.Close: 1275.57 | MarketSeries.Low: 1275.57 | MarketSeries.High: 1275.57
12/11/2017 18:03:00.386 | MarketSeries.TimeFrame: 13/11/2017 12:03:00 a. m. | MarketSeries.Open: 1275.32 | MarketSeries.Close: 1275.32 | MarketSeries.Low: 1275.32 | MarketSeries.High: 1275.32I tested with diferent symbols and time frames
Am I doing something wrong?
Regards
@yuri_paez@hotmail.com
ap11
04 Dec 2017, 10:39
RE:
Hi,
When OnBar is called, you have a new bar as last one. This Bar has only one tick in it, so Open, High, Low, Close are the same. If you want to get data of closed bar, you need to get previous bar:
Best Regards,
Andrey
yuri_paez@hotmail.com said:
@ap11