Jeka

Created at 19 Aug 2017, 17:36
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!
SL

slodder04

Joined 19.08.2017

Jeka
19 Aug 2017, 17:36


Good afternoon!
I need data on candles (opening, closing, high and low) for backtesting. What method or function should I use to get this data for testing the robot. Thanks in advance.


@slodder04
Replies

Spotware
21 Aug 2017, 10:28

Dear slodder04,

Thanks for posting your question in the forum. Open, Close, High and Low prices can be obtained as DataSeries in a cBot as follows.

        protected override void OnBar()
        {
            var open = MarketSeries.Open;
            var close = MarketSeries.Close;
            var high = MarketSeries.High;
            var low = MarketSeries.Low;
        }

Let us know if this is what you need.

Best Regards,

cTrader Team


@Spotware

slodder04
26 Aug 2017, 11:13

Thanks for the answer. I will do.
Another question:
I wrote the indicator. How to make it visible in the code of the robot.
Thankful in advance, Eugene.


@slodder04

slodder04
26 Aug 2017, 17:50

I got data on the candle with the index 0.
How do you know which index the last candle has, how do you address it?

 

http://prntscr.com/gdalsx


@slodder04

Spotware
27 Aug 2017, 12:41

Dear slodder04,

Check here how access an indicator from a cBot.

Regarding the index of the candle, the last candle has index 0. See following code sample on how to get the last High value from MarketSeries

var lastHighValue =  MarketSeries.High.Last(0);

Best Regards,

cTrader Team


@Spotware