­[e2] Setup

Sequentials Phase 1

Setup. Establish the Trend
 This is the first phase of a 2 indicator set. This indicator includes Setup, Support and Resistance lines (also known as TDST), Risk levels and some additions that are described below. Sequential Countdown is not included and will be part of the second script.

Part 1. The Price flip

 The “Price Flip” occurs if the market’s price momentum is weak. It compares the current bar’s close with the close n bars earlier and then shifts the inverted comparison with m bars in the past.
The weak momentum identifies when the comparison’s reading crosses.
The “Bullish price flip” occurs when the current bar’s close price is higher than the close price four bars earlier and the prior bar’s close is lower than the close five price bars earlier.
That could be written in Pine as:
 close > close[4] and close[1] < close[4+1] 
The number 4 represents the “Price Flip Lookback Period”. The number 1 is a “Price Flip Shift”.

The “Bearish price flip” (and the consecutive “Buy Setup”) requirements are inverted and won’t be described further.

The classic reading of the indicator suggests to compare the close price to the close price four (Price Flip Lookback Period) bars earlier.
That can be changed in the script’s options. Sources are defined as Source1 (current bar) and Source2 (n bars earlier). With the adjustable Lookback Period and Price Flip Shift, the script allows to build custom Setup Initialization Points (Price flip occurrence).
When the Setup initialization Point is established we can continue to the next step:

Part 2. Setup Count

 Setup is a time-based technique to identify market trends. When the initialization point (Price Flip prerequisite) is found, the system measures the momentum by comparing the close price with the close n (Setup Lookback Period) price bars earlier and counts consecutive occurrences. Sources are defined in inputs as Source1 (current bar) and Source2 (n bars earlier).
The Sell Setup starts when the Bullish Price Flip occurs.
  • If the consecutive bars’ close price is higher than the close price four bars earlier, the count increases by one.
 The count continues until the Setup Count Limit (point of exhaustion, by default: 9) and stops the count if the consecutive occurrence requirement is broken.
Number 9 represents the “Setup Count Limit” (or just “Count Limit", if we are not in the “Sequential Countdown” scope) and is adjustable in the script’s inputs.
When the exhaustion point is met, the script allows you to decide what to do next:

  • Start the new Setup count in the same direction. This option will allow the script to calculate Double and Triple consecutive Setups.
  • Continue the count. The setup count will continue until a price flip in the opposite direction occurs.
  • Stop the count and wait for the Price Flip occurrence for the new Setup Initialization.
When the Setup Count reaches the Count Limit, the script will evaluate the established Setup and check for a Setup's "Perfection", "Intersection" and "Double" or "Triple" Setup occurrences.

Part 3. Setup Analysis

The Sell Setup Perfection :
  • The Count limit bar’s high price is higher than the high price two and three bars earlier.
  • The high price of a bar prior to Count limit bar is higher than the high price one and two bars earlier.
If the Count Limit is set to 9 the Setup Perfection could be defined as::
  • Bar number 9's high price is higher than the high price of bar numbers 6 and 7 for the Count Limit Perfection.
  • Bar number 8's high price is higher than the high price of bar numbers 6 and 7 for the prior to Count Limit bar Setup Perfection.

The Sell Setup Intersection :
  • The Count limit bar’s low price is lower than the high price three or more (up to Setup Start bar) bars earlier.
If the Count Limit is set to 9 the Setup Intersection could be defined as:
  • Bar number 8 or 9's low price is lower than the high price of bars number 6, 5, 4, 3, 2, 1.

The Setup Risk Lines :
The script looks for the highest bar of the Sell setup and adds the True Range of that bar to it to calculate the Risk Level.
Setup risk line is often used as a stop-loss from the counter-trend entry on the Setup occurrence. Another technique is to place counter-trend bids at that level to catch stop hunts, instead of taking a position right after the setup (or add to your position).

The Double and Triple Setup :
Double and Triple Setup occurs when 2 and 3 consecutive Setups are formed without a price flip between the occurrences.
This usually indicates a strong trend likely to pullback to the reload zone and continue with the Sequentials phase 2 - Countdown.
The script will print "D" or "T" letters above/below bar.

The Setup Reload Zone and Setup Extension :
The Reload Zone measures the distance between the first Setup Bar and the Risk Line, and divides it using Fibonacci Retracement logic, which suggests an entry into the market between the 0.618 and 0.764 levels. The entry is canceled if price breaks the Trend Support/Resistance (TSDT) line.
The Extension Zone takes the same distance into account and suggests exiting positions opened in the Reload Zone, using the 1.618 and 2.618 Fibonacci levels.

The DeMark Indicators® are a collection of registered trademarks protected by U.S. trademark law. They all belong to Market Studies, LCC .
This study makes no commercial use of the trademarks. This script is for educational use and the implementation of DeMark Indicators© concepts (such as TD Setup, TDST, TD Countdown, TD Sequential) is based on my interpretation from the books “The New Science of Technical Analysis” and “DeMark on Day-Trading Options” by Tom Demark .

Special thanks to:
@LucF, for sharing his wisdom, limitless help and efforts with the code and leading my intentions to open-source this script.
@scarf and @allanster, for helping with final cuts before this publication goes public.
And unlimited amount of Pine open-source publishers, that helped me to understand how the pine works.
リリースノート: quickfix
リリースノート: ___VERSION 1.5

》 Stealth Setup.
Stealth Setup occurs when:
1) Market closed at the price flip and new setup count started
2) During that candle the opposite direction count limit was reached but didn't sustained (closed more/less then 4(by default) bars earlier).

