SequenceCounter

Description

The Sequence Counter study searches for Formation patterns with subsequent Array pattern occurrence. The Buy Formation pattern occurs when there is a sequence of bars each having the Close price less than that four bars ago. The Sell Formation pattern occurs when there is a sequence of bars each having the Close price greater than that four bars ago. Once a Formation pattern is recognized, the bars are given numbers from 1 to 9 by default (the number of bars can be defined according to your preferences by the formation period input).

After the Formation pattern has occurred, the study starts seeking an Array pattern. The latter might occur after an Intersection condition is fulfilled. For a Buy Formation pattern, that condition is existence of a bar having the High price greater than or equal to the Low three or more bars ago (but not earlier than the beginning of the Formation pattern). Conversely, for a Sell Formation pattern, that condition is existence of a bar having the Low price less than or equal to the High three or more bars ago (but not earlier than the beginning of the Formation pattern).

Once the Intersection condition is fulfilled, it is a signal for seeking an Array pattern. The Array phase begins with the last bar of the Formation (or with the Intersection bar, whichever is later). The Array Buy pattern involves a number of bars (not necessarily successive) each having the Close price not greater than the Low two bars ago. The Array Sell pattern involves a number of bars (not necessarily successive) each having the Close price not less than the High two bars ago. Once the Array pattern is recognized, the bars are given numbers from 1 to 13 by default (the number of bars can be defined according to your preferences by the array period input parameter). Note that the Formation/Array sequence is canceled in case of occurrence and completion of the opposing Formation. Along with that, a new Formation in the same direction is ignored by the study and is not plotted on the chart.

After having found a Formation pattern or a Formation/Array sequence, the study indicates Buy and Sell signals. Those are shown if the sequences meet the so-called Perfection Criteria listed in the following table.

Perfection Criteria

Formation Buy Perfection Criteria Low < Low[2 bars ago] and Low < Low[3 bars ago] or Low[1 bar ago] < Low[2 bars ago] and Low[1 bar ago] < Low[3 bars ago]
Formation Sell Perfection Criteria High > High[2 bars ago] and High > High[3 bars ago] or High[1 bar ago] > High[2 bars ago] and High[1 bar ago] > High[3 bars ago]
Array Buy Perfection Criteria Low <= Close[5 bars ago]
Array Sell Perfection Criteria High >= Close[5 bars ago]

Input Parameters

Parameter Description
array period The number of bars in the Array pattern.
formation period The number of bars in the Formation pattern.

Plots

Plot Description
Buy Formation Consists of "formation period" consecutive bars with: Close < Close[4 bars ago].
Sell Formation Consists of "formation period" consecutive bars with: Close > Close[4 bars ago].
Buy Array Displays "array period" bars satisfying the condition: Close <= Low[2 bars ago]
Sell Array Displays "array period" bars satisfying the condition: Close >= High[2 bars ago]
Perfect Buy Buy signals for Formation patterns meeting perfection criteria.
Perfect Sell Sell signals for Formation patterns meeting perfection criteria.
Perfect Array Buy Buy signals for Array patterns meeting perfection criteria.
Perfect Array Sell Sell signals for Array patterns meeting perfection criteria.

Example*

*For illustrative purposes only. Not a recommendation of a specific security or investment strategy.