Retreive Current bar and the previous bar in OnTick

Created at 24 Dec 2013, 16:17
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!
ST

StormeNet

Joined 13.12.2013

Retreive Current bar and the previous bar in OnTick
24 Dec 2013, 16:17


I want to access the current and previous bar high / low using the MarketSeries in OnTick, however, I don't know what to fill for index.

protected override void OnTick()
        {
            MarketSeries.High[???];
        }

Thanks.


@StormeNet
Replies

Spotware
24 Dec 2013, 16:56

You have two ways to access current and previous values.

First way is to use indexes:

MarketSeries.High[MarketSeries.High.Count - 1] - current value
MarketSeries.High[MarketSeries.High.Count - 2] - previous value

Second way is to use Last method of DataSeries class:

MarketSeries.High.Last(0) - current value
MarketSeries.High.Last(1) - previous value

 


@Spotware