Zig zag with price change per leg

Hi folks, I'd like to find a basic Zig plot with the number of points gained/lost in each leg plotted on the price chart. eg. zig +25 points, zag -12 points, and so on.

I'm sure someone here has a template similar to this. If you could share it that would be much appreciated. Thanks.

I think this is what you want.

field = ParamField( "Price field" );
change = Param( "% change", 5, 0.1, 25, 0.1 );
zigArray = Zig( field, change );
zigHi = zigArray > Ref( zigArray, -1 ) AND zigArray > Ref( zigArray, 1 );
zigLo = zigArray < Ref( zigArray, -1 ) AND zigArray < Ref( zigArray, 1 );
zigHiPrice = ValueWhen( zigHi, C );
zigLoPrice = ValueWhen( zigLo, C );
zigDelta = IIf( zigLo, zigLoPrice - zigHiPrice, IIf( zigHi, zigHiPrice - zigLoPrice, Null ) );
Plot( zigDelta, "ZIG Delta" + _PARAM_VALUES(), IIf( zigDelta < 0, colorRed, colorLime ), styleHistogram | styleThick );
2 Likes