OPEN-SOURCE SCRIPT

Directional Bias Aggregator [JOAT]

1 250
Directional Bias Aggregator

Introduction

The Directional Bias Aggregator is a sophisticated multi-timeframe bias scoring system designed to measure and aggregate directional conviction across multiple timeframes. This indicator solves the critical problem of conflicting signals across different timeframes by providing a weighted, systematic approach to bias analysis. Understanding the true directional bias requires looking beyond the current timeframe - professional traders always consider the bigger picture, and this tool brings that institutional approach to your trading.

This indicator is built for traders who understand that trends exist on multiple timeframes simultaneously and that the highest probability trades occur when these timeframes align. Whether you're a day trader needing higher timeframe context, a swing trader confirming trend direction, or a position trader assessing long-term bias, this aggregator provides the comprehensive directional intelligence needed to trade with confidence and clarity.

snapshot

Why This Indicator Exists

Most traders struggle with timeframe analysis - they might see a bullish signal on the 15-minute chart but bearish conditions on the 4-hour, leading to confusion and poor decisions. This indicator addresses that problem by:

  • Multi-Timeframe Analysis: Evaluates bias across up to four timeframes simultaneously
  • Weighted Aggregation: Assigns importance to each timeframe based on trading style
  • Bias Scoring: Provides numerical bias scores (-100 to +100) for objective analysis
  • Alignment Detection: Identifies when multiple timeframes agree on direction
  • Trend Integration: Adds trend filter to prevent trading against major moves
  • Conviction Measurement: Quantifies the strength of directional bias


The aggregator transforms the complex, often subjective process of multi-timeframe analysis into an objective, systematic framework that can be consistently applied.

Core Components Explained

1. Single Timeframe Bias Calculation

Each timeframe's bias is calculated using multiple indicators:

Pine Script®
// Single timeframe bias calculation f_calc_bias(float src_close, float src_high, float src_low) => // MA trend component float ma_fast = ta.ema(src_close, i_ma_fast) float ma_slow = ta.ema(src_close, i_ma_slow) float ma_diff = ma_slow != 0 ? (ma_fast - ma_slow) / ma_slow * 100 : 0 float ma_score = math.max(math.min(ma_diff * 10, 100), -100) // Price position component float price_pos = 0.0 if src_close > ma_fast and ma_fast > ma_slow price_pos := 100 else if src_close < ma_fast and ma_fast < ma_slow price_pos := -100 // ... additional price position logic // RSI component float rsi_val = ta.rsi(src_close, i_rsi_len) float rsi_score = (rsi_val - 50) * 2 // MACD component float macd_line = ta.ema(src_close, i_macd_fast) - ta.ema(src_close, i_macd_slow) float macd_signal = ta.ema(macd_line, i_macd_sig) float macd_hist = macd_line - macd_signal float atr_val = ta.atr(14) float macd_score = atr_val > 0 ? (macd_hist > 0 ? math.min(macd_hist / atr_val * 50, 100) : math.max(macd_hist / atr_val * 50, -100)) : 0 // Composite score float composite = ma_score * 0.35 + price_pos * 0.30 + rsi_score * 0.15 + macd_score * 0.20 composite


Bias components:
  • MA Trend (35% weight): Fast/slow EMA relationship and slope
  • Price Position (30% weight): Price relative to moving averages
  • RSI Momentum (15% weight): RSI centered at 50 for directional bias
  • MACD Histogram (20% weight): Trend acceleration/deceleration
  • Score Range: -100 (strong bearish) to +100 (strong bullish)
  • Neutral Zone: Scores between -30 and +30 considered neutral


Each component contributes unique directional information for comprehensive analysis.

2. Multi-Timeframe Data Requests

The indicator requests bias calculations from multiple timeframes:

Pine Script®
// Request bias from each timeframe f_request_bias(string tf) => request.security(syminfo.tickerid, tf, f_calc_bias(close, high, low)[1], lookahead=barmerge.lookahead_on) float bias_tf1 = f_request_bias(i_tf1) // Fastest timeframe float bias_tf2 = f_request_bias(i_tf2) // Medium timeframe float bias_tf3 = f_request_bias(i_tf3) // Slow timeframe float bias_tf4 = f_request_bias(i_tf4) // Slowest timeframe


