OPEN-SOURCE SCRIPT

Trend Counter [theEccentricTrader]

업데이트됨
█  OVERVIEW


This indicator counts the number of confirmed trend scenarios on any given candlestick chart and displays the statistics in a table, which can be repositioned and resized at the user's discretion.


█  CONCEPTS


Green and Red Candles

• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.

Swing Highs and Swing Lows

• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.

Peak and Trough Prices (Basic)

• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.

Upper Trends

• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.

Lower Trends

• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.

Muti-Part Upper and Lower Trends

• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend.


█  FEATURES


Inputs

Start Date
End Date
Position
Text Size
Show Sample Period

Table

The table is colour coded, consists of seven columns and, as many as, forty-one rows. Blue cells denote the multi-part trend scenarios, green cells denote the corresponding return line uptrend and uptrend scenarios and red cells denote the corresponding downtrend and return line downtrend scenarios.

The trend scenarios are listed in the first column with their corresponding total counts to the right, in the second and fifth columns. The last row in column one, displays the sample period which can be adjusted or hidden via indicator settings.

The third and sixth columns display the trend scenarios as percentage of total 1-part trends. And columns four and seven display the total trend scenarios as percentages of the, last, or preceding trend part. For example 4-part trends as a percentages of 3-part trends. This offers more insight into what might happen next at any given point in time.

Plots

For a visual aid to this indicator please use in conjunction with my Return Line Uptrends, Downtrends, Uptrends and Return Line Downtrends indicators which can all be found on my profile page under scripts, or in community scripts under the same names. Unfortunately, I could not fit all the plots with the correct offsets into one script so I had to make a separate indicator for each trend type. I decided against labels as this would limit the visual data points to 500.

Green up-arrows, with the number of the trend part, denote return line uptrends and uptrends. Red down-arrows, with the number of the trend part, denote downtrends and return line downtrends.


█  HOW TO USE


This is intended for research purposes, strategy development and strategy optimisation. I hope it will be useful in helping to gain a better understanding of the underlying dynamics at play on any given market and timeframe.

It can, for example, give you an idea of whether the current trend will continue or fail, based on the current trend scenario and what has happened in the past under similar circumstances. Such information can be very useful when conducting top down analysis across multiple timeframes and making strategic decisions.

What you do with these statistics and how far you decide to take your research is entirely up to you, the possibilities are endless.


█  LIMITATIONS


Some higher timeframe candles on tickers with larger lookbacks such as the DXY , do not actually contain all the open, high, low and close (OHLC) data at the beginning of the chart. Instead, they use the close price for open, high and low prices. So, while we can determine whether the close price is higher or lower than the preceding close price, there is no way of knowing what actually happened intra-bar for these candles. And by default candles that close at the same price as the open price, will be counted as green. You can avoid this problem by utilising the sample period filter.

The green and red candle calculations are based solely on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with. Alternatively, you can replace the scenarios with your own logic to account for the gap anomalies, if you are feeling up to the challenge.

It is also worth noting that the sample size will be limited to your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000. If upgrading is currently not an option, you can always keep a rolling tally of the statistics in an excel spreadsheet or something of the like.
릴리즈 노트
Added group titles to inputs.
릴리즈 노트
Incorporated library functions and general TLC.
Chart patternsstatisticsTrend Analysis

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항