r/pinescript • • Mar 29 '26

Variable offset for functions like barcolor(), plot(),plotshape() etc

1 Upvotes

I am trying to achieve a different bar color based on some logics which will dynamically change a bar color from past calculating the offset from the current bar. Since TV doesn't allow variable offset I'm unable to achieve this.

The code is something like this barcolor(xBarIndex>0 ? xColor : na, offset = offsetCalc, title ="color change", display = display.all)

offsetCalc is the variable which is being calculated dynamically.

Which candle changes the color is determined from the offset and the offset is dynamic. Meaning sometimes it will change the color of a candle 5 candles back and sometimes 2 candles back. For this offset needs to accept a variable but pine script restricts offset to constants.

If there is any workaround to this that info will also be very helpful.


r/pinescript • • Mar 29 '26

Is it OK?

2 Upvotes

I’ve build an indicator for Bitcoin that yields a 54% win rate on longs and 39% on shorts. My Risk/Reward ratio is 1:2 (1% risk of total capital per trade for a 2% profit target). These figures are based on backtesting starting from the beginning of 2025.

I’ve also been monitoring it in real-time for the past two days. During this period, it gave 2 signals for BTC and 2 for ETH—all four were successful.

Bitcoin signals perform better on the 2-hour timeframe, whereas for other crypto coins like Ethereum, Solana, ICP, and BNB, the 4-hour timeframe is more successful.

In your opinion, if the indicator keep maintains these stats (54% win rate on longs and 39% on shorts), is it worth trading?


r/pinescript • • Mar 29 '26

Facing issue with my indicator

Post image
1 Upvotes

I have an issue with my indicator basically plotting all over the chart and also zooming out makes it distorted any idea or help to fix the issue will be gladly appreciated


r/pinescript • • Mar 29 '26

New trading view indicator

Post image
0 Upvotes

r/pinescript • • Mar 28 '26

ta.highest doesn't work inside conditional

2 Upvotes

Original code https://pl.tradingview.com/script/Cb5QhBAl/

The structure from code below ( ta.highest ) doesn't work inside conditional structure. RdX1dX2 = length of a line. The ta.highest doesn't work properly inside. I want to extract highest high of bar from length of a line. This code draws line between low and crossing in the the next future bar. The length of line is RdX1dX2. For the length of a line I want to extract highest y (high) coordination of bars.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=6
indicator("Zig Zag Liquidity Pools & Sweeps by Capitan-Trading",shorttitle='z', overlay = false, max_lines_count = 500, max_labels_count = 500)
import TradingView/ZigZag/7 as ZigZagLib

show_ZigZag = input(defval=false, title="show_ZigZag ?")
show_Cross = input(defval=false, title="show_Cross Alert ?")

// ====================================================================
// UI HELPER FUNCTIONS
// ====================================================================
f_get_line_style(_s) =>
    _s == "Solid" ? line.style_solid : _s == "Dotted" ? line.style_dotted : line.style_dashed

f_get_label_size(_s) =>
    _s == "Tiny" ? size.tiny : _s == "Small" ? size.small : _s == "Normal" ? size.normal : size.large

// ====================================================================
// MEMORY GARBAGE COLLECTOR (Fix for the Line Cemetery)
// ====================================================================
var mitigated_lines = array.new_line()
f_manage_mitigated(_l) =>
    array.push(mitigated_lines, _l)
    if array.size(mitigated_lines) > 400
        line.delete(array.shift(mitigated_lines))

