Access on numbers of Indicators.StochasticOscillator

Created at 08 Nov 2017, 00:11
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!
MT

mto1995

Joined 19.10.2017

Access on numbers of Indicators.StochasticOscillator
08 Nov 2017, 00:11


Hello,

I would like make some operation on    Indicators.StochasticOscillator put i cant have access on the number  a.PercentK

 

 

protected override void OnTick()
        {
            var a = Indicators.StochasticOscillator(9, 3, 9, MovingAverageType.Simple);
           
            if (
 a.PercentK <= 80)
            {
               // close position
            }

        }

 

Thanks for your help


@mto1995
Replies

PanagiotisCharalampous
08 Nov 2017, 10:20

Hi mto1995,

PercentK is a DataSeries so it is not a single value but a collection. So you need to define which value you want to access. See below an example on how to get the last value of the DataSeries

        protected override void OnTick()
        {
            var a = Indicators.StochasticOscillator(9, 3, 9, MovingAverageType.Simple);

            if (a.PercentK.Last() <= 80)
            {
                // close position
            }
        }

Best Regards,

Panagiotis


@PanagiotisCharalampous