Want to learn Pine Script but don't know where to start?
I wrote a tiny indicator called "Volume X-Ray" — just ~60 lines. Perfect for your first hands-on practice, even if you've never coded before.
What it does: splits each candle into estimated Buy vs Sell volume and shows you a clean little table on the chart.
🧪 Try it yourself (takes 2 minutes):
1. Open any chart on TradingView
2. Click "Pine Editor" at the bottom
3. Delete everything in the editor
4. Paste the code from my reply below
5. Click "Add to chart"
6. You should see a small table in the top right corner
That's it — you just ran your first Pine Script.
📖 Now the fun part — learning by tweaking:
→ Change "3" to "5" in the Candles input — see more history
→ Open Settings and switch Source from "Volume" to "Footprint"
If you're on a Free or Essential plan, TradingView will show an upgrade message when you switch to Footprint. That's normal — it means footprint data needs Premium or Ultimate.
This is a great way to discover what different TradingView plans unlock for coders.
If you're on Premium/Ultimate, switch between both modes and compare — the estimated numbers vs real order flow data. The difference is eye-opening.
💬 Questions? Stuck on something? Drop a comment — I'll answer every single one. Seriously. That's why I'm posting this.
Code 👇
// Volume X-Ray · See buy/sell force inside every candle
// Free plan: estimated · Premium: real footprint data
// Switch modes in Settings → "Source"
//
@version=6
indicator("Volume X-Ray", overlay = true)
string src = input.string("Volume", "Source", options = ["Volume", "Footprint"])
int N =
input.int(3, "Candles", minval = 1, maxval = 5)
fv(float v) => v >= 1e6 ? str.tostring(v/1e6,"#.#") "M" : v >= 1e3 ? str.tostring(v/1e3,"#.#") "K" : str.tostring(v,"#.#")
var array<float> bArr =
array.new<float>()
var array<float> sArr =
array.new<float>()
var array<float> dArr =
array.new<float>()
var array<float> pArr =
array.new<float>()
float bv = 0.0, float sv = 0.0, float poc = na
if src == "Footprint"
footprint fp = request.footprint(1, 70)
if not na(fp)
bv :=
fp.buy_volume()
sv := fp.sell_volume()
volume_row pr = fp.poc()
poc := not na(pr) ? pr.down_price() : na
else
float d = high != low ? (close - open) / (high - low) : 0.0
bv := volume * (1 d) / 2
sv := volume * (1 - d) / 2
if not na(bv)
array.push(bArr, bv), array.push(sArr, sv)
array.push(dArr, bv - sv), array.push(pArr, poc)
while array.size(bArr) > N
array.shift(bArr), array.shift(sArr)
array.shift(dArr), array.shift(pArr)
var table t = na
if barstate.islast and array.size(bArr) > 0
if not na(t)
table.delete(t)
int nc = array.size(bArr)
int rows = src == "Footprint" ? 5 : 4
t :=
table.new(
position.top_right, nc 1, rows, bgcolor = #131722, border_color =
color.new(
#363A45, 50), border_width = 1)
string lbl = src == "Footprint" ? "" : "~"
string[] rn = array.from(lbl "Buy", lbl "Sell", "Delta", "POC")
for r = 0 to (src == "Footprint" ? 3 : 2)
table.cell(t, 0, r 1, array.get(rn, r), bgcolor =
#1E222D, text_color = color.gray, text_size = 10)
table.cell(t, 0, 0, src == "Footprint" ? "FP" : "Vol", bgcolor =
#1E222D, text_color =
#FF9800, text_size = 10, text_formatting = text.format_bold)
for i = 0 to nc - 1
float b = array.get(bArr, i), float s = array.get(sArr, i), float dl = array.get(dArr, i)
table.cell(t, i 1, 0, "C" str.tostring(i 1), bgcolor =
#1E222D, text_color = color.white, text_size = 10, text_formatting = text.format_bold)
table.cell(t, i 1, 1, fv(b), bgcolor =
color.new(
#26A69A, 80), text_color =
#26A69A, text_size = 10)
table.cell(t, i 1, 2, fv(s), bgcolor =
color.new(
#EF5350, 80), text_color =
#EF5350, text_size = 10)
color dc = dl > 0 ?
#26A69A :
#EF5350
table.cell(t, i 1, 3, (dl>0?" ":"") fv(dl), bgcolor =
color.new(dc, 85), text_color = dc, text_size = 10, text_formatting = text.format_bold)
if src == "Footprint"
float pc = array.get(pArr, i)
table.cell(t, i 1, 4, na(pc) ? "–" : str.tostring(pc,"#.####"), bgcolor = #131722, text_color =
#FF9800, text_size = 10)
#PineScript #LearnToCode #TradingView #PineScriptV6 #CodingForBeginners #AlgoTrading #TradingEducation #VolumeAnalysis #OrderFlow #FootprintChart #TechnicalAnalysis #VolumeProfile #DayTrading #SwingTrading #CryptoTrading #ForexTrading #FuturesTrading #StockMarket #SmartMoney #TradingTools #BuySellDelta #MarketStructure #TradingCommunity #CodeNewbie #QuantTrading #ChartAnalysis #InstitutionalFlow #PriceAction #OpenSource #WallStreet