ZigZag Indicator Slope ?

 

Hello I'm trying to find a way to calculate zizag indicator slope

 So far I was able to do so only in visual mode using ChartTimePriceToXY function

But need solution that can work without visual mode 

 
kkjawz:

Hello I'm trying to find a way to calculate zizag indicator slope

 So far I was able to do so only in visual mode using ChartTimePriceToXY function

But need solution that can work without visual mode 

If I understand the question correctly:

m = (y2-y1) / (x2-x1)

where:

y1,y2 - price

x1,x2 - time    

You can use the value of iCustom for the y values. Then, for the x coordinates, you can use the bar representation you used for the shift on iCustom. For example:

double y1 = iCustom(NULL,0,"ZigZag",0,1); //using default parameters, shift = 1
double y2 = iCustom(NULL,0,"ZigZag",0,5); //using default parameters, shift = 5

double slope = (y2-y1) / (5-1);

You may also use datetime for the x-coordinates, but using the shift looks easier and more understandable. The slope may vary though in case the span of the zigzag you want to calculate involves several legs.

Reason: