NinjaScript > Language Reference > Indicator Methods >

ZigZag

Print this Topic Previous pageReturn to chapter overviewNext page

Description

The ZigZag indicator highlights trends based on user defined threshold values. You can access methods within this indicator to determine the number of bars ago a zigzag high or low point occured or the current zigzag value.

 

 

Syntax - Bars Ago

High Bar
ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow).HighBar(int barsAgo, int instance, int lookBackPeriod)
ZigZag(IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow).HighBar(int barsAgo, int instance, int lookBackPeriod)
 
Low Bar
ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow).LowBar(int barsAgo, int instance, int lookBackPeriod)
ZigZag(IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow).LowBar(int barsAgo, int instance, int lookBackPeriod)

 

Return Value

An int value representing the number of bars ago. Returns a value of -1 if a swing point is not found within the look back period.

 

 

Syntax - Value

High Value
ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagHigh[int barsAgo]
ZigZag(IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagHigh[int barsAgo]
 
Low Value
ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagLow[int barsAgo]
ZigZag(IDataSeries input, DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagLow[int barsAgo]

 

Return Value

double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.

* A return value of 0 (zero) indicates that a zigzag high or low has not yet formed.

 

 

Parameters

barsAgo

The number of bars ago that serves as the starting bar and works backwards

deviationType

Possible values are:
DeviationType.Points
DeviationType.Percent

deviationValue

The deviation value

input

Indicator source data (?)

instance

The occurrence to check for (1 is the most recent, 2 is the 2nd most recent etc...)

lookBackPeriod

Number of bars to look back to check for the test condition. Test is evaluated on the current bar and the bars in the look back period.

 

 

Examples

// Prints the high price of the most recent zig zag high
Print("The high of the zigzag bar is " + High[Math.Max(0, ZigZag(DeviationType.Points, 0.5, false).HighBar(0, 1, 100)]));

 

 

Source Code

You can view this indicator method source code by selecting the menu Tools > Edit NinjaScript > Indicator within the NinjaTrader Control Center window.