# Swing

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

Based on the strength of the swing highs or the swing lows, the swing indicator draws a line at these points. The number of bars to the left and right of the extreme point is the determining factor for the strength. Methods for these indicators can also be implemented for other scripts.

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

The methods for these indicators can be used in scripts to determine the last extreme point and its corresponding price value. The highs and lows of these points may then be used as entry, stop or target markers.

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

```csharp
//For a high
Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod);
Swing(IDataSeries inSeries, int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod);

//For a low
Swing(int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod);
Swing(IDataSeries inSeries, int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod);
```

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

**double**

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

**When the current bar is smaller than the parameter strength, or if no swing high/low has been found, the return value is -1.**

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

|                |                                                                                                              |
| -------------- | ------------------------------------------------------------------------------------------------------------ |
| barsAgo        | Starting point for the search                                                                                |
| InSeries       | Input data series for the indicator                                                                          |
| instance       | The number of occurrences of extreme points (1 is the last occurrence, 2 is the second last occurrence etc.) |
| length         | Number of bars included in the calculation                                                                   |
| lookBackPeriod | Number of bars in the past in which swing points will be searched for (search area)                          |
| strength       | Number of bars to the left and right of the extreme points                                                   |

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

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

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

```csharp
// Position and price of the last swing high
int barsAgo = Swing(5).SwingHighBar(0, 1, 10);
Print("The last swing high was " + barsAgo + " bars ago.");
Print("The last swing high was at " + High[barsAgo]);
```


---

# 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/swing.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.
