TradingView
TradingView
31 de Mai de 2022 15:51

Polarity Divergences 

EUR/USDOANDA

Descrição

█  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:
Chart TF ​LTF < 1D 1min < 1W 30min >= 1W 1D




█  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.

Notas de Lançamento

v2

Added option to plot a character above or below the bar on divergences.
Comentários
Bjorgum
Thanks to TV and the Pine team for the steady developments and this great example of the new `request.security_lower_tf()` function. Great description and a practical use case!
Ankit_1618
Thanks for posting
MonoCoinSignal
Thanks TV!
Options360
Smart idea
zezezaza
interesting idea.
ochenmorris56
Thanks for posting
tyler8910
Very nice. Is there a way to change the threshold sensitivity to something greater than 51%? Too many divergences are showing up for me, making the signals cluttered. If I could set it to, say, 65%, this would likely decrease the signals and make it much more useful. Thanks!
Linktind
Great idea!
Can anyone help me changing the way how bar polarity is presented. Ideally it would be that the bar is not changing color but instead a shape (triangle, arrow, circle, etc.) is presented below/above the bar.

Thanks!
PineCoders
@Linktind, Hi! Please see the new version of the indicator for these changes! Thank you for your suggestions and support 💚
Linktind
@PineCoders, appreciate!
Mais