CodeRe: TradingView Indicators to MT4 Indicators

751
CaliNgu27 wrote: Sun Apr 12, 2026 9:42 am Can this indicator be converted to MT4?
Q-Trend

Hello, try these.

The "mod" version have strong buy/sell arrows/alerts

What is Q-Trend?

The Q-Trend is a clean, multi-purpose trend indicator that works on any timeframe which is best used in quieter, non-volatile markets.

This indicator does three simple things:
  • Draws a dynamic trend line in the middle of recent price action (based on the highest and lowest prices over your chosen Trend Period).
  • Adds a volatility buffer around that line using ATR (so it ignores small noise).
  • Gives you a Buy signal when price breaks clearly above the upper buffer, and a Sell signal when it breaks clearly below the lower buffer.
    At the same time, the trend line updates to follow the new price movement.
It can be referred to as a "smart trend channel" that only alerts you when the trend is really accelerating.
"fear moves faster than greed"

Re: TradingView Indicators to MT4 Indicators

753
This TV indicator is called HTF Reversal Divergence.
I'll include the code to see if it can be converted to MT4, but is there already an indicator for MT4 that shows an engulfing and shooting star type candle pattern for a HTF on a LTF chart?

Code: Select all

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=6
indicator("HTF Reversal Divergences [LuxAlgo]", "LuxAlgo - HTF Reversal Divergences", overlay = false, max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500)

//---------------------------------------------------------------------------------------------------------------------}
// Constants
//---------------------------------------------------------------------------------------------------------------------{
const color BULL_COLOR    = #089981
const color BEAR_COLOR    = #f23645
const color NEUTRAL_COLOR = #787b86

//---------------------------------------------------------------------------------------------------------------------}
// Inputs
//---------------------------------------------------------------------------------------------------------------------{
// HTF Pattern Inputs
htfInput            = input.timeframe("15", "High Timeframe",           group = "HTF Reversal Patterns", tooltip = "The timeframe to check for reversal patterns.")
showEngulfingInput  = input.bool(true,      "Show Engulfing Patterns",  group = "HTF Reversal Patterns")
showPinBarsInput    = input.bool(true,      "Show Pin Bars",            group = "HTF Reversal Patterns", tooltip = "Includes Hammer and Shooting Star patterns.")
bullPatternColInput = input.color(BULL_COLOR, "Bullish Pattern Color",  group = "HTF Reversal Patterns", inline = "Colors")
bearPatternColInput = input.color(BEAR_COLOR, "Bearish Pattern Color",  group = "HTF Reversal Patterns", inline = "Colors")

// RSI Divergence Inputs
showDivInput        = input.bool(true,      "Show RSI Divergences",     group = "RSI Divergence")
rsiLenInput         = input.int(14,         "RSI Length",               group = "RSI Divergence", minval = 1)
lbRInput            = input.int(5,          "Pivot Right Lookback",     group = "RSI Divergence")
lbLInput            = input.int(5,          "Pivot Left Lookback",      group = "RSI Divergence")
bullDivColInput     = input.color(BULL_COLOR, "Bullish Div Color",      group = "RSI Divergence", inline = "Div Colors")
bearDivColInput     = input.color(BEAR_COLOR, "Bearish Div Color",      group = "RSI Divergence", inline = "Div Colors")

// Advanced: HTF PO3 Inputs
showPo3Input        = input.bool(false,     "Show HTF PO3",             group = "Advanced: HTF PO3", tooltip = "Displays projected HTF candles to the right of price on the main chart.")
candleCountInput    = input.int(1,          "Candles to Show",          group = "Advanced: HTF PO3", minval = 1, maxval = 10)
po3OffsetInput      = input.int(15,         "Right Offset (Bars)",      group = "Advanced: HTF PO3", minval = 5)
showPo3LabelsInput  = input.bool(true,      "Show PO3 Price Labels",    group = "Advanced: HTF PO3")
showPo3DeltaInput   = input.bool(true,      "Show PO3 Running Delta",   group = "Advanced: HTF PO3")

// Alert Inputs
alertBullDivInput   = input.bool(true,      "Bullish Divergence",       group = "Alerts")
alertBearDivInput   = input.bool(true,      "Bearish Divergence",       group = "Alerts")
alertBullEngInput   = input.bool(true,      "Bullish Engulfing",        group = "Alerts")
alertBearEngInput   = input.bool(true,      "Bearish Engulfing",        group = "Alerts")
alertHammerInput    = input.bool(true,      "Hammer",                   group = "Alerts")
alertStarInput      = input.bool(true,      "Shooting Star",            group = "Alerts")

//---------------------------------------------------------------------------------------------------------------------}
// Types & Methods
//---------------------------------------------------------------------------------------------------------------------{
type HTFData
    float o
    float h
    float l
    float c
    int   oIdx
    int   hIdx
    int   lIdx
    float delta
    int   startTime

type HTFCandleUI
    box   body
    line  wick
    line  oM
    line  hM
    line  lM
    line  cM
    label oL
    label hL
    label lL
    label cL
    label dL
    label tL

//---------------------------------------------------------------------------------------------------------------------}
// Functions
//---------------------------------------------------------------------------------------------------------------------{
formatDelta(float val) =>
    string sign = val > 0 ? "+" : ""
    float absVal = math.abs(val)
    absVal >= 1000000 ? sign + str.format("{0,number,#.#}M", val / 1000000) : absVal >= 1000 ? sign + str.format("{0,number,#.#}K", val / 1000) : sign + str.tostring(val)

