Intrabar Polarity Divergences
Jun 1, 2022

The Intrabar Polarity Divergences indicator analyzes lower timeframe data within a single higher timeframe candle to identify discrepancies between the bar's overall color and the directional dominance of its internal sub-bars. This tool helps traders identify potential exhaustion or hidden strength by revealing when the internal momentum of a candle contradicts its external appearance.
Usage
The Usage section focuses on identifying "Polarity Divergences." For example, a daily chart might display a green (bullish) candle, but the intrabar data may reveal that the majority of the lower timeframe bars were actually red (bearish).
- Divergence Identification: When the majority direction of intrabars differs from the close-open direction of the main chart candle, the bar is highlighted with an orange background.
- Percentage Labels: Labels appear above or below the bar showing the percentage of dominance for the opposing direction.
- Absolute Values: If enabled, labels will also display the raw count of positive versus negative intrabars (e.g., 10/14).
- Mid-Bar Price: A blue horizontal line can be plotted to represent the close price of the intrabar located exactly in the middle of the current candle's duration.
Details
The script utilizes the request.security_lower_tf function to fetch the direction (math.sign(close - open)) of every sub-bar within the current timeframe's bar. It calculates the sum of these directions to determine the true internal sentiment. A divergence occurs when the mathematical sign of the sum of intrabar directions is opposite to the sign of the current candle's price movement. This implementation allows for a more granular view of price action without manually switching timeframes.
Settings
- Intrabar time frame: Determines the lower timeframe used for the internal analysis (e.g., looking at 5-minute bars inside a 1-hour candle).
- Show actual positive/negative intrabar values: Toggles the display of the raw count of bullish and bearish sub-bars on the chart labels.
- Show middle day intrabar close price: Enables or disables the blue plot representing the closing price of the median intrabar.
FAQ
How do I interpret an orange bar?
An orange bar indicates a polarity divergence, meaning the majority of the smaller timeframes within that bar moved in the opposite direction of the bar's final close.
Why are there no labels on some bars?
Labels only appear when a divergence is detected. If the internal intrabar momentum matches the external candle direction, no divergence is plotted.
How can I access Intrabar Polarity Divergences?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.