MTF features:
  • Configurable Timeframes: User-defined timeframe selection
  • Confirmed Bars: Uses previous bar to prevent repainting
  • Lookahead Management: Proper security request handling
  • Current TF Bias: Also calculates bias on current timeframe
  • Data Validation: Handles missing or invalid data gracefully


The MTF system ensures you always have the bigger picture context.

snapshot

3. Weighted Aggregation System

Timeframes are weighted based on their importance:

Pine Script®
// Normalize weights float total_weight = i_w1 + i_w2 + i_w3 + i_w4 float w1_norm = total_weight > 0 ? i_w1 / total_weight : 0.25 float w2_norm = total_weight > 0 ? i_w2 / total_weight : 0.25 float w3_norm = total_weight > 0 ? i_w3 / total_weight : 0.25 float w4_norm = total_weight > 0 ? i_w4 / total_weight : 0.25 // Aggregate bias score float aggregate_bias = nz(bias_tf1) * w1_norm + nz(bias_tf2) * w2_norm + nz(bias_tf3) * w3_norm + nz(bias_tf4) * w4_norm // Smoothed aggregate float smooth_bias = ta.ema(aggregate_bias, 3)


Weighting features:
  • Customizable Weights: Assign importance to each timeframe
  • Automatic Normalization: Ensures weights sum to 100%
  • Default Weights: Higher weight to slower timeframes (15%, 25%, 30%, 30%)
  • Smoothing: EMA smoothing for cleaner signals
  • Flexibility: Adjust weights based on trading style


The aggregation system creates a single, unified bias score from all timeframes.

4. Bias Alignment Analysis

The indicator measures how many timeframes agree on direction:

Pine Script®
// Count aligned timeframes int bullish_count = 0 int bearish_count = 0 if nz(bias_tf1) > i_weak_thresh bullish_count += 1 else if nz(bias_tf1) < -i_weak_thresh bearish_count += 1 // Repeat for TF2, TF3, TF4... // Alignment score (0-4) int alignment_score = math.max(bullish_count, bearish_count) // Alignment direction int alignment_direction = bullish_count > bearish_count ? 1 : bearish_count > bullish_count ? -1 : 0 // Perfect alignment check bool perfect_bullish = bullish_count == 4 bool perfect_bearish = bearish_count == 4


Alignment features:
  • Alignment Score: Number of timeframes agreeing (0-4)
  • Alignment Direction: Overall consensus direction
  • Perfect Alignment: All timeframes agree (strongest signal)
  • Weak Threshold: Minimum bias for alignment (default 30)
  • Mixed Signals: When timeframes disagree (lower confidence)


Higher alignment scores indicate higher probability setups.

5. Trend Filter Integration

An optional trend filter prevents trading against major moves:

Pine Script®
// Trend filter float trend_ma = ta.ema(close, i_trend_ma) bool above_trend = close > trend_ma bool below_trend = close < trend_ma float trend_distance = trend_ma != 0 ? (close - trend_ma) / trend_ma * 100 : 0 // Trend-adjusted bias float trend_adjusted_bias = smooth_bias if i_use_trend if above_trend and smooth_bias > 0 trend_adjusted_bias := smooth_bias * (1 + i_trend_weight) else if below_trend and smooth_bias < 0 trend_adjusted_bias := smooth_bias * (1 + i_trend_weight) else if above_trend and smooth_bias < 0 trend_adjusted_bias := smooth_bias * (1 - i_trend_weight * 0.5) else if below_trend and smooth_bias > 0 trend_adjusted_bias := smooth_bias * (1 - i_trend_weight * 0.5)


Trend filter features:
  • Trend MA: Long-term moving average (default 200)
  • Trend Weight: Bonus for trading with trend (default 20%)
  • Penalty System: Reduces bias when trading against trend
  • Trend Distance: Measures how far price is from trend
  • Optional: Can be disabled for counter-trend strategies


