NinjaScript > Language Reference > Indicator Methods >

Swing

Print this Topic Previous pageReturn to chapter overviewNext page

Description

The Swing indicator will plot lines that represent the swing points based on the strength (number of bars to the left and right of the swing point) parameter provided. You can access methods within this indicator to determine the number of bars ago a swing point occured or the current swing value.

 

 

Syntax - Bars Ago

High Bar
Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)
Swing(IDataSeries input, int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)
 
Low Bar
Swing(int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod)
Swing(IDataSeries input, int strength).SwingLowBar(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
Swing(int strength).SwingHigh[int barsAgo]
Swing(IDataSeries input, int strength).SwingHigh[int barsAgo]
 
Low Value
Swing(int strength).SwingLow[int barsAgo]
Swing(IDataSeries input, int strength).SwingLow[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) will be returned if the CurrentBar is less than the "strength" value or a swing pivot has not yet been found.

 

 

Parameters

barsAgo

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

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.

strength

The number of required bars to the left and right of the swing point

 

 

Examples

// Prints the high price of the most recent swing high
Print("The high of the swing bar is " + High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 10))]);

 

 

Source Code

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