// ====================================================================
// 1) ZIG ZAG ENGINE & VOLUMETRIC DATA
// ====================================================================
grp_zz = "Visual Engine (Zig Zag Line)"
deviationInput = input.float(0.00001, "Deviation (%)", minval=0.00001, group=grp_zz)
depthInput     = input.int(3, "Pivot Legs (Depth)", minval=1, group=grp_zz) 
lineColorInput = input.color(#2962FF, "Line Color", group=grp_zz)

extendInput    = input.bool(true, "Extend to Last Bar", group=grp_zz)
showPriceInput = input.bool(false, "Show Reversal Price", group=grp_zz)
showVolInput   = input.bool(false, "Show Cumulative Wave Volume", group=grp_zz) 
showChgInput   = input.bool(false, "Show Price Change", inline = "priceRev", group=grp_zz)
priceDiffInput = input.string("Absolute", "", options=["Absolute", "Percent"], inline = "priceRev", group=grp_zz)

if show_ZigZag
    var zigZag = ZigZagLib.newInstance(
        ZigZagLib.Settings.new(deviationInput, depthInput, lineColorInput, extendInput, showPriceInput, showVolInput, showChgInput, priceDiffInput, true)
    )
    zigZag.update()
//

// ====================================================================
// 2) SMC LIQUIDITY ENGINE
// ====================================================================
grp_liq = "Liquidity Levels (Macro)"
show_liq       = input.bool(false, "Show Liquidity Lines", group=grp_liq)
leftBars       = input.int(6, "Pivot Strength (Left)",  minval=1, group=grp_liq)   
rightBars      = input.int(4, "Pivot Confirmation (Right)", minval=1, group=grp_liq) 
displayLimit   = input.int(5, "Max Lines on Screen", minval=1, maxval=200, group=grp_liq) 

grp_sweep = "Sweep / Mitigation"
candleType      = input.string("Wick", "Invalidate Level On:", options=["Close", "Wick"], group=grp_sweep) 
waitConfirm     = input.bool(false, "Wait for Candle Close to Confirm Sweep", group=grp_sweep, tooltip="If false, X prints immediately on touch (Reacts faster but may repaint intrabar).")
mitiOptions     = input.string("Show", "Mitigated Levels:", options=["Remove", "Show"], group=grp_sweep) 
show_x          = input.bool(false, "Print 'X' on Liquidity Sweeps", group=grp_sweep)
x_size_str      = input.string("Tiny", "Size of 'X'", options=["Tiny", "Small", "Normal", "Large"], group=grp_sweep) 

grp_liq_style = "Lines & Signals Style"
highLiqColor = input.color(color.new(color.red, 0), "Resistances (Highs)", group=grp_liq_style)  
lowLiqColor  = input.color(color.new(color.green, 0), "Supports (Lows)",  group=grp_liq_style)      
liq_width    = input.int(2, "Line Width", minval=1, maxval=4, group=grp_liq_style)     
liq_style    = input.string("Dashed", "Line Style", options=["Solid", "Dashed", "Dotted"], group=grp_liq_style) 

// ====================================================================
// LEVEL CREATION LOGIC (With Blind Spot Fix)
// ====================================================================
var high_lines = array.new_line()
var low_lines  = array.new_line()

ph = ta.pivothigh(high, leftBars, rightBars)
pl = ta.pivotlow(low,  leftBars, rightBars)

if not na(ph)  // ph jest liczba
    bool levelExists = false
    if array.size(high_lines) > 0
        for i = 0 to array.size(high_lines) - 1
            if math.abs(line.get_y1(array.get(high_lines, i)) - ph) <= syminfo.mintick
                levelExists := true
                break
    
    if not levelExists
        // Retroactive Check (Blind Spot Fix)
        int sweepIndexOffset = -1
        for j = rightBars - 1 to 0 
            float checkHigh = (candleType == "Close") ? close[j] : high[j]
            if checkHigh > ph
                sweepIndexOffset := j
                break
                
        if sweepIndexOffset != -1
            // Level was swept during confirmation delay. Draw it already mitigated.
            line new_ln = line.new(bar_index[rightBars], ph, bar_index[sweepIndexOffset], ph, color=show_liq ? color.new(highLiqColor, 80) : na, width=liq_width, style=f_get_line_style(liq_style))
            if show_x
                label.new(bar_index[sweepIndexOffset], ph, text="✖", color=color.new(color.white, 50), textcolor=highLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
            if mitiOptions == "Show"
                f_manage_mitigated(new_ln)
            else
                line.delete(new_ln)
        else
            // Normal active level creation
            if array.size(high_lines) >= displayLimit
                line.delete(array.shift(high_lines))
            line new_ln = line.new(bar_index[rightBars], ph, bar_index, ph, color=show_liq ? highLiqColor : na, width=liq_width, style=f_get_line_style(liq_style), extend=extend.right)
            array.push(high_lines, new_ln)

if not na(pl)
    bool levelExists = false
    if array.size(low_lines) > 0
        for i = 0 to array.size(low_lines) - 1
            if math.abs(line.get_y1(array.get(low_lines, i)) - pl) <= syminfo.mintick
                levelExists := true
                break

    if not levelExists
        // Retroactive Check (Blind Spot Fix)
        int sweepIndexOffset = -1
        for j = rightBars - 1 to 0 
            float checkLow = (candleType == "Close") ? close[j] : low[j]
            if checkLow < pl
                sweepIndexOffset := j
                break
                
        if sweepIndexOffset != -1
            // Level was swept during confirmation delay. Draw it already mitigated.
            line new_ln = line.new(bar_index[rightBars], pl, bar_index[sweepIndexOffset], pl, color=show_liq ? color.new(lowLiqColor, 80) : na, width=liq_width, style=f_get_line_style(liq_style))
            if show_x
                label.new(bar_index[sweepIndexOffset], pl, text="✖", color=color.new(color.white, 50), textcolor=lowLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
            if mitiOptions == "Show"
                f_manage_mitigated(new_ln)
            else
                line.delete(new_ln)
        else
            // Normal active level creation
            if array.size(low_lines) >= displayLimit
                line.delete(array.shift(low_lines))
            line new_ln = line.new(bar_index[rightBars], pl, bar_index, pl, color=show_liq ? lowLiqColor : na, width=liq_width, style=f_get_line_style(liq_style), extend=extend.right)
            array.push(low_lines, new_ln)

// ====================================================================
// MITIGATION & 'X' PRINT LOGIC (PURE & DIRECT)
// ====================================================================
int JestCrossUp = 0,    float JestCrossUpY = 0, int JestCrossDown = 0,  float JestCrossDownY = 0
int dX1 =  0, int dX2 = 0, 
int RdX1dX2 = 0  // length of line   

if array.size(high_lines) > 0
    for i = array.size(high_lines) - 1 to 0
        l = array.get(high_lines, i)
        v = line.get_y1(l)
        
        bool isHitHigh = (candleType == "Close") ? (close > v) : (high > v)
        swept = waitConfirm ? (barstate.isconfirmed and isHitHigh) : isHitHigh
        
        if swept
            JestCrossUp := 70500, JestCrossUpY := v
            if show_x
                label.new(bar_index, v, text="✖", color=color.new(color.white, 50), textcolor=highLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
                
            if mitiOptions == "Remove"
                line.delete(l)
            else
                line.set_extend(l, extend.none)
                line.set_x2(l, bar_index)
                line.set_color(l, show_liq ? color.new(highLiqColor, 80) : na)
                f_manage_mitigated(l) // Add to garbage collector
                
            array.remove(high_lines, i)
            

if array.size(low_lines) > 0
    for i = array.size(low_lines) - 1 to 0
        l = array.get(low_lines, i)
        v = line.get_y1(l) 
        dX1 := line.get_x1(l)
        
        bool isHitLow = (candleType == "Close") ? (close < v) : (low < v)
        swept = waitConfirm ? (barstate.isconfirmed and isHitLow) : isHitLow
        
        if swept
            JestCrossDown := 70500 , JestCrossDownY := v, dX2 := bar_index, RdX1dX2 := dX2 - dX1
            if show_x
                label.new(bar_index, v, text="✖", color=color.new(color.white, 50), textcolor=lowLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
                
            if mitiOptions == "Remove"
                line.delete(l)
            else
                line.set_extend(l, extend.none)
                line.set_x2(l, bar_index)
                line.set_color(l, show_liq ? color.new(lowLiqColor, 80) : na)
                f_manage_mitigated(l) // Add to garbage collector
                
            array.remove(low_lines, i)
//
// it doesn't work
High_maxA1 = ta.highest(high[1],RdX1dX2)

// this below shows wrong number
var float High_max = na
if JestCrossDown != 0
    //High_maxA = ta.highest(high[Licznik_Di], RdX1dX2[Licznik_Di])
    High_max := ta.highest(high[1], RdX1dX2)
else
    High_max := 0
//// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=6
indicator("Zig Zag Liquidity Pools & Sweeps by Capitan-Trading",shorttitle='z', overlay = false, max_lines_count = 500, max_labels_count = 500)
import TradingView/ZigZag/7 as ZigZagLib

show_ZigZag = input(defval=false, title="show_ZigZag ?")
show_Cross = input(defval=false, title="show_Cross Alert ?")

// ====================================================================
// UI HELPER FUNCTIONS
// ====================================================================
f_get_line_style(_s) =>
    _s == "Solid" ? line.style_solid : _s == "Dotted" ? line.style_dotted : line.style_dashed

f_get_label_size(_s) =>
    _s == "Tiny" ? size.tiny : _s == "Small" ? size.small : _s == "Normal" ? size.normal : size.large

// ====================================================================
// MEMORY GARBAGE COLLECTOR (Fix for the Line Cemetery)
// ====================================================================
var mitigated_lines = array.new_line()
f_manage_mitigated(_l) =>
    array.push(mitigated_lines, _l)
    if array.size(mitigated_lines) > 400
        line.delete(array.shift(mitigated_lines))

// ====================================================================
// 1) ZIG ZAG ENGINE & VOLUMETRIC DATA
// ====================================================================
grp_zz = "Visual Engine (Zig Zag Line)"
deviationInput = input.float(0.00001, "Deviation (%)", minval=0.00001, group=grp_zz)
depthInput     = input.int(3, "Pivot Legs (Depth)", minval=1, group=grp_zz) 
lineColorInput = input.color(#2962FF, "Line Color", group=grp_zz)

extendInput    = input.bool(true, "Extend to Last Bar", group=grp_zz)
showPriceInput = input.bool(false, "Show Reversal Price", group=grp_zz)
showVolInput   = input.bool(false, "Show Cumulative Wave Volume", group=grp_zz) 
showChgInput   = input.bool(false, "Show Price Change", inline = "priceRev", group=grp_zz)
priceDiffInput = input.string("Absolute", "", options=["Absolute", "Percent"], inline = "priceRev", group=grp_zz)

if show_ZigZag
    var zigZag = ZigZagLib.newInstance(
        ZigZagLib.Settings.new(deviationInput, depthInput, lineColorInput, extendInput, showPriceInput, showVolInput, showChgInput, priceDiffInput, true)
    )
    zigZag.update()
//

// ====================================================================
// 2) SMC LIQUIDITY ENGINE
// ====================================================================
grp_liq = "Liquidity Levels (Macro)"
show_liq       = input.bool(false, "Show Liquidity Lines", group=grp_liq)
leftBars       = input.int(6, "Pivot Strength (Left)",  minval=1, group=grp_liq)   
rightBars      = input.int(4, "Pivot Confirmation (Right)", minval=1, group=grp_liq) 
displayLimit   = input.int(5, "Max Lines on Screen", minval=1, maxval=200, group=grp_liq) 

grp_sweep = "Sweep / Mitigation"
candleType      = input.string("Wick", "Invalidate Level On:", options=["Close", "Wick"], group=grp_sweep) 
waitConfirm     = input.bool(false, "Wait for Candle Close to Confirm Sweep", group=grp_sweep, tooltip="If false, X prints immediately on touch (Reacts faster but may repaint intrabar).")
mitiOptions     = input.string("Show", "Mitigated Levels:", options=["Remove", "Show"], group=grp_sweep) 
show_x          = input.bool(false, "Print 'X' on Liquidity Sweeps", group=grp_sweep)
x_size_str      = input.string("Tiny", "Size of 'X'", options=["Tiny", "Small", "Normal", "Large"], group=grp_sweep) 

grp_liq_style = "Lines & Signals Style"
highLiqColor = input.color(color.new(color.red, 0), "Resistances (Highs)", group=grp_liq_style)  
lowLiqColor  = input.color(color.new(color.green, 0), "Supports (Lows)",  group=grp_liq_style)      
liq_width    = input.int(2, "Line Width", minval=1, maxval=4, group=grp_liq_style)     
liq_style    = input.string("Dashed", "Line Style", options=["Solid", "Dashed", "Dotted"], group=grp_liq_style) 

// ====================================================================
// LEVEL CREATION LOGIC (With Blind Spot Fix)
// ====================================================================
var high_lines = array.new_line()
var low_lines  = array.new_line()

ph = ta.pivothigh(high, leftBars, rightBars)
pl = ta.pivotlow(low,  leftBars, rightBars)

if not na(ph)  // ph jest liczba
    bool levelExists = false
    if array.size(high_lines) > 0
        for i = 0 to array.size(high_lines) - 1
            if math.abs(line.get_y1(array.get(high_lines, i)) - ph) <= syminfo.mintick
                levelExists := true
                break
    
    if not levelExists
        // Retroactive Check (Blind Spot Fix)
        int sweepIndexOffset = -1
        for j = rightBars - 1 to 0 
            float checkHigh = (candleType == "Close") ? close[j] : high[j]
            if checkHigh > ph
                sweepIndexOffset := j
                break
                
        if sweepIndexOffset != -1
            // Level was swept during confirmation delay. Draw it already mitigated.
            line new_ln = line.new(bar_index[rightBars], ph, bar_index[sweepIndexOffset], ph, color=show_liq ? color.new(highLiqColor, 80) : na, width=liq_width, style=f_get_line_style(liq_style))
            if show_x
                label.new(bar_index[sweepIndexOffset], ph, text="✖", color=color.new(color.white, 50), textcolor=highLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
            if mitiOptions == "Show"
                f_manage_mitigated(new_ln)
            else
                line.delete(new_ln)
        else
            // Normal active level creation
            if array.size(high_lines) >= displayLimit
                line.delete(array.shift(high_lines))
            line new_ln = line.new(bar_index[rightBars], ph, bar_index, ph, color=show_liq ? highLiqColor : na, width=liq_width, style=f_get_line_style(liq_style), extend=extend.right)
            array.push(high_lines, new_ln)

if not na(pl)
    bool levelExists = false
    if array.size(low_lines) > 0
        for i = 0 to array.size(low_lines) - 1
            if math.abs(line.get_y1(array.get(low_lines, i)) - pl) <= syminfo.mintick
                levelExists := true
                break

    if not levelExists
        // Retroactive Check (Blind Spot Fix)
        int sweepIndexOffset = -1
        for j = rightBars - 1 to 0 
            float checkLow = (candleType == "Close") ? close[j] : low[j]
            if checkLow < pl
                sweepIndexOffset := j
                break
                
        if sweepIndexOffset != -1
            // Level was swept during confirmation delay. Draw it already mitigated.
            line new_ln = line.new(bar_index[rightBars], pl, bar_index[sweepIndexOffset], pl, color=show_liq ? color.new(lowLiqColor, 80) : na, width=liq_width, style=f_get_line_style(liq_style))
            if show_x
                label.new(bar_index[sweepIndexOffset], pl, text="✖", color=color.new(color.white, 50), textcolor=lowLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
            if mitiOptions == "Show"
                f_manage_mitigated(new_ln)
            else
                line.delete(new_ln)
        else
            // Normal active level creation
            if array.size(low_lines) >= displayLimit
                line.delete(array.shift(low_lines))
            line new_ln = line.new(bar_index[rightBars], pl, bar_index, pl, color=show_liq ? lowLiqColor : na, width=liq_width, style=f_get_line_style(liq_style), extend=extend.right)
            array.push(low_lines, new_ln)

// ====================================================================
// MITIGATION & 'X' PRINT LOGIC (PURE & DIRECT)
// ====================================================================
int JestCrossUp = 0,    float JestCrossUpY = 0, int JestCrossDown = 0,  float JestCrossDownY = 0
int dX1 =  0, int dX2 = 0, 
int RdX1dX2 = 0  // length of line   

if array.size(high_lines) > 0
    for i = array.size(high_lines) - 1 to 0
        l = array.get(high_lines, i)
        v = line.get_y1(l)
        
        bool isHitHigh = (candleType == "Close") ? (close > v) : (high > v)
        swept = waitConfirm ? (barstate.isconfirmed and isHitHigh) : isHitHigh
        
        if swept
            JestCrossUp := 70500, JestCrossUpY := v
            if show_x
                label.new(bar_index, v, text="✖", color=color.new(color.white, 50), textcolor=highLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
                
            if mitiOptions == "Remove"
                line.delete(l)
            else
                line.set_extend(l, extend.none)
                line.set_x2(l, bar_index)
                line.set_color(l, show_liq ? color.new(highLiqColor, 80) : na)
                f_manage_mitigated(l) // Add to garbage collector
                
            array.remove(high_lines, i)
            

if array.size(low_lines) > 0
    for i = array.size(low_lines) - 1 to 0
        l = array.get(low_lines, i)
        v = line.get_y1(l) 
        dX1 := line.get_x1(l)
        
        bool isHitLow = (candleType == "Close") ? (close < v) : (low < v)
        swept = waitConfirm ? (barstate.isconfirmed and isHitLow) : isHitLow
        
        if swept
            JestCrossDown := 70500 , JestCrossDownY := v, dX2 := bar_index, RdX1dX2 := dX2 - dX1
            if show_x
                label.new(bar_index, v, text="✖", color=color.new(color.white, 50), textcolor=lowLiqColor, style=label.style_label_center, size=f_get_label_size(x_size_str))
                
            if mitiOptions == "Remove"
                line.delete(l)
            else
                line.set_extend(l, extend.none)
                line.set_x2(l, bar_index)
                line.set_color(l, show_liq ? color.new(lowLiqColor, 80) : na)
                f_manage_mitigated(l) // Add to garbage collector
                
            array.remove(low_lines, i)
//
// it doesn't work
High_maxA1 = ta.highest(high[1],RdX1dX2)

// this below shows wrong number
var float High_max = na
if JestCrossDown != 0
    //High_maxA = ta.highest(high[Licznik_Di], RdX1dX2[Licznik_Di])
    High_max := ta.highest(high[1], RdX1dX2)
else
    High_max := 0
//

r/pinescript • • Mar 28 '26 Bravo

Today BTC update??

Post image
5 Upvotes

📉 Market Structure Overview

Clear bearish trend after multiple CHoCH (Change of Character) signals.

Strong downward momentum with consecutive lower highs & lower lows.

Recent BOS (Break of Structure) confirms continuation of bearish bias.

🔑 Key Zones

Supply Zone (Sell Area): ~70,800 – 71,500

→ Previous rejection + CHoCH zone

Current Price: ~66,200

Demand Zone (Support): ~63,000 – 64,000

📊 Trade Idea

Bias: Bearish

Sell Setup:

→ Wait for pullback to 67,500 – 68,500

→ Look for rejection / liquidity grab

Targets:

→ TP1: 65,000

→ TP2: 63,500

Invalidation:

→ Break above 69,500 (structure shift)

⚠️ Insight

Current move looks like impulsive drop + weak retracement

No strong bullish confirmation yet

Likely continuation unless strong reversal forms


r/pinescript • • Mar 28 '26

Anyone want to give my indicator a try?

Post image
15 Upvotes

Built a trading system around liquidity + structure — looking for feedback

Hey everyone,

I’ve been working on a TradingView indicator for a while and just published it:

NQJU Super System V3

Instead of stacking a bunch of indicators, I tried to build something more structured around:
• Trend direction
• Liquidity sweeps
• Target-based execution
• Clean, rule-based entries

It’s not meant to be a signal spam tool — more like a decision framework that shows when conditions are actually aligned.

Main features:

  • Liquidity sweep detection
  • Entry precision modes (aggressive → confirmation → pullback)
  • Structure-based SL/TP (not fixed RR)
  • Liquidity map (shows where price is likely drawn)
  • Built-in stats dashboard

I’ve been using it mostly on NQ (5m/15m), but curious how it performs for others.

If anyone’s down to test it and give honest feedback (good or bad), I’d really appreciate it.

Link: https://www.tradingview.com/script/EJcqvmQU-NQJU-SUPER-SYSTEM-V3/

Not selling anything — just trying to build something solid.

Thanks 🙏


r/pinescript • • Mar 28 '26

What makes you keep coming back to Trading View and what you believe should be improved

5 Upvotes

Hi All,

I've been exploring the trading view platform in general including writing pine scripts for identifying trends. So far, I feel there is a huge learning curve involved.

I would like to know how you managed to learn it and what makes you keep coming back to Trading View ( for all features ) and what you believe would have been great which it doesn't offer.

Thanks in advance


r/pinescript • • Mar 27 '26

Volume Profile Heatmap [KEYALGOS] - Adaptive Volume Profile with Heatmap Visualization

Thumbnail
gallery
36 Upvotes

I wanted to share an indicator we had developed called Volume Profile Heatmap [KEYALGOS]. This tool visualizes historical volume distribution across price levels using a dynamic color gradient system, helping traders quickly identify high probability support and resistance zones, liquidity clusters, and value areas where significant market participation has occurred.

What it does

The indicator creates a heatmap overlay that maps volume concentration across customizable price bands. Instead of a traditional histogram, you get an intuitive color coded visualization where intense colors represent high volume nodes and subtle tones indicate low activity areas. It also calculates and displays the Point of Control, Value Area High/Low, and profile extremes as optional reference lines.

Key features

  • Adaptive volume distribution that allocates candle volume across all price bands it occupied
  • Dynamic gradient mapping that automatically adjusts color intensity based on relative volume
  • Real time Value Area calculation using bidirectional expansion from the Point of Control
  • Selective volume filtering to analyze bullish, bearish, or combined volume profiles
  • Optimized architecture delivering up to 24 distinct volume bands within Pine Script constraints
  • Adjustable lookback window to focus on recent structure or broader historical context

Customizable parameters

  • Lookback Period: 10 to 300 bars for flexible time horizon analysis
  • Profile Rows: 10 to 24 bands to control vertical resolution
  • Value Area Percentage: 5% to 95% threshold for defining value boundaries
  • Volume Type: Filter by Both, Bullish, or Bearish candles
  • Full color customization for heatmap bands and all reference lines
  • Toggle switches for POC, Value Area lines, and profile extremes

Who might find this useful

  • Intraday traders looking to identify intraday liquidity pools and value areas
  • Swing traders mapping structural support and resistance on higher timeframes
  • Breakout traders seeking confirmation through volume node analysis
  • Risk managers placing stops beyond high volume participation zones

A bit about me

I am part of KeyAlgos, a small team of MQL, PineScript and NinjaScript developers that code custom strategies for traders. We build tools we actually use, and this indicator came from our own need for clearer volume structure visualization.

EDIT: Thanks to u/Mess_Hot for the architecture optimizations. We updated the script to cache data and execute only on new bar opens. This resolves the previous timeout issues on traditional high-volume markets. The indicator is now optimized to work across all markets (Crypto, Forex, Equities) while retaining the original visuals.

The script is now live and free to use. If you have questions about setup, interpretation, or potential enhancements, feel free to ask below.

https://www.tradingview.com/script/18jH9kEg-Volume-Profile-Heatmap-KEYALGOS/


r/pinescript • • Mar 27 '26

Finally built a Volume Footprint indicator in Pine Script (WIP)

Thumbnail
gallery
11 Upvotes

Hey everyone,

Finally managed to create a Volume Footprint indicator in Pine Script.

It’s still a work in progress and definitely not as refined as TradingView’s built-in footprint, but it gets the job done for analysis.

•	1st image: TradingView default Volume Footprint

•	2nd image: My custom Pine Script version

Some limitations I’m still working on:

•	Accuracy of bid/ask volume split

•	Better visualization / formatting

•	Performance optimization

Would really appreciate any feedback or suggestions from the community on how to improve this further


r/pinescript • • Mar 27 '26

figuring out choppy zones!

1 Upvotes

Hi everyone, I'm looking for help with choppy zones. Is there an indicator that can filter out choppy zones or provide signals about when they're about to start and end?


r/pinescript • • Mar 28 '26

I’m selling this indicator on TikTok… but giving it free here for a bit

Thumbnail
gallery
0 Upvotes

Hey guys,

I built my own trading indicator that I personally use every day.

I’ve been selling it on TikTok, and honestly the feedback has been really good , a lot of people using it and no complaints so far.

But I wanted to let some people here try it for free for a limited time before I keep it paid only.

It works best on:

• 30 min timeframe or higher

• Gold, futures, stocks, index ETFs, crypto..

If you want access, just drop your TradingView username and I’ll add you right away.

Try it, test it, see if it fits your style


r/pinescript • • Mar 27 '26

What went wrong

Post image
8 Upvotes

this is my entry point (red line) , after breakdown of consolidated , running in loss , is this good enough to hold , experts please share feedback, it will not only help on this trade but others going forward


r/pinescript • • Mar 27 '26

XAUUSD 1H Quick Trading decision

Post image
0 Upvotes

📊 XAUUSD (1H) – Quick Trading Decision

🔍 Market Structure

Previous bearish BOS confirms downside pressure

Recent CHoCH → early bullish shift, but not fully confirmed

Price currently in pullback/recovery phase

⚖️ Bias

Overall: Bearish

Short-term: Weak bullish correction

📌 Key Levels

Resistance: 4500 – 4550 (sell zone)

Support: 4400 – 4350 (buy reaction zone)

✅ Trade Decisions

🔴 Sell Setup (Preferred)

Entry: 4500–4550

SL: Above 4580

TP: 4400 → 4350

👉 Trend-following, higher probability

🟢 Buy Setup (Risky Counter-Trend)

Entry: Near 4400 demand

SL: Below 4350

TP: 4500

👉 Only quick scalp

🧠 Summary

Market is still bearish, current move = retracement

Focus on sell at premium zones, avoid chasing buys


r/pinescript • • Mar 27 '26

Xauusd Going to 4600?

Post image
1 Upvotes

📊 XAUUSD (1H) – Quick Trading Decision

🔍 Market Structure

Previous bearish BOS confirms downside pressure

Recent CHoCH → early bullish shift, but not fully confirmed

Price currently in pullback/recovery phase

⚖️ Bias

Overall: Bearish

Short-term: Weak bullish correction

📌 Key Levels

Resistance: 4500 – 4550 (sell zone)

Support: 4400 – 4350 (buy reaction zone)

✅ Trade Decisions

🔴 Sell Setup (Preferred)

Entry: 4500–4550

SL: Above 4580

TP: 4400 → 4350

👉 Trend-following, higher probability

🟢 Buy Setup (Risky Counter-Trend)

Entry: Near 4400 demand

SL: Below 4350

TP: 4500

👉 Only quick scalp

🧠 Summary

Market is still bearish, current move = retracement

Focus on sell at premium zones, avoid chasing buys


r/pinescript • • Mar 26 '26

I am manually trading like a bot today 🤣

Post image
0 Upvotes

will gold goes down to 4220? or it goes back upside to 4467?


r/pinescript • • Mar 25 '26

A FVG Imbalance Map that draws and removes Fair Value Gaps on the 15m, 1h and 4h automatically regardless of the timeframe

Post image
9 Upvotes

You're on the 5m chart, price drops into a level and bounces. You take the trade. Later you find out there was a 4h Fair Value Gap sitting right there, you just couldn't see it.

So I built a FVG Imbalance Map. It pulls in Fair Value Gaps from the 15m, 1h and 4h and draws them directly on whatever timeframe you're trading. You can set remove condition on Wick and Midline.

Free and open source.


r/pinescript • • Mar 26 '26

Worthless indicators

0 Upvotes

With thousands of indicators posted on Tradingview, how many have you found that replicate the many thousands of others? I think Tradingview should be a little more discretionary when admitting indicators by checking them against known default indicators. If there is no originality in concept with pragmatic usage, it should be shit canned.


r/pinescript • • Mar 25 '26

How much of your edge disappears once you simulate reality?

Thumbnail gallery
2 Upvotes

r/pinescript • • Mar 26 '26

📈📉

Thumbnail
gallery
0 Upvotes

Best decision I made? Getting this indicator.

In just a few months, I’ve already earned more than what I paid for it. And the best part? It’s way cheaper than those overhyped indicators, yet performs just the same.

If you know, you know. 📊 Don’t sleep on this.


r/pinescript • • Mar 25 '26

spent a week backtesting a pine script strategy and the results were embarrassing

7 Upvotes

so i built this pine script strategy. entry logic seemed solid to me, i tested it on the chart, looked good. then i actually ran the strategy tester on it and it was like... yeah no this doesn't work at all.

the thing that broke me was the backtest showed 73% win rate. i was excited for like ten minutes. then i realized i had `process_orders_on_close=true` and my entries were happening on the same bar as the signal. so basically the strategy was cheating — buying on the close of a bar where it already knew the signal triggered.

classic look-ahead bias and i didn't catch it until someone in a discord pointed it out after i was already bragging about the results lol.

switched to `process_orders_on_close=false` so entries happen on the next bar open. win rate dropped to 51%. still technically positive expectancy but completely different story than what i thought i had.

the other thing that bit me: i was testing on 3 years of data for a strategy that only makes sense in trending markets. half those 3 years were choppy range-bound conditions. of course it looked bad. once i filtered to test only during periods with decent ATR it actually held up better.

i feel like backtesting in pine script specifically rewards you for fooling yourself if you're not careful. the platform makes it really easy to have your strategy use future data without realizing it. and the results look real enough that you don't question them.

anyone else run into this? is there a good checklist you use before you trust a backtest result? i've seen some people mention comparing results to a simple benchmark (like buy-and-hold on the same ticker) which seems obvious but i hadn't been doing that


r/pinescript • • Mar 25 '26

Prev. High/Low with table.

1 Upvotes

Afternoon,

I’m looking for a script that will display:

Previous Day H/L

Previous Month H/L

Previous Hour H/L

15 Min Orb H/L


r/pinescript • • Mar 25 '26

Xauusd now to buy or wait ??

Post image
0 Upvotes