The trend filter adds an extra layer of confirmation for directional bias.

6. Conviction and Consistency Metrics

The indicator measures the strength and stability of bias:

Pine Script®
// Confluence quality float confluence_quality = (float(alignment_score) / 4.0) * (math.abs(smooth_bias) / 100.0) * 100 // Bias conviction score float conviction_score = 0.0 conviction_score += float(alignment_score) * 15 // Max 60 conviction_score += math.abs(smooth_bias) * 0.3 // Max 30 if i_use_trend if (above_trend and smooth_bias > 0) or (below_trend and smooth_bias < 0) conviction_score += 10 // Trend alignment bonus conviction_score := math.min(conviction_score, 100) // Bias consistency var int bias_consistency_counter = 0 if smooth_bias > i_weak_thresh and smooth_bias[1] > i_weak_thresh bias_consistency_counter := math.min(bias_consistency_counter + 1, 20) else if smooth_bias < -i_weak_thresh and smooth_bias[1] < -i_weak_thresh bias_consistency_counter := math.min(bias_consistency_counter + 1, 20) else bias_consistency_counter := math.max(bias_consistency_counter - 1, 0) float bias_consistency = float(bias_consistency_counter) / 20.0 * 100


Quality metrics:
  • Confluence Quality: Combines alignment and strength (0-100%)
  • Conviction Score: Overall signal strength (0-100)
  • Bias Consistency: How stable the bias has been (0-100%)
  • Momentum: Rate of change in bias
  • Acceleration: Change in bias momentum


These metrics help assess signal reliability and persistence.

Visual Elements

  • Bias Histogram: Main bias display with gradient coloring
  • Conviction Ribbon: Visual representation of conviction strength
  • MTF Breakdown Lines: Individual timeframe bias lines
  • Alignment Markers: Diamonds for perfect alignment
  • Momentum Plot: Bias momentum visualization
  • Background Colors: Regime-based background shading
  • Dashboard: Comprehensive metrics panel
  • Glow Effects: Intensity-based visual enhancements


snapshot

The dashboard displays:
1. Individual timeframe biases and weights
2. Aggregate bias and trend-adjusted bias
3. Alignment score and direction
4. Confluence quality percentage
5. Conviction score and consistency
6. Bias momentum and acceleration
7. Trend filter status and distance
8. Signal strength and recommendations

Input Parameters

Timeframe Settings:
  • Timeframe 1-4: Individual timeframes for analysis
  • Default: 15m, 60m, 240m, Daily
  • Flexible: Can be any valid timeframe combination


Weighting Settings:
  • TF1-TF4 Weights: Individual importance weights
  • Default: 15%, 25%, 30%, 30% (favoring slower timeframes)
  • Total: Automatically normalized to 100%


Calculation Settings:
  • Fast/Slow MA: Bias calculation periods (default: 8/21)
  • RSI Period: Momentum oscillator (default: 14)
  • MACD Settings: Fast/Slow/Signal (default: 12/26/9)


Threshold Settings:
  • Strong Bias Threshold: Strong signal level (default: 60)
  • Weak Bias Threshold: Minimum bias for alignment (default: 30)
  • Trend Weight: Bonus for trend alignment (default: 20%)


How to Use This Indicator

Step 1: Analyze Individual Timeframes
Check the dashboard to see bias on each timeframe. Look for consistency - if most timeframes show the same direction, confidence is higher.

Step 2: Check Aggregate Bias
The aggregate bias provides a unified directional score. Values above 60 indicate strong bullish bias, below -60 indicate strong bearish bias.

Step 3: Verify Alignment
Higher alignment scores (3-4 timeframes) offer the highest probability setups. Perfect alignment (4/4) often precedes strong moves.

Step 4: Assess Conviction
High conviction scores (>75%) indicate strong, consistent bias. Low conviction (<50%) suggests uncertainty - wait for clarity.

Step 5: Consider Trend Filter
If enabled, ensure bias aligns with the major trend. Trading against the trend reduces conviction and increases risk.

