ZigZag...

Created at 29 Aug 2016, 20:18
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!
GD

GDPR-24_203122

Joined 02.10.2015 Blocked

ZigZag...
29 Aug 2016, 20:18


Sooo....

I am testing a sort of bot to print out values from a zigzag indicator. 

I get the previous value and the current (in progress) value from the indicator like this: 

 

 ZigZag zigzag;

____________START:_______________________

 zigzag = Indicators.GetIndicator<ZigZag>(28, 5, 3);

_________________________________________

 var lastValue = GetZigZagValue(zigzag.Result, 0);
            var previousValue = GetZigZagValue(zigzag.Result, 1);

_________________________________________

        double GetZigZagValue(DataSeries dataSeries, int indexFromEnd)
        {
            for (var i = MarketSeries.Close.Count - 1; i >= 0; i--)
            {
                if (!double.IsNaN(zigzag.Result[i]))
                {
                    if (indexFromEnd == 0)
                        return zigzag.Result[i];
                    indexFromEnd--;
                }
            }
            return double.NaN;
        }

_____________________________________

Main Question:

How can I get the number of bars between those two points (and for example print them to log)?

And thanks a lot for your answer :)