Stocks & Commodities V. 24:11 (36-44): Sidebar: Algorithm for the Swing Indicator by Giorgos E. Siligardos, Ph.D.
The Pascal-like pseudolanguage here consists of two parts and gives the basic steps to construct the swing indicator (SI) using parameter threshold %. We consider the closing price of a trading vehicle an array of N values: CLOSE, CLOSE, ……CLOSE[N].
The first part of the code constructs the PIVOT array (PIVOT,PIVOT, ….PIVOT[N]), which carries information about the peaks and troughs of the SI by assigning “1” to cases where a swing high or low has occurred and zero otherwise.
The second part of the code constructs the SI array ( SI, SI, …SI[N] ) by getting the information from the PIVOT array and connecting the pivots using line segments.