Swing
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.
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.
//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);
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.
| |
barsAgo | The 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 |

Swing
// 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]);