ERROR: OCHL values the same value.

Created at 31 Jan 2014, 01:38
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
RA

raygalla

Joined 21.08.2013

ERROR: OCHL values the same value.
31 Jan 2014, 01:38


Hi,

I was testing my robot on calgo and noticed that the OCHL values are the same value on each bar. Can you look into this please.

I created a new basic robot with just the print commands for Market series data to confirm and I got the same results. Also this error is happening on all Pairs.

Thank You for a great product, I am really enjoying using it.

Code Below:

         protected override void OnBar()
        {
            // Put your core logic here
            //getCandleStickPattern(0);
            var close = MarketSeries.Close.LastValue;
            var high = MarketSeries.High.LastValue;
            var low = MarketSeries.Low.LastValue;

            Print("Current close {0}, high {1}, low {2}", close, high, low);



        }

 

OCHL price the same


@raygalla
Replies

Spotware
31 Jan 2014, 09:02

OnBar event happens when new bar is opened. At that moment MarketSeries collection already contains tick from new bar. It means that last bar is not formed and in general cases open = high = low = close. If you want to access to last formed bar you need take previous one.

You need to change your code:

 protected override void OnBar()
        {
            // Put your core logic here
            //getCandleStickPattern(0);
            var close = MarketSeries.Close.Last(1);
            var high = MarketSeries.High.Last(1);
            var low = MarketSeries.Low.Last(1);

            Print("Current close {0}, high {1}, low {2}", close, high, low);
        }

 


@Spotware

raygalla
31 Jan 2014, 10:26

Thank you for the very quick reply.

I have implemented the change and it is working perfect.

Again thank you and keep up the good work.

 


@raygalla