OPEN-SOURCE SCRIPT

Drawdown Range

ที่อัปเดต:
Hello death eaters, presenting a unique script which can be used for fundamental analysis or mean reversion based trades.

Process of deriving this table is as below:

  • Find out ATH for given day
  • Calculate the drawdown from ATH for the day and drawdown percentage
  • Based on the drawdown percentage, increment the count of basket which is based on input iNumber of ranges. For example, if number of ranges is 5, then there will be 5 baskets. First basket will fit drawdown percentage 0-20% and each subsequent ones will accommodate next 20% range.
  • Repeat the process from start to last bar. Once done, table will plot how much percentage of days belong to which basket.


For example, from the below chart of AAPL
สแนปชอต

We can deduce following,
  • Historically stock has traded within 1% drawdown from ATH for 6.59% of time. This is the max amount of time stock has stayed in specific range of drawdown from ATH.
  • Stock has traded at the drawdown range of 82-83% from ATH for 0.17% of time. This is the least amount of time the stock has stayed in specific range of drawdown from ATH.
  • At present, stock is trading 2-3% below ATH and this has happened for about 2.46% of total days in trade
  • Maximum drawdown the stock has suffered is 83%


Lets take another example of TSLA
สแนปชอต

Stock is trading at 21-22% below ATH. But, historically the max drawdown range where stock has traded is within 0-1%. Now, if we make this range to show 20 divisions instead of 100, it will look something like this:
สแนปชอต

Table suggests that stock is trading about 20-25% below ATH - which is right. But, table also suggests that stock has spent most number of days within this drawdown range when we divide it by 20 baskets instad of 100. I would probably wait for price to break out of this range before going long or short. At present, it seems a stage ranging stage. I might think about selling PUTs or covered CALLs outside this range.

Similarly, if you look at SPY, 36% of the time, price has stayed within 5% from ATH - makes it a compelling bull case!!
สแนปชอต

BABA is trading at 50-55% below ATH - which is the most it has retraced so far. In general, it is used to be within 15-20% from ATH
สแนปชอต

NOW, Bit of explanation on input options.

Number of Ranges : Says how many baskets the drawdown map needs to be divided into.
Reference : You can take ATH as reference or chose a time window between which the highest need to be considered for drawdown. This can be useful for megacaps which has gone beyond initial phase of uncertainity. There is no point looking at 80% drawdown AAPL had during 1990s. More approriate to look at it post 2000s where it started making higher impact and growth.
Cumulative Percentage : When this is unchecked, percentage division shows 0-nth percentage instad of percentage ranges. For example this is how it looks on SPY:
สแนปชอต

We can see that SPY has remained within 6% from ATH for more than 50% of the time.

Hope this is helpful. Happy trading :)

PS: this can be used in conjunction with Drawdown-Price-vs-Fundamentals to pick value stocks at discounted price while also keeping an eye on range tendencies of it.

Thanks to mattX5 for the ideas and discussion today :)
เอกสารเผยแพร่
  • Default number of ranges set to 20
  • changed Cumulative to Percentile
  • Added start and end date of the range calculation


Another screenshot comparing indexes
สแนปชอต
เอกสารเผยแพร่
Added tickerid to table for easy identification
เอกสารเผยแพร่
Fixed intermittent array index out of bounds issue
เอกสารเผยแพร่
Convert to pine5
เอกสารเผยแพร่
Fixed runtime issue
เอกสารเผยแพร่
Fix issue related to old logger library.
drawdownfundamental-analysisTrend Analysis

สคริปต์โอเพนซอร์ซ

ด้วยเจตนารมณ์หลักของ TradingView ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถเข้าใจและตรวจสอบได้ ต้องขอบคุณผู้เขียน! ที่ให้คุณใช้ได้ฟรี แต่การนำโค้ดนี้ไปใช้ในการเผยแพร่ซ้ำจะต้องอยู่ภายใต้ กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?

คำจำกัดสิทธิ์ความรับผิดชอบ