Indicator · Pine Script v6 · On the chart

QuantMarket Lab Directional Dashboard

by EngAlhassan404· code credited to Eng.Alhassan Ali Mubarak Bahbah

A statistics table on the price chart that counts how many recent candles closed up, down or flat and shows the share of each as a directional bias.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code209
Settings14inputs
LicenceMIT
Last update1 year ago24 Sep 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

209 lines of Pine Script v6 from TradingView_Indicator/QML_HUD.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

QML_HUD.pine
//@version=6
// -----------------------------------------------------------------------------
// © 2025 Eng.Alhassan Ali Mubarak Bahbah
//
// Title:         QuantMarket Lab: Directional Dashboard
// Author:        Eng.Alhassan Ali Mubarak Bahbah
// Version:       5.1
// Description:   A multi-mode statistical dashboard for analyzing market
//                directional equilibrium based on candle frequency.
// -----------------------------------------------------------------------------
indicator("QuantMarket Lab: Directional Dashboard", "QML-HUD", true)

// =============================================================================
//                                 USER INPUTS
// =============================================================================

// --- Analysis Mode Settings ---
string grp_mode = "1. Analysis Mode"
string systemMode = input.string("Standard", "System Mode", options=["Standard", "Daily", "Weekly", "Monthly"], group=grp_mode, tooltip="Standard: Uses a fixed lookback period.\nDaily/Weekly/Monthly: Analyzes data from the start of the current session.")
int minCandles = input.int(10, "Min. Calculation Candles", minval=1, group=grp_mode, tooltip="The minimum number of candles required in a session (Daily, Weekly, Monthly) before statistics are displayed.")

// --- General Settings ---
string grp_general = "2. General Settings"
int lookbackPeriod = input.int(252, "Lookback Period", minval=1, group=grp_general, tooltip="Only active when 'System Mode' is set to 'Standard'.")
bool showNeutral = input.bool(true, "Show Neutral (Doji) Candles?", group=grp_general)

// --- Display Settings ---
string grp_display = "3. Display Settings"
string tablePosition = input.string("top_right", "Table Position", options=["top_right", "top_left", "bottom_right", "bottom_left"], group=grp_display)
string fontSizeOption = input.string("Normal", "Font Size", options=["Small", "Normal", "Large"], group=grp_display)

