OPEN-SOURCE SCRIPT

Polarity Divergences

업데이트됨
█  OVERVIEW


This indicator looks at the polarity of the intrabars composing a chart bar and fills chart candles orange when a majority of intrabars does not have the same polarity as that of the chart bar.



█  CONCEPTS


Bar polarity

By [I]bar polarity, we mean the direction of a bar, which is determined by looking at the bar's close vs its open.


Intrabars

[I]Intrabars are chart bars at a lower timeframe than the chart's. Each 1H chart bar of a 24x7 market will, for example, usually contain 60 bars at the lower timeframe of 1min, provided there was market activity during each minute of the hour. Mining information from intrabars can be useful in that it offers traders visibility on the activity inside a chart bar.


Lower timeframes (LTFs)

A [I]lower timeframe is a timeframe that is smaller than the chart's timeframe. This script determines which ​LTF to use by examining the chart's timeframe. The ​LTF determines how many intrabars are examined for each chart bar; the lower the timeframe, the more intrabars are analyzed. This table shows which ​LTF is used for each range of chart timeframes:




█  HOW TO USE IT


The idea underlying this indicator is that if the polarity of a chart bar is up or down, the majority of its constituent intrabars should also be up or down. If that is not the case, then we can consider the bar to be abnormal, and so worthy of our attention. You will notice that such anomalies often occur before reversals, but irregularities do not necessarily announce reversals, as they also occur on pauses in trends or in trend-less conditions.

The indicator will update in real time, as intrabars composing the realtime chart bar are gradually built. The closer the realtime bar is to being closed, the more reliable the result will be, as that is when the indicator can analyze the most intrabars.



█  NOTES FOR Pine Script™ CODERS


This script uses the recently released request.security_lower_tf() Pine Script™ function discussed in this blog post. It works differently from the usual request.security() in that it can only be used at LTFs, and it returns an array containing one value per intrabar. This makes it much easier for programmers to access intrabar information.

A script can access a maximum of 100K intrabars; that is the reason we step the ​LTF by taking into account the chart's timeframe. By progressively increasing the ​LTF as the chart's timeframe increases, we provide users with optimal coverage of the chart bars. Always using a 1min ​LTF would, for example, limit the chart coverage to the last 69 bars on a 1D chart of a 24x7 market because each chart bar will usually contain 1440 intrabars (100K / 1440 = 69.4). By using a 30min ​LTF for 1D charts, we cover 100K / 48 = 2083 bars.



Look first. Then leap.

릴리즈 노트
v2

Added option to plot a character above or below the bar on divergences.
Candlestick analysis

오픈 소스 스크립트

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

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


Share TradingView with a friend:
tradingview.com/share-your-love/

Read more about the new tools and features we're building for you: tradingview.com/blog/en/
또한 다음에서도:

면책사항