Login Page - Create Account

Technical Studies Reference


Swing High and Low

This study calculates and displays Swing Highs and Swing Lows for the Price Data. These Swings are indicated by placing an arrow above the chart bar for a Swing High and below the bar for a Swing Low.

Let \(H_t\) and \(L_t\) be the High and Low Prices, respectively, at Index \(t\). Let the Inputs Arrow Offset as Percentage and Length Inputs be denoted as \(k\) and \(n\), respectively. Then we denote the Swing High and Swing Low functions at Index \(t\) as \(SH_t(n)\) and \(SL_t(n)\), respectively.

If the Input Allow Equal High/Low Bars is set to No, then we compute the Swing High and Swing Low functions as follows.

\(\displaystyle{SH_t(n) = \left\{ \begin{matrix} 0 & H_t \leq \max\{H_{t - n}, H_{t - n + 1}, ... , H_{t - 1}\} \space or \space H_t \leq \max\{H_{t + 1}, H_{t + 2}, ... , H_{t + n}\} \\ 1 & H_t > \max\{H_{t - n}, H_{t - n + 1}, ... , H_{t - 1}\} \space and \space H_t > \max\{H_{t + 1}, H_{t + 2}, ... , H_{t + n}\} \end{matrix}\right .}\)

\(\displaystyle{SL_t(n) = \left\{ \begin{matrix} 0 & L_t \geq \min\{L_{t - n}, L_{t - n + 1}, ... , L_{t - 1}\} \space or \space L_t \geq \min\{L_{t + 1}, L_{t + 2}, ... , L_{t + n}\} \\ 1 & L_t < \min\{L_{t - n}, L_{t - n + 1}, ... , L_{t - 1}\} \space and \space L_t < \min\{L_{t + 1}, L_{t + 2}, ... , L_{t + n}\} \end{matrix}\right .}\)

If the Input Allow Equal High/Low Bars is set to Yes, then the calculations are modified as follows.

\(\displaystyle{SH_t(n) = \left\{ \begin{matrix} 0 & H_t < \max\{H_{t - n}, H_{t - n + 1}, ... , H_{t - 1}\} \space or \space H_t < \max\{H_{t + 1}, H_{t + 2}, ... , H_{t + n}\} \\ 1 & H_t \geq \max\{H_{t - n}, H_{t - n + 1}, ... , H_{t - 1}\} \space and \space H_t \geq \max\{H_{t + 1}, H_{t + 2}, ... , H_{t + n}\} \end{matrix}\right .}\)

\(\displaystyle{SL_t(n) = \left\{ \begin{matrix} 0 & L_t > \min\{L_{t - n}, L_{t - n + 1}, ... , L_{t - 1}\} \space or \space L_t > \min\{L_{t + 1}, L_{t + 2}, ... , L_{t + n}\} \\ 1 & L_t \leq \min\{L_{t - n}, L_{t - n + 1}, ... , L_{t - 1}\} \space and \space L_t \leq \min\{L_{t + 1}, L_{t + 2}, ... , L_{t + n}\} \end{matrix}\right .}\)

Regardless of the setting of the Allow Equal High/Low Bars Input, the Swing High and Swing Low Subgraphs are determined for \(t \geq 2n\) by \(SH_{t - n}(n)\) and \(SL_{t - n}\), respectively, as follows.

  • If \(SH_{t - n}(n) = 1\), then a downward arrow is placed above the bar with Index \(t - n\) at a vertical position given by \(H_{t - n} + (H_{t - n} - L_{t - n})\cdot\frac{k}{100}\).
  • If \(SL_{t - n}(n) = 1\), then an upward arrow is placed below the bar with Index \(t - n\) at a vertical position given by \(L_{t - n} - (H_{t - n} - L_{t - n})\cdot\frac{k}{100}\).

No arrows are drawn if \(SH_{t - n}(n) = 0\) or \(SL_{t - n}(n) = 0\).

This study has a dependency upon the Price Display Format / Value Format for the main price graph in the in the chart for it to work properly. Therefore, the setting must be correct. The Price Display Format is set through Chart >> Chart Settings.

In the case where a study is set to display as the main price graph, then you need to adjust the Value Format for that study and this is set through the Study Settings window for that study.

A Swing High or Swing Low will never be identified on the last bar in the chart because it is not possible to determine that. Also, the most recent Swing High or Swing Low could change as the latest bar in the chart changes.

The Swing High and Low study is very sensitive to the Chart >> Chart Settings >> Price Display Format setting and you need to set that correctly relative to the data in the chart. It is best to leave it at the default setting. Otherwise, the study will give inaccurate results. For example, for currencies typically this setting is .00001. You should use that setting and not decrease this.

If the Input Extend Swings Until Future Intersection is set to Yes, then from every bar at which a Swing High or Swing Low is detected, a line will extend from that Swing High or Swing Low until it intersects with future price bars. The Line Properties Subgraph sets the color, style and with of that line. When this Input is set to No, these line extensions are not drawn.

Inputs

  • Arrow Offset as Percentage: This specifies the offset as a percentage of the range of a bar that the arrows should be placed away from the High or Low of a bar.
  • Length
  • Allow Equal High/Low Bars: When this Input is set to Yes, then the bars on either side of a bar can have an equal High or Low for the pattern to be considered a Swing High or Low.
  • Extend Swings Until Future Intersection: A custom Input that determines whether horizontal lines are drawn from Swing Highs or Swing Lows to future bars.

Spreadsheet

The spreadsheet below contains the formulas for this study in Spreadsheet format. Save this Spreadsheet to the Data Files Folder.

Open it through File >> Open Spreadsheet.

Swing_High_and_Low.242.scss


*Last modified Monday, 03rd October, 2022.