// --- Color & Thresholds Settings ---
string grp_colors = "4. Color & Thresholds Settings"
float moderateThreshold = input.float(55.0, "Moderate Bias Threshold %", minval=50.0, step=0.5, group=grp_colors)
float extremeThreshold = input.float(70.0, "Extreme Bias Threshold %", minval=50.1, step=0.5, group=grp_colors)
color equilibriumColor = input.color(color.new(color.gray, 20), "Equilibrium Color", group=grp_colors)
color moderateUpColor = input.color(color.new(#26A69A, 70), "Moderate Up Color", group=grp_colors)
color extremeUpColor = input.color(color.new(#26A69A, 40), "Extreme Up Color", group=grp_colors)
color moderateDownColor = input.color(color.new(#EF5350, 70), "Moderate Down Color", group=grp_colors)
color extremeDownColor = input.color(color.new(#EF5350, 40), "Extreme Down Color", group=grp_colors)
color textColor = input.color(color.new(color.white, 0), "Text Color", group=grp_colors)

// =============================================================================
//                               HELPER FUNCTIONS
// =============================================================================

// Gets the font size based on user selection.
f_get_font_size(string sizeOption) =>
    switch sizeOption
        "Small" => size.small
        "Large" => size.large
        => size.normal

// Gets the background color based on the directional bias percentage.
f_get_bias_color(float percentage, bool isUp) =>
    color resultColor = equilibriumColor
    if percentage >= extremeThreshold
        resultColor := isUp ? extremeUpColor : extremeDownColor
    else if percentage >= moderateThreshold
        resultColor := isUp ? moderateUpColor : moderateDownColor
    resultColor

// Gets the status text description based on percentages.
f_get_status_text(float upPerc, float downPerc) =>
    string statusText = "Equilibrium"
    if upPerc >= extremeThreshold
        statusText := "Extreme Upward Bias"
    else if upPerc >= moderateThreshold
        statusText := "Moderate Upward Bias"
    else if downPerc >= extremeThreshold
        statusText := "Extreme Downward Bias"
    else if downPerc >= moderateThreshold
        statusText := "Moderate Downward Bias"
    statusText

// Draws a simple cell in the table.
f_cell_simple(table tbl, int col, int row, string txt, string txt_halign, color bgcolor) =>
    tbl.cell(col, row, txt, text_halign=txt_halign, text_size=f_get_font_size(fontSizeOption), text_color=textColor, bgcolor=bgcolor)

// =============================================================================
//                                  CALCULATIONS
// =============================================================================

// Define the current candle's state.
bool isUp = close > open
bool isDown = close < open

// Variables to hold the final values for the table display.
float finalUpCount = 0.0
float finalDownCount = 0.0
float finalNeutralCount = 0.0
float finalTotalCount = 0.0
string modeLabel = "Lookback Period"
string modeValue = ""

// Main Logic: Switch between Standard and Session-based modes.
if systemMode == "Standard"
    // Standard Mode Logic (rolling window).
    finalUpCount := math.sum(isUp ? 1 : 0, lookbackPeriod)
    finalDownCount := math.sum(isDown ? 1 : 0, lookbackPeriod)
    finalNeutralCount := showNeutral ? math.sum(not isUp and not isDown ? 1 : 0, lookbackPeriod) : 0
    finalTotalCount := lookbackPeriod
    modeValue := str.tostring(lookbackPeriod) + " Candles"
else
    // Session Mode Logic (Daily, Weekly, Monthly).
    // Persistent variables to track the session.
    var int sessionUpCount = 0
    var int sessionDownCount = 0
    var int sessionNeutralCount = 0
    var int barsInSession = 0

    // Detect the start of a new session.
    bool isNewDay = timeframe.change("D")
    bool isNewWeek = timeframe.change("W")
    bool isNewMonth = timeframe.change("M")
    bool sessionReset = (systemMode == "Daily" and isNewDay) or (systemMode == "Weekly" and isNewWeek) or (systemMode == "Monthly" and isNewMonth)

    // Reset or accumulate the counters.
    if sessionReset
        sessionUpCount := isUp ? 1 : 0
        sessionDownCount := isDown ? 1 : 0
        sessionNeutralCount := showNeutral and not isUp and not isDown ? 1 : 0
        barsInSession := 1
    else
        sessionUpCount += isUp ? 1 : 0
        sessionDownCount += isDown ? 1 : 0
        sessionNeutralCount += showNeutral and not isUp and not isDown ? 1 : 0
        barsInSession += 1

    finalUpCount := sessionUpCount
    finalDownCount := sessionDownCount
    finalNeutralCount := sessionNeutralCount
    finalTotalCount := barsInSession
    modeLabel := "System Mode"
    modeValue := systemMode + " (" + str.tostring(barsInSession) + " Candles)"

// Check for data validity based on the minimum candles input.
bool dataIsValid = systemMode == "Standard" or finalTotalCount >= minCandles

// Calculate final percentages for display.
float totalForCalc = finalTotalCount > 0 ? finalTotalCount : 1
float finalUpPerc = (finalUpCount / totalForCalc) * 100
float finalDownPerc = (finalDownCount / totalForCalc) * 100
float finalNeutralPerc = (finalNeutralCount / totalForCalc) * 100

// =============================================================================
//                                TABLE DRAWING
// =============================================================================

if (barstate.islast)
    // Define table dimensions.
    int NUM_COLUMNS = 2
    int NUM_ROWS = 7
    var table hud = table.new(position.top_right, NUM_COLUMNS, NUM_ROWS, border_width = 0)
    
    // Set table position based on user input.
    var pos = position.top_right
    switch tablePosition
        "top_left" => pos := position.top_left
        "bottom_right" => pos := position.bottom_right
        "bottom_left" => pos := position.bottom_left
        => pos
    hud.set_position(pos)
    
    // Clear table before redrawing.
    hud.clear(0, 0, NUM_COLUMNS - 1, NUM_ROWS - 1)

    int row_idx = 0

    // Row 0: Header
    f_cell_simple(hud, 0, row_idx, syminfo.ticker, text.align_left, color.new(color.blue, 50))
    f_cell_simple(hud, 1, row_idx, "Frame: " + timeframe.period, text.align_right, color.new(color.blue, 50))
    row_idx += 1

    // Row 1: Smart Mode Display
    f_cell_simple(hud, 0, row_idx, modeLabel, text.align_left, na)
    f_cell_simple(hud, 1, row_idx, modeValue, text.align_right, na)
    row_idx += 1
    
    // Prepare display text based on data validity.
    string upText = dataIsValid ? str.format("{0,number,integer} ({1,number,.2f}%)", finalUpCount, finalUpPerc) : "N/A"
    string downText = dataIsValid ? str.format("{0,number,integer} ({1,number,.2f}%)", finalDownCount, finalDownPerc) : "N/A"
    string neutralText = dataIsValid ? str.format("{0,number,integer} ({1,number,.2f}%)", finalNeutralCount, finalNeutralPerc) : "N/A"
    string statusText = dataIsValid ? f_get_status_text(finalUpPerc, finalDownPerc) : "Awaiting Data..."

    // Prepare background colors based on data validity.
    color upBgColor = dataIsValid ? f_get_bias_color(finalUpPerc, true) : na
    color downBgColor = dataIsValid ? f_get_bias_color(finalDownPerc, false) : na
    color neutralBgColor = dataIsValid ? equilibriumColor : na

    // Row 2: Up Candles Data
    f_cell_simple(hud, 0, row_idx, "↑ Up Candles", text.align_left, na)
    f_cell_simple(hud, 1, row_idx, upText, text.align_right, upBgColor)
    row_idx += 1
    
    // Row 3: Down Candles Data
    f_cell_simple(hud, 0, row_idx, "↓ Down Candles", text.align_left, na)
    f_cell_simple(hud, 1, row_idx, downText, text.align_right, downBgColor)
    row_idx += 1
    
    // Row 4: Neutral Candles Data (Conditional)
    if (showNeutral)
        f_cell_simple(hud, 0, row_idx, "- Neutral Candles", text.align_left, na)
        f_cell_simple(hud, 1, row_idx, neutralText, text.align_right, neutralBgColor)
        row_idx += 1
    
    // Final Row: Status
    f_cell_simple(hud, 0, row_idx, "Status", text.align_left, na)
    f_cell_simple(hud, 1, row_idx, statusText, text.align_right, na)

Overview

In Standard mode it uses a fixed lookback; in Daily, Weekly or Monthly mode it counts candles since the session started. Thresholds set when a bias counts as moderate or extreme, and colors, table position and font size are adjustable. It is a descriptive readout, not a signal generator.

Details

Published by

EngAlhassan404 on GitHub

Code credit

Eng.Alhassan Ali Mubarak Bahbah, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Screeners & dashboards

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingdata-analysisfinanceforex-marketpine-scriptpythonquantitative-financestock-markettradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
System ModestringStandardsystemMode
Min. Calculation Candlesint10minCandles
Lookback Periodint252lookbackPeriod
Show Neutral (Doji) Candles?booltrueshowNeutral
Table Positionstringtop_righttablePosition
Font SizestringNormalfontSizeOption
Moderate Bias Threshold %float55.0moderateThreshold
Extreme Bias Threshold %float70.0extremeThreshold
Equilibrium Colorcolorcolor.new(color.gray, 20)equilibriumColor
Moderate Up Colorcolorcolor.new(#26A69A, 70)moderateUpColor
Extreme Up Colorcolorcolor.new(#26A69A, 40)extremeUpColor
Moderate Down Colorcolorcolor.new(#EF5350, 70)moderateDownColor
Show all 14 settings
SettingTypeDefaultVariable
Extreme Down Colorcolorcolor.new(#EF5350, 40)extremeDownColor
Text Colorcolorcolor.new(color.white, 0)textColor
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Symbol Info Helper

by everget
948 stars

Symbol Info Helper is an informational utility script that displays metadata about the currently selected instrument directly on the main price chart. It gathers built-in symbol properties including ticker identifier, description, instrument type, point value,

Indicator v4 Screeners & dashboards
Updated 11 days ago · GPL-3.0 GitHub repository of Symbol Info Helper
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
330 stars

This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale

Indicator v5 Support & resistanceScreeners & dashboards
Updated 2 months ago · None stated GitHub repository of Multi Alert Long/Short [Alorse]

Pricing Table

by namuan
318 stars

This indicator calculates theoretical options contract values and in-the-money probabilities using historical realized volatility across multiple standard deviations. It displays these metrics in a table overlay directly on the price chart. Users can adjust th

Indicator v4 Volatility & bandsScreeners & dashboards
Updated 2 months ago · MIT GitHub repository of Pricing Table

3938 Tracker

by Allen1212
303 stars

3938 Tracker visualizes historical buying and selling activity from ARK Invest funds directly on the main price chart. It plots labels at specific timestamps corresponding to trade dates, indicating buy or sell actions along with the count of participating ETF

Indicator v4 Screeners & dashboards
Updated 2 years ago · None stated GitHub repository of 3938 Tracker

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers