# ZigZag

#### Description <a href="#description_148" id="description_148"></a>

The ZigZag indicator searched for extreme points in different timeframes. It finds the extreme points by using threshold values that traders themselves define. These specified threshold values determine the extent to which the market direction needs to change before the ZigZag line alters its orientation and forms a further extreme point.

#### Interpretation <a href="#interpretation_65" id="interpretation_65"></a>

The previous extreme values (local highs or lows) are ideally suited for either entries or stop targets.

**Caution:** The ZigZag is not an indicator in the common sense. Position and direction of the zigzag can change retrospectively (repainting indicator).

#### Further information <a href="#further-information_49" id="further-information_49"></a>

<http://www.robotrading.de/indikatoren/zig-zag-indikator-zeigt-hoch-und-tief-punkte-im-forex-markt>

#### Usage <a href="#usage_133" id="usage_133"></a>

```csharp
//For the upper extreme value
ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagHigh[int barsAgo]
ZigZag(IDataSeries inSeries, DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagHigh[int barsAgo]

//For the lower extreme value
ZigZag(DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagLow[int barsAgo]
ZigZag(IDataSeries inSeries, DeviationType deviationType, double deviationValue, bool useHighLow).ZigZagLow[int barsAgo]
```

#### Return value <a href="#return-value_131" id="return-value_131"></a>

**double**

When using this method with an index (e.g. **ZigZag**(...)\[**int** barsAgo] ), the value of the indicator will be issued for the referenced bar.

A return value of 0 indicates that no high or low point has been found yet.

#### Parameters <a href="#parameters_121" id="parameters_121"></a>

|                                                |                                                                                                                    |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| inSeries                                       | Input data series for the indicator                                                                                |
| deviationType                                  | The change in points or percent                                                                                    |
| DeviationType.Points and DeviationType.Percent |                                                                                                                    |
| deviationValue                                 | Value of the deviation                                                                                             |
| useHighLow                                     | Defines whether the high/low of a bar will be used for extreme values or if you want to use closing prices instead |

#### Visualization <a href="#visualization_136" id="visualization_136"></a>

![ZigZag](https://agenatrader.github.io/AgenaIndicator-documentation/media/ZigZag.jpg)

#### Example <a href="#example_127" id="example_127"></a>

```csharp
//Output of the market value for the last high point
Print("The last high of the ZigZag indicator was at " + ZigZag(DeviationType.Percent, 1, true).ZigZagHigh[0]);

// Output of the market value for the last low point
Print("The last low of the ZigZag indicator was at " + ZigZag(DeviationType.Percent, 1, true).ZigZagLow[0]);
```

[ Previous](https://agenatrader.github.io/AgenaIndicator-documentation/data/)<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://indicators.agenatrader.com/standard-indicators/zigzag.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
