rSign of ZigZag indicator flipped

Posted By: Morris

rSign of ZigZag indicator flipped - 06/13/20 16:21

This might also be a documentation issue -- either way, it appears to me that the rSign variable generated by ZigZag() has the wrong sign. From the online manual for ZigZag():

Quote
Returned: rSlope (the slope of the last identified line; upwards lines have a positive slope, downwards lines a negative slope); rPeak (the bar offset of the last identified peak); rSign (1 if the last peak was a top, -1 if the last peak was a bottom); rLength (the number of bars of the last zig or zag that ends with rPeak)


Unless I misinterpret this, rSlope and rSign should always have the same sign; however, they have opposite signs (in Zorro S 2.25), and rSign appears to contain -1 for a prior top, and 1 for a prior peak. rSlope appears correct. I assume this could be fixed by changing either the documentation (for backwards compatibility) or the implementation...
Posted By: jcl

Re: rSign of ZigZag indicator flipped - 06/15/20 14:17

I would interpret it so that rSlope and rSign have a different sign. If the last peak was a top, then rSign is 1, and rSlope is negative because the slope goes downwards from a top.
Posted By: Morris

Re: rSign of ZigZag indicator flipped - 06/15/20 17:52

Well, I understand one could interpret it that way -- only, that's not what rSign actually does :-)

Code
void run()
{
    StartDate = 2016;
    EndDate = 2016;
    BarPeriod = 1440;

    ZigZag(series(price()), 150*PIP, 1, DARKGREEN);
    plot("rSign", rSign, NEW, RED);
}


Yields the attached result. It appears that as soon as rSign recognizes that a new leg is being formed, it assumes -1 for a prior top and 1 for a prior bottom (as seen by the length of the legs in the image, and by the last value for rSign)...

In any case. Not a big deal, one just has to be aware of it either way.

Attached picture EURUSD-ZigZag.png
Posted By: jcl

Re: rSign of ZigZag indicator flipped - 06/17/20 09:28

Ok, we'll check what rSign really does and will make the documentation more clear.
Posted By: Morris

Re: rSign of ZigZag indicator flipped - 06/17/20 16:33

Thank you! smile
© 2024 lite-C Forums