Step 6: Monitor Momentum
Accelerating bias in the direction of alignment suggests the move is gaining strength. Decelerating bias warns of potential reversals.

Best Practices

  • Perfect alignment (4/4) provides the highest probability setups
  • Higher timeframe bias should generally override lower timeframe signals
  • Increasing conviction scores suggest strengthening trends
  • Divergence between timeframes often precedes reversals
  • Use the trend filter unless you're specifically trading counter-trend setups
  • Bias consistency is key - look for stable, persistent bias
  • Sudden changes in aggregate bias often signal regime shifts
  • Combine with price action for optimal entry timing
  • Adjust timeframe weights based on your trading style
  • Keep a bias journal to track how different instruments behave


Trading Applications

Trend Following:
  • Enter when bias > 60 on at least 3 timeframes
  • Add to positions as conviction increases
  • Stay in trades as long as bias remains aligned
  • Exit when bias weakens or reverses on slower timeframes


Mean Reversion:
  • Look for extreme bias (>80 or <-80) on faster timeframes
  • Enter when faster timeframe bias opposes slower timeframe
  • Target mean reversion to neutral bias levels
  • Quick exits - don't fight the longer-term bias


Breakout Trading:
  • Wait for bias alignment across all timeframes
  • Enter on breakouts with supporting bias momentum
  • Use wider stops due to potential volatility
  • Scale out as bias reaches extreme levels


Strategy Integration

This indicator enhances any trading system:

  • Use as a directional filter for existing strategies
  • Import aggregate bias for trend confirmation
  • Use alignment score as signal strength filter
  • Apply conviction scoring for position sizing
  • Integrate trend filter for additional safety
  • Export individual timeframe biases for custom logic


Technical Implementation

Built with Pine Script v6 featuring:
  • Multi-timeframe bias calculation with proper security requests
  • Weighted aggregation system with automatic normalization
  • Advanced alignment detection with perfect alignment alerts
  • Trend filter integration with adjustable weighting
  • Conviction and consistency scoring systems
  • Momentum and acceleration analysis
  • Comprehensive visualization with multi-layer effects
  • Real-time dashboard with 12 key metrics
  • Alert conditions for all major bias events
  • Export functions for strategy integration


The code uses confirmed bars and proper lookahead management to prevent repainting.

Originality Statement

This indicator is original in its comprehensive approach to multi-timeframe bias aggregation and scoring. While individual components (moving averages, RSI, MACD) are established tools, this indicator is justified because:

  • It synthesizes bias analysis across multiple timeframes into a unified scoring system
  • The weighted aggregation allows customization based on trading style and preferences
  • Alignment detection provides objective measures of timeframe consensus
  • The conviction scoring system quantifies signal strength and reliability
  • Trend filter integration adds an extra layer of confirmation
  • Consistency analysis identifies stable, persistent bias versus noisy fluctuations
  • The dashboard presents complex multi-timeframe analysis in an accessible format
  • Export functions enable integration with any trading system
  • Each timeframe contributes unique context: faster timeframes show immediate bias, slower timeframes show established trends
  • The indicator solves the real problem of conflicting signals across timeframes through systematic aggregation


The indicator's value lies in transforming the complex, often confusing world of multi-timeframe analysis into a clear, objective system that traders can use to make informed decisions with confidence.

Disclaimer

This indicator is provided for educational and informational purposes only. It is not financial advice or a recommendation to buy or sell any financial instrument. Multi-timeframe analysis is a tool for understanding market context, not a prediction system.

Bias can change suddenly due to news events, economic data, or changes in market structure. Past bias patterns do not guarantee future behavior. The indicator's signals are mathematical calculations based on historical patterns and should be used in conjunction with other forms of analysis.

Always use proper risk management, including stop losses and position sizing appropriate for your account and risk tolerance. Strong bias alignment does not guarantee success - markets can remain irrational longer than you can remain solvent.

The author is not responsible for any losses incurred from using this indicator. Users assume full responsibility for all trading decisions made using this system.

-Made with passion by officialjackofalltrades

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.