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/
更多:

免责声明