# Technical Studies Reference

This study calculates and displays Thomas DeMark's Trading the Nines indicator. Buy and Sell Setups consist of a particular 9-bar formation following a price flip. We describe Buy Setups and Sell Setups separately below.

Let $$H_t$$, $$L_t$$, and $$C_t$$ denote the High, Low, and Close Prices, respectively, at Index $$t$$. Let the Text Labels Tick Offset Input and the Tick Size be denoted as $$k$$ and $$s$$, respectively.

A prerequisite for a Buy Setup is a Bearish Price Flip, which occurs when the following two conditions are met.

• The Close of the prior bar is greater than or equal to the Close of the bar 4 bars prior: $$C_{t - 1} \geq C_{t - 5}$$.
• The Close of the current bar is less than the Close of the bar 4 bars prior: $$C_t < C_{t - 4}$$.

If these conditions are met, then this study numbers the bars starting at the completion of the Price Flip, up to 9 bars. If the second condition fails at any bar before the 9-bar formation is completed, then the Buy Setup is cancelled and must begin again with a new Bearish Price Flip.

The bar numbering for the Buy Setup occurs below the chart bars, at a vertical position given by $$L_t - k \cdot s$$. The default color for these numbers is green.

If a 9-bar Buy Setup is completed, then the 9th bar is tested for Buy Setup Perfection. The conditions for Perfection are as follows. If either of these conditions is met, then the Buy Setup is considered to be Perfected.

• $$L_t \leq L_{t - 2}$$ and $$L_t \leq L_{t - 3}$$
• $$L_{t - 1} \leq L_{t - 2}$$ and $$L_{t - 1} \leq L_{t - 3}$$

If a Buy Setup is Perfected, then the numbering for the 9th bar in the formation changes to yellow, by default. If not, then the numbering does not change color.

Note: The last bar in the chart is always excluded from this analysis and will never be numbered. This is due to technical problems with numbering of incomplete bars that are still updating.

Sell Setup:

A prerequisite for a Sell Setup is a Bullish Price Flip, which occurs when the following two conditions are met.

• The Close of the prior bar is less than or equal to the Close of the bar 4 bars prior: $$C_{t - 1} \leq C_{t - 5}$$.
• The Close of the current bar is greater than the Close of the bar 4 bars prior: $$C_t > C_{t - 4}$$.

If these conditions are met, then this study numbers the bars starting at the completion of the Price Flip, up to 9 bars. If the second condition fails at any bar before the 9-bar formation is completed, then the Sell Setup is cancelled and must begin again with a new Bullish Price Flip.

The bar numbering for the Sell Setup occurs above the chart bars, at a vertical position given by $$H_t + k \cdot s$$. The default color for these numbers is green.

If a 9-bar Sell Setup is completed, then the 9th bar is tested for Sell Setup Perfection. The conditions for Perfection are as follows. If either of these conditions is met, then the Sell Setup is considered to be Perfected.

• $$H_t \geq H_{t - 2}$$ and $$H_t \geq H_{t - 3}$$
• $$H_{t - 1} \geq H_{t - 2}$$ and $$H_{t - 1} \geq H_{t - 3}$$

If a Sell Setup is Perfected, then the numbering for the 9th bar in the formation changes to yellow, by default. If not, then the numbering does not change color.

Note: The last bar in the chart is always excluded from this analysis and will never be numbered. This is due to technical problems with numbering of incomplete bars that are still updating.

#### Input

• Text Labels Tick Offset: This Input specifies the offset in ticks of the price of a chart bar, to offset the bar number label below the Low of the chart bar.