drawHtfPattern(string name, float h, float l, float o, float c, int tStart, int tEnd, color col, bool isBullish) =>
    string timeStr  = str.format_time(tStart, "HH:mm", syminfo.timezone)
    string labelTxt = name + "\n" + timeStr
    int midTime     = math.round((tStart + tEnd) / 2)
    int timeInset   = math.round((tEnd - tStart) * 0.1)

    box.new(tStart, h, tEnd, l, xloc = xloc.bar_time, bgcolor = color.new(col, 90), border_color = color.new(col, 50), border_width = 1, force_overlay = true)
    box.new(tStart + timeInset, math.max(o, c), tEnd - timeInset, math.min(o, c), xloc = xloc.bar_time, bgcolor = color.new(col, 60), border_color = color.new(col, 20), border_width = 1, force_overlay = true)
    line.new(midTime, h, midTime, l, xloc = xloc.bar_time, color = color.new(col, 20), width = 1, force_overlay = true)
    label.new(midTime, isBullish ? l : h, labelTxt, xloc = xloc.bar_time, yloc = yloc.price, color = #00000000, textcolor = col, style = isBullish ? label.style_label_up : label.style_label_down, size = size.small, force_overlay = true)

//---------------------------------------------------------------------------------------------------------------------}
// Core Calculations
//---------------------------------------------------------------------------------------------------------------------{
bool htfNewBar = nz(ta.change(time(htfInput))) != 0

// Fetch HTF Data: [1] is the bar that just finished
[hOpen, hHigh, hLow, hClose, hPrevOpen, hPrevClose, hTimeStart, hTimeEnd] = request.security(syminfo.tickerid, htfInput, [open[1], high[1], low[1], close[1], open[2], close[2], time[1], time_close[1]])

// PO3 Tracking logic
var htfHistory = array.new<HTFData>()
var float curO = na, var float curH = na, var float curL = na
var int   curOIdx = na, var int   curHIdx = na, var int   curLIdx = na
var float curDelta = 0.0
var int   curStartTime = na

if showPo3Input
    if htfNewBar
        if not na(curO)
            htfHistory.unshift(HTFData.new(curO, curH, curL, close[1], curOIdx, curHIdx, curLIdx, curDelta, curStartTime))
            if htfHistory.size() > 10
                htfHistory.pop()
        curO := open, curH := high, curL := low, curOIdx := bar_index, curHIdx := bar_index, curLIdx := bar_index, curDelta := (close > open ? volume : close < open ? -volume : 0), curStartTime := time
    else
        if high > curH or na(curH)
            curH := high, curHIdx := bar_index
        if low < curL or na(curL)
            curL := low, curLIdx := bar_index
        curDelta += (close > open ? volume : close < open ? -volume : 0)

// HTF Pattern Logic
bool isBullEngulfing = showEngulfingInput and hClose > hOpen and hPrevClose < hPrevOpen and hClose >= hPrevOpen and hOpen <= hPrevClose
bool isBearEngulfing = showEngulfingInput and hClose < hOpen and hPrevClose > hPrevOpen and hClose <= hPrevOpen and hOpen >= hPrevClose
bool isHammer        = showPinBarsInput and (math.min(hOpen, hClose) - hLow) > (hHigh - hLow) * 0.6 and math.abs(hClose - hOpen) < (hHigh - hLow) * 0.3
bool isShootingStar  = showPinBarsInput and (hHigh - math.max(hOpen, hClose)) > (hHigh - hLow) * 0.6 and math.abs(hClose - hOpen) < (hHigh - hLow) * 0.3

bool isBullPattern = isBullEngulfing or isHammer
bool isBearPattern = isBearEngulfing or isShootingStar

// RSI Calculations
float rsiValue = ta.rsi(close, rsiLenInput)
color rsiColor = rsiValue > 50 ? bullDivColInput : bearDivColInput

// RSI Divergence Logic
float phRsi = ta.pivothigh(rsiValue, lbLInput, lbRInput), float plRsi = ta.pivotlow(rsiValue, lbLInput, lbRInput)
bool bullDivConfirmed = false, bearDivConfirmed = false

var float plPriceMem = na, var float plRsiMem = na, var int plIndexMem = na
if not na(plRsi)
    if not na(plPriceMem) and rsiValue[lbRInput] > plRsiMem and low[lbRInput] < plPriceMem
        bullDivConfirmed := true
        if showDivInput
            line.new(plIndexMem, plPriceMem, bar_index - lbRInput, low[lbRInput], color = bullDivColInput, width = 2, force_overlay = true)
            label.new(bar_index - lbRInput, low[lbRInput], "Bull Div", yloc = yloc.belowbar, textcolor = bullDivColInput, color = #00000000, size = size.small, style = label.style_label_up, force_overlay = true)
            line.new(plIndexMem, plRsiMem, bar_index - lbRInput, rsiValue[lbRInput], color = bullDivColInput, width = 2)
    plPriceMem := low[lbRInput], plRsiMem := rsiValue[lbRInput], plIndexMem := bar_index - lbRInput

var float phPriceMem = na, var float phRsiMem = na, var int phIndexMem = na
if not na(phRsi)
    if not na(phPriceMem) and rsiValue[lbRInput] < phRsiMem and high[lbRInput] > phPriceMem
        bearDivConfirmed := true
        if showDivInput
            line.new(phIndexMem, phPriceMem, bar_index - lbRInput, high[lbRInput], color = bearDivColInput, width = 2, force_overlay = true)
            label.new(bar_index - lbRInput, high[lbRInput], "Bear Div", yloc = yloc.abovebar, textcolor = bearDivColInput, color = #00000000, size = size.small, style = label.style_label_down, force_overlay = true)
            line.new(phIndexMem, phRsiMem, bar_index - lbRInput, rsiValue[lbRInput], color = bearDivColInput, width = 2)
    phPriceMem := high[lbRInput], phRsiMem := rsiValue[lbRInput], phIndexMem := bar_index - lbRInput

//---------------------------------------------------------------------------------------------------------------------}
// Visuals
//---------------------------------------------------------------------------------------------------------------------{
// RSI Plots
rsiPlot = plot(rsiValue, "RSI", color = rsiColor, linewidth = 2)
midPlot = plot(50,       "Mid Line", color = color.new(chart.fg_color, 80), style = plot.style_linebr)
fill(midPlot, rsiPlot, 50, rsiValue, rsiValue > 50 ? color.new(bullDivColInput, 100) : color.new(bearDivColInput, 50), rsiValue > 50 ? color.new(bullDivColInput, 50) : color.new(bearDivColInput, 100))
hline(70, "OB", color = color.new(bearDivColInput, 50), linestyle = hline.style_dashed)
hline(30, "OS", color = color.new(bullDivColInput, 50), linestyle = hline.style_dashed)

// HTF Reversal Pattern Drawings
if htfNewBar and not na(hTimeStart)
    if isBullPattern
        drawHtfPattern(isBullEngulfing ? "Bull Engulfing" : "Hammer", hHigh, hLow, hOpen, hClose, hTimeStart, hTimeEnd, bullPatternColInput, true)
    if isBearPattern
        drawHtfPattern(isBearEngulfing ? "Bear Engulfing" : "Shooting Star", hHigh, hLow, hOpen, hClose, hTimeStart, hTimeEnd, bearPatternColInput, false)

// PO3 UI Logic
var uiElements = array.new<HTFCandleUI>()
if barstate.islast and showPo3Input
    if uiElements.size() > 0
        for i = 0 to uiElements.size() - 1
            HTFCandleUI ui = uiElements.get(i)
            ui.body.delete()
            ui.wick.delete()
            if not na(ui.oM)
                ui.oM.delete()
            if not na(ui.hM)
                ui.hM.delete()
            if not na(ui.lM)
                ui.lM.delete()
            if not na(ui.cM)
                ui.cM.delete()
            if not na(ui.oL)
                ui.oL.delete()
            if not na(ui.hL)
                ui.hL.delete()
            if not na(ui.lL)
                ui.lL.delete()
            if not na(ui.cL)
                ui.cL.delete()
            if not na(ui.dL)
                ui.dL.delete()
            if not na(ui.tL)
                ui.tL.delete()
    uiElements.clear()

    int candleWidth = 6, int candleGap = 10
    for p = 0 to candleCountInput - 1
        bool isLive = (p == candleCountInput - 1)
        HTFData data = isLive ? HTFData.new(curO, curH, curL, close, curOIdx, curHIdx, curLIdx, curDelta, curStartTime) : (htfHistory.size() > (candleCountInput - 2) - p ? htfHistory.get((candleCountInput - 2) - p) : na)
        
        if not na(data)
            int startIdx = last_bar_index + po3OffsetInput + (p * (candleWidth + candleGap)), int endIdx = startIdx + candleWidth, int midIdx = (startIdx + endIdx) / 2
            color baseColor = data.c >= data.o ? bullPatternColInput : bearPatternColInput
            color wickColor = isLive ? baseColor : color.new(baseColor, 70)
            line wLine = line.new(midIdx, data.h, midIdx, data.l, color = wickColor, width = 2, force_overlay = true)
            box  bBox  = box.new(startIdx, math.max(data.o, data.c), endIdx, math.min(data.o, data.c), border_color = wickColor, bgcolor = color.new(baseColor, isLive ? 20 : 85), force_overlay = true)
            line oM = na, line hM = na, line lM = na, line cM = na, label oL = na, label hL = na, label lL = na, label cL = na, label dL = na
            if isLive
                oM := line.new(data.oIdx, data.o, startIdx, data.o, color = NEUTRAL_COLOR, style = line.style_dashed, force_overlay = true)
                hM := line.new(data.hIdx, data.h, midIdx, data.h, color = bullPatternColInput, style = line.style_dashed, force_overlay = true)
                lM := line.new(data.lIdx, data.l, midIdx, data.l, color = bearPatternColInput, style = line.style_dashed, force_overlay = true)
                cM := line.new(bar_index, data.c, endIdx, data.c, color = baseColor, style = line.style_dashed, force_overlay = true)
                if showPo3LabelsInput
                    oL := label.new(endIdx + 1, data.o, "Open: " + str.tostring(data.o, format.mintick), color = #00000000, textcolor = NEUTRAL_COLOR, style = label.style_label_left, size = size.small, force_overlay = true)
                    hL := label.new(endIdx + 1, data.h, "High: " + str.tostring(data.h, format.mintick), color = #00000000, textcolor = bullPatternColInput, style = label.style_label_left, size = size.small, force_overlay = true)
                    lL := label.new(endIdx + 1, data.l, "Low: " + str.tostring(data.l, format.mintick), color = #00000000, textcolor = bearPatternColInput, style = label.style_label_left, size = size.small, force_overlay = true)
                    cL := label.new(endIdx + 1, data.c, "Close: " + str.tostring(data.c, format.mintick), color = #00000000, textcolor = baseColor, style = label.style_label_left, size = size.small, force_overlay = true)
            int totalMins = timeframe.in_seconds(htfInput) / 60
            string tfStr = totalMins >= 1440 ? str.tostring(totalMins/1440) + "D" : totalMins >= 60 ? str.tostring(totalMins/60) + "H" : str.tostring(totalMins) + "m"
            label tL = label.new(midIdx, data.h, tfStr + (not isLive ? "\n" + str.format_time(data.startTime, "HH:mm", syminfo.timezone) : ""), color = #00000000, textcolor = isLive ? NEUTRAL_COLOR : color.new(NEUTRAL_COLOR, 60), style = label.style_label_down, size = size.normal, force_overlay = true)
            if showPo3DeltaInput
                dL := label.new(midIdx, data.l, "Delta: " + formatDelta(data.delta), color = #00000000, textcolor = isLive ? (data.delta >= 0 ? bullPatternColInput : bearPatternColInput) : color.new(NEUTRAL_COLOR, 60), style = label.style_label_up, size = size.normal, force_overlay = true)
            uiElements.push(HTFCandleUI.new(bBox, wLine, oM, hM, lM, cM, oL, hL, lL, cL, dL, tL))

//---------------------------------------------------------------------------------------------------------------------}
// Alerts
//---------------------------------------------------------------------------------------------------------------------{
if (alertBullDivInput and bullDivConfirmed)
    alert("Bullish RSI Divergence on " + syminfo.ticker, alert.freq_once_per_bar_close)
if (alertBearDivInput and bearDivConfirmed)
    alert("Bearish RSI Divergence on " + syminfo.ticker, alert.freq_once_per_bar_close)
if (alertBullEngInput and htfNewBar and isBullEngulfing)
    alert("HTF Bullish Engulfing on " + syminfo.ticker, alert.freq_once_per_bar_close)
if (alertBearEngInput and htfNewBar and isBearEngulfing)
    alert("HTF Bearish Engulfing on " + syminfo.ticker, alert.freq_once_per_bar_close)
if (alertHammerInput and htfNewBar and isHammer)
    alert("HTF Hammer on " + syminfo.ticker, alert.freq_once_per_bar_close)
if (alertStarInput and htfNewBar and isShootingStar)
    alert("HTF Shooting Star on " + syminfo.ticker, alert.freq_once_per_bar_close)

//---------------------------------------------------------------------------------------------------------------------}
These users thanked the author CaliNgu27 for the post:
ashdays

Re: TradingView Indicators to MT4 Indicators

754
Dear Coders can you make this indicator as same as Trading View it will be very helpful thankyou

https://www.tradingview.com/support/sol ... 000773012/

Kaufman's Adaptive Moving Average (KAMA), introduced by Perry J. Kaufman in 1995, is a moving average that dynamically adjusts its smoothing behavior to the relative noise or choppiness in market movements.

Kaufman designed the indicator as a generalized trend-following solution based on the idea that faster averages are more useful for tracking trends when the market price is moving quickly in one direction, and slower averages are better for avoiding whipsaws during periods of choppiness and volatility. As such, KAMA follows the market price at a faster rate when movements are efficient and directional, and at a slower rate when movements are choppy or inefficient.

Traders often analyze movements in KAMA to identify trends and choppy market conditions, and use the crossings between KAMA and price or other moving averages to find potential turning points and signals.


Calculation
At its core, KAMA uses the same general structure as an exponential moving average (EMA):

MA = SC × Price + (1 − SC) × Previous MA
Where:

SC is the smoothing factor, sometimes referred to as the smoothing constant, which is a value between 0 and 1 that controls the rate at which the moving average follows the market price. The lower the factor, the less sensitive the moving average becomes to short-term price changes.
Previous MA is the EMA value on the previous bar.
A traditional EMA calculates a fixed smoothing factor of 2 / (length + 1), where the length value controls the period for which the average responds significantly to changes in price.

By contrast, KAMA calculates a dynamic factor based on the estimated efficiency of market movements. Below are the steps that the indicator performs to calculate the smoothing factor.

Calculate the Efficiency Ratio
KAMA uses Kaufman's Efficiency Ratio (ER) to control its responsiveness. The ratio represents the absolute change in price over a period relative to the total bar-by-bar change (volatility) within that period:

Change = Abs(Price − Price N bars ago)
Volatility = Sum of Abs(Price − Price 1 bar ago) over N bars
ER = Change / Volatility
An ER value near 1 means that the total bar-by-bar change across the period is close to the overall change, indicating efficient price movement in one direction. A value near 0 means that the overall change is much smaller than the total bar-by-bar change, indicating choppy or inefficient movement over the period.

Calculate initial smoothing factors
KAMA uses two separate EMA smoothing factors to determine its smoothing response. One factor corresponds to the slowest response for inefficient price movements, and the other corresponds to the fastest response for efficient movements:

Slow SC = 2 / (Slow Length + 1)
Fast SC = 2 / (Fast Length + 1)
Calculate the final smoothing factor
The indicator determines the final smoothing factor by mixing the fast and slow smoothing factors based on the value of ER, then squaring the result:

SC = (ER × (Fast SC - Slow SC) + Slow SC)²
This smoothing factor causes the moving average to converge toward the market price at a faster rate when ER is high, and at a slower rate when ER is low. Squaring the factor significantly reduces the moving average's responsiveness during periods of choppy or inefficient price movement.

Inputs

Source
The source series for which to calculate the adaptive moving average.

ER length
The number of bars to analyze for the Efficiency Ratio. Use a lower value to make the average's smoothing behavior change in response to only very recent price fluctuations, and a higher value to make the behavior responsive to fluctuations over a larger period.

Fast length
The length for the fast smoothing factor, which controls the fastest possible response of the moving average.

Slow length
The length for the slow smoothing factor, which controls the slowest possible response of the moving average.

Timeframe
Sets the timeframe that the indicator uses for its calculations. The "Wait for timeframe closes" checkbox below determines whether the indicator shows results only when a bar on the specified timeframe closes. See the Leveraging multi-timeframe analysis article to learn more.
If you are not willing to take risk the unusual, you will have to settle for the ordinary.
Don't wait for extraordinary opportunities. Seize common occasions and make them great. Weak men wait for opportunities; strong men make them

Re: TradingView Indicators to MT4 Indicators

756
TRADERSM wrote: Sat Apr 18, 2026 10:24 pm Dear Coders can you make this indicator as same as Trading View it will be very helpful thankyou

https://www.tradingview.com/support/sol ... 000773012/

Kaufman's Adaptive Moving Average (KAMA), introduced by Perry J. Kaufman in 1995, is a moving average that dynamically adjusts its smoothing behavior to the relative noise or choppiness in market movements.

Kaufman designed the indicator as a generalized trend-following solution based on the idea that faster averages are more useful for tracking trends when the market price is moving quickly in one direction, and slower averages are better for avoiding whipsaws during periods of choppiness and volatility. As such, KAMA follows the market price at a faster rate when movements are efficient and directional, and at a slower rate when movements are choppy or inefficient.

Traders often analyze movements in KAMA to identify trends and choppy market conditions, and use the crossings between KAMA and price or other moving averages to find potential turning points and signals.


Calculation
At its core, KAMA uses the same general structure as an exponential moving average (EMA):

MA = SC × Price + (1 − SC) × Previous MA
Where:

SC is the smoothing factor, sometimes referred to as the smoothing constant, which is a value between 0 and 1 that controls the rate at which the moving average follows the market price. The lower the factor, the less sensitive the moving average becomes to short-term price changes.
Previous MA is the EMA value on the previous bar.
A traditional EMA calculates a fixed smoothing factor of 2 / (length + 1), where the length value controls the period for which the average responds significantly to changes in price.

By contrast, KAMA calculates a dynamic factor based on the estimated efficiency of market movements. Below are the steps that the indicator performs to calculate the smoothing factor.

Calculate the Efficiency Ratio
KAMA uses Kaufman's Efficiency Ratio (ER) to control its responsiveness. The ratio represents the absolute change in price over a period relative to the total bar-by-bar change (volatility) within that period:

Change = Abs(Price − Price N bars ago)
Volatility = Sum of Abs(Price − Price 1 bar ago) over N bars
ER = Change / Volatility
An ER value near 1 means that the total bar-by-bar change across the period is close to the overall change, indicating efficient price movement in one direction. A value near 0 means that the overall change is much smaller than the total bar-by-bar change, indicating choppy or inefficient movement over the period.

Calculate initial smoothing factors
KAMA uses two separate EMA smoothing factors to determine its smoothing response. One factor corresponds to the slowest response for inefficient price movements, and the other corresponds to the fastest response for efficient movements:

Slow SC = 2 / (Slow Length + 1)
Fast SC = 2 / (Fast Length + 1)
Calculate the final smoothing factor
The indicator determines the final smoothing factor by mixing the fast and slow smoothing factors based on the value of ER, then squaring the result:

SC = (ER × (Fast SC - Slow SC) + Slow SC)²
This smoothing factor causes the moving average to converge toward the market price at a faster rate when ER is high, and at a slower rate when ER is low. Squaring the factor significantly reduces the moving average's responsiveness during periods of choppy or inefficient price movement.

Inputs

Source
The source series for which to calculate the adaptive moving average.

ER length
The number of bars to analyze for the Efficiency Ratio. Use a lower value to make the average's smoothing behavior change in response to only very recent price fluctuations, and a higher value to make the behavior responsive to fluctuations over a larger period.

Fast length
The length for the fast smoothing factor, which controls the fastest possible response of the moving average.

Slow length
The length for the slow smoothing factor, which controls the slowest possible response of the moving average.

Timeframe
Sets the timeframe that the indicator uses for its calculations. The "Wait for timeframe closes" checkbox below determines whether the indicator shows results only when a bar on the specified timeframe closes. See the Leveraging multi-timeframe analysis article to learn more.
This average is also in my average pack, but without extras fast,slow,power inputs ( it is hardcoded ).
I use this function and made this indicator.
These users thanked the author kvak for the post (total 4):
RodrigoRT7, TRADERSM, Jimmy, Krunal Gajjar
"fear moves faster than greed"

Re: TradingView Indicators to MT4 Indicators

758
kvak wrote: Sun Apr 19, 2026 6:38 am This average is also in my average pack, but without extras fast,slow,power inputs ( it is hardcoded ).
I use this function and made this indicator.
Thankyou my friend
These users thanked the author TRADERSM for the post:
kvak
If you are not willing to take risk the unusual, you will have to settle for the ordinary.
Don't wait for extraordinary opportunities. Seize common occasions and make them great. Weak men wait for opportunities; strong men make them

Re: TradingView Indicators to MT4 Indicators

759
here is a not-so-bad arrow indicator that I converted using Grok from TV
https://www.tradingview.com/script/Pq5g ... ily-Chart/

I didn't check the code so use it with a grain of salt
These users thanked the author ionone for the post (total 9):
Akela, Jimmy, forexjoe85, FredericoA, elvenso, Tur005, kvak, Karvamaha, RodrigoRT7
Scalping the Century TimeFrame since 1999

Re: TradingView Indicators to MT4 Indicators

760
Liquidity Delta Profiler


Dear Coders.
Help convert this TV Script indicator to MT4 please 🙏

These indicator is Combine of Supply & Demand with ICT - Liquidity Zones Concept based of Volume (Buyers & Sellers)

More Better and Usefully than 'Supply and Demand' OR 'ICT - Liquidity Zones' indicator's stand alone.

The Liquidity Delta Profiler indicator identifies major buy-side and sell-side liquidity levels and visualizes internal buyer/seller activity through volume delta-filled quadrants, providing a complete toolkit for analyzing liquidity sweeps and potential reversals.

The indicator utilizes a pivot-based detection system. When a swing high is confirmed, a Buy-Side Liquidity (BSL) zone is created; a swing low creates a Sell-Side Liquidity (SSL) zone.

The script includes "Filter Overlaps" logic to ensure chart clarity. If a new, more significant pivot forms within the range of an existing active zone, the tool can automatically update to the most relevant level, preventing the clutter of multiple overlapping boxes.



Code: Select all

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=6
indicator("Liquidity Delta Profiler [LuxAlgo]", "LuxAlgo - Liquidity Delta Profiler", overlay = true, max_boxes_count = 500, max_labels_count = 500)

//---------------------------------------------------------------------------------------------------------------------}
// Constants
//---------------------------------------------------------------------------------------------------------------------{
color DATA              = #DBDBDB
color HEADERS           = #808080
color BACKGROUND        = #161616
color BORDERS           = #2E2E2E

string TOP_RIGHT        = 'Top Right'
string BOTTOM_RIGHT     = 'Bottom Right'
string BOTTOM_LEFT      = 'Bottom Left'

string TINY             = 'Tiny'
string SMALL            = 'Small'
string NORMAL           = 'Normal'
string LARGE            = 'Large'
string HUGE             = 'Huge'

string DASHBOARD_GROUP  = 'Dashboard'

//---------------------------------------------------------------------------------------------------------------------}
// Settings
//---------------------------------------------------------------------------------------------------------------------{
length = input.int(15, "Pivot Length", minval = 2, tooltip = "Lookback and lookforward length for detecting major swing highs/lows.")
maxZones = input.int(10, "Max Zones per Type", minval = 1, maxval = 40, tooltip = "Maximum number of active/historical buy and sell zones to keep on the chart.")
showSwept = input.bool(true, "Show Swept Zones", tooltip = "Keep zones visible (with dashed outlines and reduced opacity) after price sweeps them.")
filterOverlaps = input.bool(true, "Filter Overlapping Zones", tooltip = "When enabled, prevents creating new zones that overlap with existing active zones. Only the most significant (highest for BSL, lowest for SSL) level is kept.")

showDecay = input.bool(true, "Show Zone Decay", tooltip = "Displays the remaining 'health' of active zones based on the volume traded inside them. Health drops from 100% to 0%.")
zoneCapacity = input.float(5.0, "Zone Volume Capacity", minval = 1.0, tooltip = "Multiplier for average volume to determine how much volume a zone can absorb before reaching 0% health.")

enableReversals = input.bool(true, "Enable Reversal Detection", group = "Reversals", tooltip = "Detects unusual volume delta patterns during liquidity sweeps to signal potential reversals. Plots a bubble with signal type (ABS, EXH, DIV, REJ) and hover tooltip.")

dashboardInput          = input.bool(   true,       'Show Dashboard',    group = DASHBOARD_GROUP, tooltip = 'Enable or disable the dashboard.')
dashboardPositionInput  = input.string( TOP_RIGHT,  'Position',          group = DASHBOARD_GROUP, tooltip = 'Select the dashboard location.', options = [TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT])
dashboardSizeInput      = input.string( TINY,       'Size',              group = DASHBOARD_GROUP, tooltip = 'Select the dashboard size.', options = [TINY, SMALL, NORMAL, LARGE, HUGE])
dashboardWindowInput    = input.int(    10,         'Eval Window (Bars)', group = DASHBOARD_GROUP, minval = 1, tooltip = 'Maximum number of bars to wait for the reversal to occur.')
dashboardHoldInput      = input.int(    3,          'Hold Time (Bars)',   group = DASHBOARD_GROUP, minval = 1, tooltip = 'Number of consecutive bars price must stay in profit (opposite direction) to be considered a win.')
dashboardHighlightInput = input.bool(   false,      'Highlight Eval Bars',group = DASHBOARD_GROUP, tooltip = 'Highlights bars actively evaluated. Yellow = Evaluating, Aqua = Holding in profit.')

bslColor = input.color(color.new(#f23645, 0), "BSL Outline Color", group = "Style", tooltip = "Color for Buy-Side Liquidity zones (above price).")
sslColor = input.color(color.new(#089981, 0), "SSL Outline Color", group = "Style", tooltip = "Color for Sell-Side Liquidity zones (below price).")

buyDeltaColor = input.color(color.new(#089981, 0), "Buy Delta Fill", group = "Style", tooltip = "Fill color when buy volume dominates a zone quadrant.")
sellDeltaColor = input.color(color.new(#f23645, 0), "Sell Delta Fill", group = "Style", tooltip = "Fill color when sell volume dominates a zone quadrant.")

//---------------------------------------------------------------------------------------------------------------------}
// Types
//---------------------------------------------------------------------------------------------------------------------{
type Zone
    float top
    float bottom
    int left
    int right
    bool swept
    bool signaled
    box[] quads
    float[] deltas
    box outline
    float volumeTraded
    float capacity
    bool wasHit
    label decayLabel

type Trade
    string type
    int dir
    float entry
    int entryBar
    bool active
    bool won
    int consecBars

//---------------------------------------------------------------------------------------------------------------------}
// Variables
//---------------------------------------------------------------------------------------------------------------------{
var Zone[] bslZones = array.new<Zone>()
var Zone[] sslZones = array.new<Zone>()

var activeTrades = array.new<Trade>()

var int absTotal = 0
var int absWins = 0
var int exhTotal = 0
var int exhWins = 0
var int divTotal = 0
var int divWins = 0
var int rejTotal = 0
var int rejWins = 0

var string parsedDashboardPosition = switch dashboardPositionInput
    TOP_RIGHT       => position.top_right
    BOTTOM_RIGHT    => position.bottom_right
    BOTTOM_LEFT     => position.bottom_left
    => position.top_right

var string parsedDashboardSize     = switch dashboardSizeInput
    TINY            => size.tiny
    SMALL           => size.small
    NORMAL          => size.normal
    LARGE           => size.large
    HUGE            => size.huge
    => size.normal

var table t_able = table.new(parsedDashboardPosition, 4, 11, bgcolor = dashboardInput ? BACKGROUND : na, border_width = 0, frame_color = dashboardInput ? BORDERS : na, frame_width = 1, force_overlay = true)

//---------------------------------------------------------------------------------------------------------------------}
// Methods / Functions
//---------------------------------------------------------------------------------------------------------------------{
cell(table t_able, int col, int r, string data, color txtColor = color.white, string align = text.align_right, color background = na, float h = 0) => 
    t_able.cell(col, r, data, text_color = txtColor, text_size = parsedDashboardSize, text_halign = align, bgcolor = background, height = h)

divider(table t_able, int r, int lastColumn) =>    
    string rowDivider = '━━━━━━━━━━━━━━━━'
    t_able.merge_cells(0, r, lastColumn, r)
    cell(t_able, 0, r, rowDivider, txtColor = BORDERS, align = text.align_center, h = 0.5)

method evaluateReversals(Zone z, bool isBsl, float barH, float barL, float barC, float barO, float barDelta, float barVol) =>
    if enableReversals and not z.signaled
        float totalD = 0.0
        float absTotalD = 0.0
        for d in z.deltas
            totalD += d
            absTotalD += math.abs(d)
            
        if absTotalD > 0
            int outerIdx = isBsl ? 3 : 0
            float outerD = z.deltas.get(outerIdx)
            
            bool isSweeping = isBsl ? barH > z.top : barL < z.bottom
            bool closesInside = isBsl ? (barC <= z.top and barC >= z.bottom) : (barC >= z.bottom and barC <= z.top)
            float midPoint = (z.top + z.bottom) / 2
            bool closesRejecting = isBsl ? barC < midPoint : barC > midPoint
            
            string signalType = ""
            string tooltipTxt = ""
            float significance = 0.0
            color sigColor = isBsl ? color.red : color.green // Reversing from Resistance is Bearish (Red), from Support is Bullish (Green)
            
            // 1. Absorption at the Extreme (Trap)
            if isSweeping and ((isBsl and outerD < 0) or (not isBsl and outerD > 0))
                float ratio = math.abs(outerD) / (absTotalD + 0.0001)
                if ratio > 0.2
                    signalType := "ABS"
                    tooltipTxt := "Absorption at Extreme\n" + (isBsl ? "Sellers" : "Buyers") + " aggressively absorbed the sweep.\nOuter Quadrant Delta: " + str.tostring(outerD, format.volume)
                    significance := ratio * 2
                    
            // 2. Exhaustion (Dry Sweep)
            if signalType == "" and isSweeping
                float ratio = math.abs(outerD) / (absTotalD + 0.0001)
                if ratio < 0.1
                    signalType := "EXH"
                    tooltipTxt := "Exhaustion (Dry Sweep)\nMinimal volume at the extreme edge.\nOuter Quadrant Delta: " + str.tostring(outerD, format.volume)
                    significance := 1.0 - (ratio * 5)
                    
            // 3. Delta Divergence (FOMO)
            if signalType == "" and closesInside
                float ratio = math.abs(outerD) / (absTotalD + 0.0001)
                if ratio > 0.6 and ((isBsl and outerD > 0) or (not isBsl and outerD < 0))
                    signalType := "DIV"
                    tooltipTxt := "Delta Divergence (FOMO)\nHigh volume trapped at the extreme, but price failed to breakout.\nOuter Quadrant Delta: " + str.tostring(outerD, format.volume)
                    significance := ratio
                    
            // 4. Snapback (Climax + Rejection)
            if signalType == "" and isSweeping and closesRejecting
                float barRatio = math.abs(barDelta) / (barVol + 0.0001)
                if ((isBsl and barDelta < 0) or (not isBsl and barDelta > 0)) and barRatio > 0.2
                    signalType := "REJ"
                    tooltipTxt := "Snapback Rejection\nSweep followed by immediate strong rejection.\nBar Delta: " + str.tostring(barDelta, format.volume)
                    significance := barRatio * 2
        
            // Plot Signal
            if signalType != ""
                z.signaled := true
                alert("Reversal Signal (" + signalType + ") detected at " + str.tostring(barC), alert.freq_once_per_bar)
                
                significance := math.min(math.max(significance, 0.0), 1.0)
                string sSize = size.tiny
                int trans = 50
                
                if significance > 0.7
                    sSize := size.normal
                    trans := 10
                else if significance > 0.4
                    sSize := size.small
                    trans := 30
                    
                color finalColor = color.new(sigColor, trans)
                float yLoc = isBsl ? barH : barL
                string labelStyle = isBsl ? label.style_label_down : label.style_label_up
                
                label.new(bar_index, yLoc, text=signalType, color=finalColor, style=labelStyle, textcolor=color.white, size=sSize, tooltip=tooltipTxt)
                
                // Track Trade Performance
                float entry = barC
                activeTrades.push(Trade.new(signalType, isBsl ? -1 : 1, entry, bar_index, true, false, 0))

method updateVisuals(Zone z, bool isBsl, bool showS, color buyC, color sellC, color bslC, color sslC) =>
    float maxD = 0.0
    for d in z.deltas
        maxD := math.max(maxD, math.abs(d))
    
    for i = 0 to 3
        float d = z.deltas.get(i)
        color c = na
        string txt = ""
        color tColor = na
        if maxD > 0 and math.abs(d) > 0.001
            color baseC = d > 0 ? buyC : sellC
            int trans = z.swept ? 90 : 100 - int((math.abs(d) / maxD) * 60)
            c := color.rgb(color.r(baseC), color.g(baseC), color.b(baseC), trans)
            txt := (d > 0 ? "+" : d < 0 ? "-" : "") + str.tostring(math.abs(d), format.volume)
            tColor := color.new(baseC, z.swept ? 50 : 0)
        else
            color baseC = isBsl ? bslC : sslC
            int defaultTrans = 60 + (isBsl ? (3 - i) : i) * 10
            c := color.rgb(color.r(baseC), color.g(baseC), color.b(baseC), z.swept ? 90 : defaultTrans)
            txt := "0"
            tColor := color.new(baseC, z.swept ? 80 : 50)
        
        box q = z.quads.get(i)
        q.set_bgcolor(not showS and z.swept ? na : c)
        q.set_text(not showS and z.swept ? "" : txt)
        q.set_text_color(not showS and z.swept ? na : tColor)
        
        if z.swept
            q.set_border_color(not showS ? na : color.new(isBsl ? bslC : sslC, 80))
            q.set_border_style(line.style_dashed)
        else
            q.set_border_color(color.new(isBsl ? bslC : sslC, 60))
            q.set_border_style(line.style_solid)
            
    if z.swept
        if showS
            z.outline.set_border_style(line.style_dashed)
            z.outline.set_border_color(color.new(isBsl ? bslC : sslC, 80))
        else
            z.outline.set_border_color(na)

barOverlap(float barH, float barL, float qTop, float qBot) =>
    float overlapTop = math.min(barH, qTop)
    float overlapBot = math.max(barL, qBot)
    overlapTop > overlapBot ? (overlapTop - overlapBot) : 0.0

//---------------------------------------------------------------------------------------------------------------------}
// Logic
//---------------------------------------------------------------------------------------------------------------------{
float atr = ta.atr(14)
float ph = ta.pivothigh(high, length, length)
float pl = ta.pivotlow(low, length, length)
float avgVol = nz(ta.sma(volume, length))
if avgVol == 0
    avgVol := 1
float currentZoneCap = avgVol * zoneCapacity

if not na(ph) and bar_index >= length
    int pivotIdx = bar_index - length
    float pHigh = high[length]
    float pBot = math.max(close[length], open[length])
    if pHigh - pBot < atr[length] * 0.1
        pBot := pHigh - atr[length] * 0.1
        
    bool skip = false
    if filterOverlaps and bslZones.size() > 0
        for i = bslZones.size() - 1 to 0
            if i < bslZones.size()
                Zone ex = bslZones.get(i)
                if not ex.swept
                    bool overlaps = math.max(pBot, ex.bottom) <= math.min(pHigh, ex.top)
                    if overlaps
                        if pHigh > ex.top
                            for b in ex.quads
                                b.delete()
                            ex.outline.delete()
                            ex.decayLabel.delete()
                            bslZones.remove(i)
                        else
                            skip := true
                            break
                            
    if not skip
        box[] quads = array.new<box>(4)
        float[] deltas = array.new<float>(4, 0.0)
        float step = (pHigh - pBot) / 4
        for i = 0 to 3
            float qBot = pBot + i * step
            float qTop = pBot + (i + 1) * step
            color baseC = bslColor
            int trans = 60 + (3 - i) * 10
            color c = color.rgb(color.r(baseC), color.g(baseC), color.b(baseC), trans)
            
            float gap = step * 0.05
            float bTop = qTop - gap
            float bBot = qBot + gap
            if i == 0
                bBot := qBot
            if i == 3
                bTop := qTop
                
            quads.set(i, box.new(pivotIdx, bTop, pivotIdx, bBot, border_color = color.new(baseC, 60), bgcolor = c, text = "0", text_color = color.new(baseC, 50), text_halign = text.align_right, text_size = size.auto))
        
        box outline = box.new(pivotIdx, pHigh, pivotIdx, pBot, border_color = color.new(bslColor, 80), bgcolor = na)
        label dLabel = label.new(bar_index, pBot + (pHigh - pBot)/2, text = "100%", style = label.style_label_left, color = color.new(bslColor, 80), textcolor = color.white, size = size.small)
        if not showDecay
            dLabel.set_x(na)
            
        Zone z = Zone.new(pHigh, pBot, pivotIdx, pivotIdx, false, false, quads, deltas, outline, 0.0, currentZoneCap, false, dLabel)
        bslZones.unshift(z)
        if bslZones.size() > maxZones
            Zone removed = bslZones.pop()
            for b in removed.quads
                b.delete()
            removed.outline.delete()
            removed.decayLabel.delete()

if not na(pl) and bar_index >= length
    int pivotIdx = bar_index - length
    float pLow = low[length]
    float pTop = math.min(close[length], open[length])
    if pTop - pLow < atr[length] * 0.1
        pTop := pLow + atr[length] * 0.1
        
    bool skip = false
    if filterOverlaps and sslZones.size() > 0
        for i = sslZones.size() - 1 to 0
            if i < sslZones.size()
                Zone ex = sslZones.get(i)
                if not ex.swept
                    bool overlaps = math.max(pLow, ex.bottom) <= math.min(pTop, ex.top)
                    if overlaps
                        if pLow < ex.bottom
                            for b in ex.quads
                                b.delete()
                            ex.outline.delete()
                            ex.decayLabel.delete()
                            sslZones.remove(i)
                        else
                            skip := true
                            break
                            
    if not skip
        box[] quads = array.new<box>(4)
        float[] deltas = array.new<float>(4, 0.0)
        float step = (pTop - pLow) / 4
        for i = 0 to 3
            float qBot = pLow + i * step
            float qTop = pLow + (i + 1) * step
            color baseC = sslColor
            int trans = 60 + i * 10
            color c = color.rgb(color.r(baseC), color.g(baseC), color.b(baseC), trans)
            
            float gap = step * 0.05
            float bTop = qTop - gap
            float bBot = qBot + gap
            if i == 0
                bBot := qBot
            if i == 3
                bTop := qTop
                
            quads.set(i, box.new(pivotIdx, bTop, pivotIdx, bBot, border_color = color.new(baseC, 60), bgcolor = c, text = "0", text_color = color.new(baseC, 50), text_halign = text.align_right, text_size = size.auto))
        
        box outline = box.new(pivotIdx, pTop, pivotIdx, pLow, border_color = color.new(sslColor, 80), bgcolor = na)
        label dLabel = label.new(bar_index, pLow + (pTop - pLow)/2, text = "100%", style = label.style_label_left, color = color.new(sslColor, 80), textcolor = color.white, size = size.small)
        if not showDecay
            dLabel.set_x(na)
            
        Zone z = Zone.new(pTop, pLow, pivotIdx, pivotIdx, false, false, quads, deltas, outline, 0.0, currentZoneCap, false, dLabel)
        sslZones.unshift(z)
        if sslZones.size() > maxZones
            Zone removed = sslZones.pop()
            for b in removed.quads
                b.delete()
            removed.outline.delete()
            removed.decayLabel.delete()

float vol = nz(volume)
float totalRange = high - low
float barDelta = totalRange == 0 ? 0 : vol * (close - open) / totalRange

if bslZones.size() > 0
    for i = bslZones.size() - 1 to 0
        if i < bslZones.size()
            Zone z = bslZones.get(i)
            if not z.swept
                z.right := bar_index
                z.outline.set_right(bar_index)
                for b in z.quads
                    b.set_right(bar_index)
                
                bool hit = false
                float step = (z.top - z.bottom) / 4
                for j = 0 to 3
                    float qBot = z.bottom + j * step
                    float qTop = z.bottom + (j + 1) * step
                    float overlap = barOverlap(high, low, qTop, qBot)
                    if overlap > 0
                        hit := true
                        float overlapRatio = totalRange == 0 ? 0 : overlap / totalRange
                        float qDelta = barDelta * overlapRatio
                        z.deltas.set(j, z.deltas.get(j) + qDelta)
                        z.volumeTraded += vol * overlapRatio
                
                if hit and not z.wasHit
                    alert("Price testing Resistance BSL Zone at " + str.tostring(z.top), alert.freq_once_per_bar)
                    
                if high > z.top
                    z.swept := true
                    alert("Resistance BSL Zone Swept at " + str.tostring(z.top), alert.freq_once_per_bar)
                
                if not z.swept
                    if showDecay
                        int health = int(math.max(0, 100 - (z.volumeTraded / z.capacity * 100)))
                        z.decayLabel.set_x(bar_index + 1)
                        z.decayLabel.set_text(str.tostring(health) + "%")
                    else
                        z.decayLabel.set_x(na)
                else
                    z.decayLabel.delete()
                    
                z.wasHit := hit
                
                if hit or z.swept
                    z.evaluateReversals(true, high, low, close, open, barDelta, vol)
                    z.updateVisuals(true, showSwept, buyDeltaColor, sellDeltaColor, bslColor, sslColor)

if sslZones.size() > 0
    for i = sslZones.size() - 1 to 0
        if i < sslZones.size()
            Zone z = sslZones.get(i)
            if not z.swept
                z.right := bar_index
                z.outline.set_right(bar_index)
                for b in z.quads
                    b.set_right(bar_index)
                
                bool hit = false
                float step = (z.top - z.bottom) / 4
                for j = 0 to 3
                    float qBot = z.bottom + j * step
                    float qTop = z.bottom + (j + 1) * step
                    float overlap = barOverlap(high, low, qTop, qBot)
                    if overlap > 0
                        hit := true
                        float overlapRatio = totalRange == 0 ? 0 : overlap / totalRange
                        float qDelta = barDelta * overlapRatio
                        z.deltas.set(j, z.deltas.get(j) + qDelta)
                        z.volumeTraded += vol * overlapRatio
                
                if hit and not z.wasHit
                    alert("Price testing Support SSL Zone at " + str.tostring(z.bottom), alert.freq_once_per_bar)
                    
                if low < z.bottom
                    z.swept := true
                    alert("Support SSL Zone Swept at " + str.tostring(z.bottom), alert.freq_once_per_bar)
                
                if not z.swept
                    if showDecay
                        int health = int(math.max(0, 100 - (z.volumeTraded / z.capacity * 100)))
                        z.decayLabel.set_x(bar_index + 1)
                        z.decayLabel.set_text(str.tostring(health) + "%")
                    else
                        z.decayLabel.set_x(na)
                else
                    z.decayLabel.delete()
                    
                z.wasHit := hit
                
                if hit or z.swept
                    z.evaluateReversals(false, high, low, close, open, barDelta, vol)
                    z.updateVisuals(false, showSwept, buyDeltaColor, sellDeltaColor, bslColor, sslColor)

// Process Active Trades
color barHighlight = na
if activeTrades.size() > 0
    for i = activeTrades.size() - 1 to 0
        if i < activeTrades.size()
            Trade t = activeTrades.get(i)
            if t.active
                if bar_index > t.entryBar // Wait until the next bar to start evaluating
                    bool inProfit = (t.dir == 1 and close > t.entry) or (t.dir == -1 and close < t.entry)
                    
                    if inProfit
                        t.consecBars += 1
                        if na(barHighlight) or barHighlight == color.yellow
                            barHighlight := color.aqua
                    else
                        t.consecBars := 0
                        if na(barHighlight)
                            barHighlight := color.yellow
                        
                    if t.consecBars >= dashboardHoldInput
                        t.active := false
                        t.won := true
                    else if bar_index - t.entryBar >= dashboardWindowInput
                        t.active := false // Time ran out
                    
                    if not t.active
                        if t.type == "ABS"
                            absTotal += 1
                            if t.won
                                absWins += 1
                        else if t.type == "EXH"
                            exhTotal += 1
                            if t.won
                                exhWins += 1
                        else if t.type == "DIV"
                            divTotal += 1
                            if t.won
                                divWins += 1
                        else if t.type == "REJ"
                            rejTotal += 1
                            if t.won
                                rejWins += 1
                        activeTrades.remove(i)

barcolor(dashboardHighlightInput ? barHighlight : na)

if barstate.islast
    if dashboardInput
        t_able.merge_cells(0, 0, 3, 0)
        cell(t_able, 0, 0, 'Reversal Performance (Time-Based)', txtColor = DATA, align = text.align_center)
        
        divider(t_able, 1, 3)
        
        cell(t_able, 0, 2, 'Signal', txtColor = HEADERS, align = text.align_left)
        cell(t_able, 1, 2, 'Total',  txtColor = HEADERS, align = text.align_right)
        cell(t_able, 2, 2, 'Wins',   txtColor = HEADERS, align = text.align_right)
        cell(t_able, 3, 2, 'Win %',  txtColor = HEADERS, align = text.align_right)
        
        divider(t_able, 3, 3)
        
        float absRate = absTotal > 0 ? (absWins / absTotal) * 100 : 0
        cell(t_able, 0, 4, 'ABS', txtColor = DATA, align = text.align_left)
        cell(t_able, 1, 4, str.tostring(absTotal), txtColor = DATA, align = text.align_right)
        cell(t_able, 2, 4, str.tostring(absWins), txtColor = DATA, align = text.align_right)
        cell(t_able, 3, 4, str.tostring(absRate, '#.##') + '%', txtColor = absTotal > 0 ? (absRate >= 50 ? color.green : color.red) : DATA, align = text.align_right)
        
        divider(t_able, 5, 3)
        
        float exhRate = exhTotal > 0 ? (exhWins / exhTotal) * 100 : 0
        cell(t_able, 0, 6, 'EXH', txtColor = DATA, align = text.align_left)
        cell(t_able, 1, 6, str.tostring(exhTotal), txtColor = DATA, align = text.align_right)
        cell(t_able, 2, 6, str.tostring(exhWins), txtColor = DATA, align = text.align_right)
        cell(t_able, 3, 6, str.tostring(exhRate, '#.##') + '%', txtColor = exhTotal > 0 ? (exhRate >= 50 ? color.green : color.red) : DATA, align = text.align_right)
        
        divider(t_able, 7, 3)
        
        float divRate = divTotal > 0 ? (divWins / divTotal) * 100 : 0
        cell(t_able, 0, 8, 'DIV', txtColor = DATA, align = text.align_left)
        cell(t_able, 1, 8, str.tostring(divTotal), txtColor = DATA, align = text.align_right)
        cell(t_able, 2, 8, str.tostring(divWins), txtColor = DATA, align = text.align_right)
        cell(t_able, 3, 8, str.tostring(divRate, '#.##') + '%', txtColor = divTotal > 0 ? (divRate >= 50 ? color.green : color.red) : DATA, align = text.align_right)
        
        divider(t_able, 9, 3)
        
        float rejRate = rejTotal > 0 ? (rejWins / rejTotal) * 100 : 0
        cell(t_able, 0, 10, 'REJ', txtColor = DATA, align = text.align_left)
        cell(t_able, 1, 10, str.tostring(rejTotal), txtColor = DATA, align = text.align_right)
        cell(t_able, 2, 10, str.tostring(rejWins), txtColor = DATA, align = text.align_right)
        cell(t_able, 3, 10, str.tostring(rejRate, '#.##') + '%', txtColor = rejTotal > 0 ? (rejRate >= 50 ? color.green : color.red) : DATA, align = text.align_right)
    else
        t_able.clear(0, 0, 3, 10)

//---------------------------------------------------------------------------------------------------------------------}


** More Detail Info :
https://www.tradingview.com/script/irBB ... r-LuxAlgo/
These users thanked the author Tsar for the post (total 3):
Freedom35FPS, Tur005, RodrigoRT7
Always looking the GREAT, never left GOOD Point...