If turned on in the options ("Show Stealth Setup"):
- Stealth Setup is marked with "S" char.
- Trend Support/Resistance are calculated from that setup, as it was completed.
- Draw a regular Setup rectangle with dashed lines.
- Statistics count it as a regular completed Setup.

》 Statistics improvement.
- Statistics could be hidden in the tooltips from the script's options. Just hover the mouse.
- Count number of Setups in a row.
- Convert number of bars into Weeks/Days/Hours/Minutes format. (Credits to Kodify - https://kodify.net/tradingview/date-time...)
- Statistics offset function and label redraw method updated (Credits to LucF and midtownsk8rguy)

》Other updates.
- Double and Triple Trend calculation bug fixed.
- Code refactored ( PineScript Coding Conventions )
- Setup bug with the Continuous count fixed.
- Setup location could be changed from the script's options (Separately for Buy and Sell Setup)
リリースノート: Fixed bugs:
- 10001 candle
- Intraday barsToDate calculation
お気に入りスクリプトから削除 お気に入りスクリプトに追加
Pisces swimming through the river
All their life against the stream
Searching for a hook to catch on
And see their sun beam
Then suffocate in painful tortures
On cutting tables of callous men
Under a knife of handsome butchers
Emeralds are ripped away


This is magnificent!
+5 返信
@scarf, indeed, thx for helping ;)
Thank you for all that you do! Looking forward to giving this one a go.
+3 返信
@BMoom, Feel free to ask if you have any questions ;)
This is really an amazing piece of work. Thanks for including notes. I look forward to your further work with DeMark indicators. The Sequential Countdown will be really helpful. Thank you!
+2 返信
e2e4mfck GeraldM
@GeraldM, Thx, the second phase - countdown is a great tool indeed, some day I will definitely publish it on TradingView ;)
+1 返信
In the beginning I like to thank you
I hope you explain in a simple way how to trade through this indicator.
  I mean, for example, when do I buy, in what condition, and also when do I sell
And thank you again
+2 返信
e2e4mfck CryptoMoood
@CryptoMoood, This indicator is a trend measurement tool and its depends on your strategy when you enter the market. Are you trying to counter the trend or you are trying to follow it?
I will write a few notes about it somewhere in the future. Meanwhile I suggest to read the Tom Demark's books that I mentioned in the disclaimer.
CryptoMoood e2e4mfck
@e2e4mfck, Thx ;)
+1 返信
GeraldM CryptoMoood
@CryptoMoood, Jason Pearl's book is also a good source.
+1 返信
ホーム 株式スクリーナー FXスクリーナー 仮想通貨スクリーナー 経済指標カレンダー 使い方 チャート機能 価格 友達紹介 ハウスルール ヘルプセンター ウェブサイト&ブローカー向けソリューション ウィジェット チャートソリューション 軽量チャートライブラリ ブログ&ニュース ツイッター
プロフィール プロフィール設定 アカウントとお支払い 友達紹介 コイン マイサポートチケット ヘルプセンター 公開したアイデア フォロワー フォロー中 プライベートメッセージ チャット サインアウト