Zig Formula around ZERO values

Hi everyone.
I have written some zig code with a Timeframe Expand, from daily data. I'm having issues when looking at the zig in a 2hr timeframe. The problems arises when the formula is AT ZERO or perhaps crossing ZERO. The zig seems to create little zigs around this area, where is should be smooth. This doesn't happen all the time.
I have had to use ABS formula with zig when the indicator has negative values, and this is part of the issue around this zero area.
So in summary, I'm trying to create smooth zigs through the Zero line.
Thanks so much for any help on this.
Kevin.

ZIG problem

TimeFrameSet(inDaily);
SIGNALzig = Zig(Signal(12,26,9),1);
SIGNALzig1=IIf(SIGNALzig>0,SIGNALzig,Zig(abs(SIGNALzig),1)*-1);
TimeFrameRestore();

SIGNALzigEXPAND= TimeFrameExpand(SIGNALzig,inDaily,expandFirst);
koko= Zig(SIGNALzigEXPAND,1);
koko1 = IIf(koko>0,koko,Zig(abs(koko),1)*-1);

SIGNALzigdaily = TimeFrameExpand(SIGNALzig1,inDaily,expandFirst);

Plot(SIGNALzigdaily,"blue", colorBlue,0,0,0,0,0,3 );
Plot( koko1,"", colorRed,0,0,0,1,3 );type or paste code here

Zig should only be used for positive inputs. This is so because ZIG uses Percent change and when input approaches zero percent change can swing to infinity.

Would it then be possible to add a large number to the data being analyzed, apply zigzag to it, then subtract the same large number from the resultant zigzag values?

1 Like