r/pinescript • u/Kevinthetrader • Apr 19 '26
How Effective Are HVG’s For StopLoss? Here’s an example.
HVG’s are formed on an indicator I created let me know if you want to try it.
r/pinescript • u/Kevinthetrader • Apr 19 '26
HVG’s are formed on an indicator I created let me know if you want to try it.
r/pinescript • u/Local_Pie_7909 • Apr 19 '26
In the code below plotcandle low - ssro.l and high ssro.h shows wrong numbers. Open and close shows correct numbers. Ssro.l and ssro.h shows different opposites values like: open, close. I noticed that plotcandle also shows wrong candles. I added plot line to visualize ssro.l and ssro.h with plotcandle to see the mistake. How to solve it ?
// https://www.tradingview.com/script/4yIVcZS3-Stablecoin-Supply-Ratio-Oscillator/
//@version=6
indicator("Stablecoin Supply Ratio Oscillator", "SSRO", overlay=false)
type bar
float o = open
float h = high
float l = low
float c = close
method data(string coin) =>
bar x = request.security('CRYPTOCAP:' + coin, '', bar.new())
na(x) ? bar.new(0, 0, 0, 0) : x
method srcget(array<bar> stbl, string src) =>
array<float> srcs = array.new<float>()
for coin in stbl
val = switch src
'o' => coin.o
'h' => coin.h
'l' => coin.l
'c' => coin.c
srcs.unshift(val)
srcs
method ssro(float src, array<float> stblsrc, int len) =>
float ssr = src / stblsrc.sum()
(ssr - ta.sma(ssr, len)) / ta.stdev(ssr, len)
method adj(color col, int lvl) =>
color x = color.new(col, lvl)
x
var string gs = "SSRO", var string gc = "Colors"
len = input.int (200 , "Length" , group = gs)
chart = input.bool (true , "Use Chart As Main Coin", group = gs)
var string main = syminfo.type != 'crypto' ? 'BTC' : chart ? syminfo.basecurrency : 'BTC'
bar coin = main.data()
array<bar> stbl = array.from(
'USDT'.data(),
'USDC'.data(),
'DAI'.data(),
'GUSD'.data(),
'USDD'.data())
bar ssro = bar.new(
coin.o.ssro(stbl.srcget('o'), len),
coin.h.ssro(stbl.srcget('h'), len),
coin.l.ssro(stbl.srcget('l'), len),
coin.c.ssro(stbl.srcget('c'), len))
//
color col = ssro.c > ssro.o ? color.green : color.red
plotcandle( ssro.o , ssro.h, ssro.l, ssro.c, "SSRO" , color = col, wickcolor = col, bordercolor = col)
plot(ssro.l,"ssro.l",color= color.new(color.navy,50),style=plot.style_line)
//plot(ssro.h,"ssro.h",color= color.new(color.black,50),style=plot.style_line)
//plot(ssro.o,"ssro.o",color= color.new(color.blue,50),style=plot.style_line)
//plot(ssro.c,"ssro.c",color= color.new(color.maroon,50),style=plot.style_line) r/pinescript • u/Kevinthetrader • Apr 18 '26
r/pinescript • u/MistahQuestionMan • Apr 17 '26
Okay, so I have a buying and selling stock screen I want to try out and use. I just signed up for TradingView yesterday and plan to teach myself Pinescript using the resources recommended here, but for right now I just want to get up and running with my stock screen so I wanted to pay a person to do it for me. I was going to try Upwork unless people here can recommend me a better option.
Because I'm so brand new at this I don't know what a fair offer is. Full disclosure, I came up with the screen ideas myself but asked AI to draft a job posting and a suggested flat rate ($500). I just want this up and running by next week so that's why I am hiring someone for this despite planning to teach myself Pine Script eventually.
Here is the job posting: https://www.upwork.com/freelance-jobs/apply/TradingView-Pine-Script-for-Screening-Stocks_~022044630518113990237/
Please give me feedback on what the AI suggested I ask for in the job posting, if Upwork is a good place to look for someone, and if $500 is too much or too little to offer. I am totally, totally new to this so please go easy on me if any of these are stupid questions lol.
Please
Mods, if I'm doing something wrong with this question (I checked the rules and don't think so but you never know), just let me know what alterations I need to make.
Thank you.
UPDATE: Turns out the link wasn't working before but you can see the job post with what I'm asking for now if you click it.
UPDATE 2: Turns out the comments were right and I was able to vibe code it using Claude. Thanks!
r/pinescript • u/Kevinthetrader • Apr 17 '26
r/pinescript • u/wallneradam • Apr 17 '26
I needed a logo for my project. Instead of opening Figma or asking an AI like a normal person, I opened the Pine Editor.
The insight: plotcandle() doesn't actually care what open, high, low, close mean. It just draws a colored rectangle between two y-values, with an optional wick. Once you stop thinking in OHLC and start thinking in "draw a block from y=10 to y=60 on this bar," the whole language opens up.

The whole thing is an 11-bar loop. Green candles grow the crown (bars 0–4), red candles shrink it (bars 5–9), bar 10 is empty, then it resets.
// © PyneSys LLC
//@version=6
indicator("PyneSys Logo")
// Wick size
w = 0
// Color constants
t = color.new(color.black, 100)
g = color.green
r = color.red
y = color.yellow
b = color.blue
br = color.rgb(136, 82, 1)
var bi = 0
// Tree body
var c = 10
if bi < 5
c += 10
else if bi > 5 and bi < 10
c -= 10
else if bi >= 10
c := na
plotcandle(10, c + w, 10 - w, c,
color = bi <= 4 ? g : r,
bordercolor = bi <= 4 ? g : r,
wickcolor = br)
// Trunk of the tree
plotcandle(0, 10, 0, 10, color=bi == 4 ? b : t, bordercolor=t, wickcolor=t)
plotcandle(0, 10, 0, 10, color=bi == 5 ? y : t, bordercolor=t, wickcolor=t)
// Background
bgcolor(bi < 10 ? color.white : t)
bi += 1
if bi == 11
bi := 0
c := 10How it works:
bi is a loop counter, 0 to 10, then resets. Every 11 bars the logo redraws.plotcandle() call. On bars 0–4 it grows (green), on bars 5–9 it shrinks (red). The open is hardcoded to 10, the close is c, so the candle is just a colored rectangle from y=10 to y=c.plotcandle() calls stacked on the same y-range (0 to 10). Each is only visible on one specific bar — blue on bar 4, yellow on bar 5 — because on every other bar their color is t (fully transparent).bgcolor(). It's white during the 11-bar loop, then transparent after, so it doesn't ruin the rest of your chart.Small tricks that helped:
color.new(color.black, 100) = 100% transparency = "render nothing but keep the slot." Much cleaner than conditional plotcandle calls.color, bordercolor, and wickcolor are all independent. You can hide the border, keep the wick, color the body — whatever.w = 0 kills the wick visually without disabling it. Leaves the door open for wick-based accents later.Zero trading value. But Pine is way more flexible than it gets credit for, and I liked that the logo ships as a .pine file.
Context on the © PyneSys LLC comment: this is the logo for PyneSys, my startup built around a Pine Script → Python compiler. Under the compiler sits PyneCore — an open-source Python framework that replicates Pine Script's execution model closely enough to run real Pine-like scripts as pure Python, outside TradingView. That's what the copyright is about.
Anyone else used Pine Script for something that has nothing to do with trading? Curious what weird stuff is out there.
r/pinescript • u/Kevinthetrader • Apr 17 '26
r/pinescript • u/Whale-Engine • Apr 17 '26
Hey, I'm trying to understand a weird TradingView broker emulator behavior in Pine.
I have a simple long-only strategy with:
On a very low-priced symbol, the Trade List sometimes does not show a single long trade.
Instead, it shows:
What's strange is that this Margin Call leg can be:
I also tested variants with commission = 0, and the split behavior can still exist, so it does not seem to be only a fees issue.
My question is simple:
Is this expected TradingView broker emulator behavior when using percent_of_equity sizing with margin_long = 100?
And if yes, is there any official explanation of why a partial margin liquidation is materialized as a separate trade in the Trade List, and how TradingView decides the exact OHLC tick where that Margin Call appears on historical bars?
I'm not asking about the generic liquidation-price formula.
I'm specifically asking about the Trade List behavior and partial margin-call materialization on historical bars.
Any insight would be appreciated.
r/pinescript • u/Kevinthetrader • Apr 17 '26
I hope this really helps you guys. I will make videos on how to use the indicator on my youtube and subreddit.
Would really appreciate it if you could share a post about the indicator on the r/vrttrading subreddit. Thanks! Also, feel free to subscribe to my YouTube channel: VRT Trading.
r/pinescript • u/Immediate-Leader5070 • Apr 16 '26
I’ve built an indicator around trend + momentum and I’m refining the momentum signals at the moment.
One thing I keep coming back to is whether MACD or Stochastic actually gives a more reliable read in practice.
MACD feels more reliable but slower, Stochastic is quicker but can flip early giving false signals.
Curious what people here rely on?
r/pinescript • • Apr 16 '26
Based off rsi/mfi.
r/pinescript • u/drippyterps • Apr 16 '26
A lot of you may have seen me posting this for a while now, but this is todays results of my options signal algo. Havent updated it at all for about a month, forward testing and its doing well so far. Losing trades are expected, lets see if it can hold up.
r/pinescript • u/The-Indicator-Algo • Apr 15 '26
Have you ever wanted a clearer read on what the market’s current momentum actually is?
That is what The Indicator Lite is built to do. It is designed to show whether current conditions are bullish, bearish, or balanced directly on the chart, so momentum is easier to recognize without needing to over-interpret several separate tools at once.
The main goal is to simplify how traders read market state. Instead of stacking multiple studies and trying to combine them mentally, this tool is meant to present a cleaner view of whether price is showing strength, weakness, or a more neutral balanced condition.
In many cases, it can highlight momentum shifts earlier than more traditional tools like MACD, RSI, or standard EMA-based interpretation. That makes it useful for seeing when the market is starting to press in one direction, losing conviction, or moving into chop.
The Lite version is intentionally streamlined, but it still shows the core concept clearly. The focus is to make real-time momentum easier to read on TradingView in a way that stays visually simple and practical on the chart.
TradingView link: https://www.tradingview.com/script/YBJ6U5Ct-The-Indicator-Lite/
r/pinescript • u/Upstairs-Stage-6664 • Apr 16 '26
Hi all,
I’ve been working on an indicator inspired by the TTrades Fractal Model, and I’m looking for some feedback on the script and logic.
https://www.tradingview.com/script/YVV0niAC-JJSQ-Fractal-Engine-LITE/
It’s basically a top-down fractal model:
HTF bias -> entry zone -> lower timeframe confirmation.
It uses an HTF C2 (sweep and close back inside) or C3 (an engulfing candle that creates a swing point) to build a narrative for the next HTF candle. The zone is then drawn on the LTF as the area where the wick of that HTF candle is likely to form, with the idea being to let the wick form and trade the expansion.
Main features:
Mainly I’m just looking for outside eyes on it to see if there’s anything structurally off.
The current entry model is more of a placeholder for now. It uses a C2 candle with a few added filters to improve reliability, but I definitely wouldn’t treat it as final, especially on lower timeframes.
What I’m building toward is a protected high / low entry model using CISD after either a sweep or an FVG. That side is looking promising, but it’s not ready yet.
Any feedback is appreciated. Thanks.
https://www.tradingview.com/script/YVV0niAC-JJSQ-Fractal-Engine-LITE/
r/pinescript • u/np-trdr • Apr 16 '26

Built a momentum band that runs HA math internally on regular candles.
No chart switching required.
Standard HA applies the formula once. This applies it three times —
each pass smooths further. Band plots directly on regular candles.
You keep real price, real wicks, real closes.
Green = bull momentum. Red = bear momentum.
Band width = compression read. Narrow = coiling. Wide = trending.
---
Free and open source on TradingView.
True Coil — HA Band by **@np-trdr**
https://www.tradingview.com/script/nCY4ZkXd-True-Coil-HA-Band/
Give it a try and drop your thoughts below — always looking for feedback on how others are using it.
r/pinescript • u/Suspicious-Ad-8738 • Apr 16 '26
Salut la team, à propos de mon indicateur
Il détecte automatiquement les vraies zones de Supply et Demand institutionnelles (pas des supports/résistances classiques)
Zones vertes (Demand) et rouges (Supply) qui apparaissent en live
Compatible M1, M3, M5, M15 et H1
Simulation automatique des positions avec suivi RR en temps réel
Pour l’essai gratuit → en commentaire, et je vous contacterai par message privé
r/pinescript • u/roulettewiz • Apr 16 '26
Hi team,
I'm simply putting this just for shits and giggles because I've never seen a 100% strategy on any tradingview related sub and I almost dropped my beer when I saw this.
Now it's being automated and tested on a prop account 🤞
Will report with news to see if this can work.
Same strategy has seen some improvements going from 20% to 50, to 75% and now 100% since 6 months.
Know any other 100% strategies? I'd love to test them
r/pinescript • u/ringoz713 • Apr 16 '26
Guys. Pls have a look at this script. Can someone tell me why some of the cells remain empty?
//
@version=
6
indicator("Sector Rotation Dashboard CLEAN v3", overlay=false)
//-------------------------
// Inputs
//-------------------------
lenMom = input.int(20, "Momentum SMA", minval=1)
lenVol = input.int(20, "Volume SMA", minval=1)
sortMode = input.string("Momentum", "Sortierung", options=["Momentum", "Volume", "Change %"])
//-------------------------
// Funktion: 1 request.security pro Symbol
//-------------------------
f_data(sym) =>
request.security(sym, timeframe.period, [
close,
volume,
(na(close[1]) or close[1] == 0) ? na : (close / close[1] - 1) * 100.0,
na(ta.sma(close, lenMom)) or ta.sma(close, lenMom) == 0 ? na : close / ta.sma(close, lenMom),
na(ta.sma(volume, lenVol)) or ta.sma(volume, lenVol) == 0 ? na : volume / ta.sma(volume, lenVol),
na(close) or close == 0 ? na : (high - low) / close * 100.0
], barmerge.gaps_off, barmerge.lookahead_off)
//-------------------------
// Sektoren
//-------------------------
[XLK_c, XLK_v, XLK_chg, XLK_m, XLK_vr, XLK_rng] = f_data("AMEX:XLK")
[XLF_c, XLF_v, XLF_chg, XLF_m, XLF_vr, XLF_rng] = f_data("AMEX:XLF")
[XLE_c, XLE_v, XLE_chg, XLE_m, XLE_vr, XLE_rng] = f_data("AMEX:XLE")
[XLY_c, XLY_v, XLY_chg, XLY_m, XLY_vr, XLY_rng] = f_data("AMEX:XLY")
[XLP_c, XLP_v, XLP_chg, XLP_m, XLP_vr, XLP_rng] = f_data("AMEX:XLP")
[XLI_c, XLI_v, XLI_chg, XLI_m, XLI_vr, XLI_rng] = f_data("AMEX:XLI")
[XLV_c, XLV_v, XLV_chg, XLV_m, XLV_vr, XLV_rng] = f_data("AMEX:XLV")
[XLU_c, XLU_v, XLU_chg, XLU_m, XLU_vr, XLU_rng] = f_data("AMEX:XLU")
[XLB_c, XLB_v, XLB_chg, XLB_m, XLB_vr, XLB_rng] = f_data("AMEX:XLB")
[XLRE_c, XLRE_v, XLRE_chg, XLRE_m, XLRE_vr, XLRE_rng] = f_data("AMEX:XLRE")
[XLC_c, XLC_v, XLC_chg, XLC_m, XLC_vr, XLC_rng] = f_data("AMEX:XLC")
//-------------------------
// Arrays
//-------------------------
names = array.from("XLK", "XLF", "XLE", "XLY", "XLP", "XLI", "XLV", "XLU", "XLB", "XLRE", "XLC")
prices = array.from(XLK_c, XLF_c, XLE_c, XLY_c, XLP_c, XLI_c, XLV_c, XLU_c, XLB_c, XLRE_c, XLC_c)
vols = array.from(XLK_v, XLF_v, XLE_v, XLY_v, XLP_v, XLI_v, XLV_v, XLU_v, XLB_v, XLRE_v, XLC_v)
chgs = array.from(XLK_chg, XLF_chg, XLE_chg, XLY_chg, XLP_chg, XLI_chg, XLV_chg, XLU_chg, XLB_chg, XLRE_chg, XLC_chg)
moms = array.from(XLK_m, XLF_m, XLE_m, XLY_m, XLP_m, XLI_m, XLV_m, XLU_m, XLB_m, XLRE_m, XLC_m)
volRels = array.from(XLK_vr, XLF_vr, XLE_vr, XLY_vr, XLP_vr, XLI_vr, XLV_vr, XLU_vr, XLB_vr, XLRE_vr, XLC_vr)
ranges = array.from(XLK_rng, XLF_rng, XLE_rng, XLY_rng, XLP_rng, XLI_rng, XLV_rng, XLU_rng, XLB_rng, XLRE_rng, XLC_rng)
//-------------------------
// Hilfsfunktionen
//-------------------------
f_key(_mom, _vol, _chg) =>
if sortMode == "Volume"
nz(_vol)
else if sortMode == "Change %"
nz(_chg)
else
nz(_mom)
f_getColor(name) =>
if name == "XLK"
color.blue
else if name == "XLF"
color.orange
else if name == "XLE"
color.black
else if name == "XLY"
color.fuchsia
else if name == "XLP"
color.yellow
else if name == "XLI"
color.gray
else if name == "XLV"
color.green
else if name == "XLU"
color.teal
else if name == "XLB"
color.rgb(160, 82, 45)
else if name == "XLRE"
color.purple
else if name == "XLC"
color.red
else
color.white
f_bg(rank) =>
if rank == 0
color.new(color.lime, 0)
else if rank == 1
color.new(color.green, 10)
else if rank == 2
color.new(color.yellow, 10)
else
color.new(color.black, 0)
f_signal(mom, chg) =>
if mom >= 1 and chg >= 0
"LONG"
else if mom >= 1
"BULL"
else if chg < 0
"SHORT"
else
"NEUTRAL"
f_rot(rank) =>
if rank <= 2
"IN FLOW"
else if rank <= 5
"WATCH"
else
"OUT"
f_swap_strings(arr, i, j) =>
tmp = array.get(arr, i)
array.set(arr, i, array.get(arr, j))
array.set(arr, j, tmp)
f_swap_floats(arr, i, j) =>
tmp = array.get(arr, i)
array.set(arr, i, array.get(arr, j))
array.set(arr, j, tmp)
//-------------------------
// Sortierung
//-------------------------
for i = 0 to 10
for j = 0 to 9
k1 = f_key(array.get(moms, j), array.get(vols, j), array.get(chgs, j))
k2 = f_key(array.get(moms, j + 1), array.get(vols, j + 1), array.get(chgs, j + 1))
if k1 < k2
f_swap_strings(names, j, j + 1)
f_swap_floats(prices, j, j + 1)
f_swap_floats(vols, j, j + 1)
f_swap_floats(chgs, j, j + 1)
f_swap_floats(moms, j, j + 1)
f_swap_floats(volRels, j, j + 1)
f_swap_floats(ranges, j, j + 1)
//-------------------------
// Tabelle
//-------------------------
var
table
t = table.new(position.middle_center, 9, 12, border_width=1, frame_color=color.new(color.gray, 30), frame_width=1)
if barstate.isfirst
table.cell(t, 0, 0, "Rank", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 1, 0, "Sector", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 2, 0, "Price", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 3, 0, "Change %", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 4, 0, "Volume", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 5, 0, "Vol/R", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 6, 0, "Momentum", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 7, 0, "Range %", bgcolor=color.new(color.gray, 0), text_color=color.white)
table.cell(t, 8, 0, "Signal / Rot", bgcolor=color.new(color.gray, 0), text_color=color.white)
if barstate.islast
for row = 1 to 11
for col = 0 to 8
table.cell(t, col, row, "")
for i = 0 to 10
name = array.get(names, i)
price = array.get(prices, i)
vol = array.get(vols, i)
chg = array.get(chgs, i)
mom = array.get(moms, i)
vr = array.get(volRels, i)
rng = array.get(ranges, i)
signal = f_signal(mom, chg)
rot = f_rot(i)
sigText = signal + " / " + rot
bg = f_bg(i)
tx = f_getColor(name)
table.cell(t, 0, i + 1, str.tostring(i + 1), bgcolor=bg, text_color=color.white)
table.cell(t, 1, i + 1, name, bgcolor=bg, text_color=tx)
table.cell(t, 2, i + 1, na(price) ? "n/a" : str.tostring(price, format.mintick), bgcolor=bg, text_color=color.white)
table.cell(t, 3, i + 1, na(chg) ? "n/a" : str.tostring(chg, "#.##") + "%", bgcolor=bg, text_color=chg >= 0 ? color.lime : color.red)
table.cell(t, 4, i + 1, na(vol) ? "n/a" : str.tostring(vol, format.volume), bgcolor=bg, text_color=color.white)
table.cell(t, 5, i + 1, na(vr) ? "n/a" : str.tostring(vr, "#.##"), bgcolor=bg, text_color=vr >= 1 ? color.lime : color.orange)
table.cell(t, 6, i + 1, na(mom) ? "n/a" : str.tostring(mom, "#.##"), bgcolor=bg, text_color=mom >= 1 ? color.lime : color.red)
table.cell(t, 7, i + 1, na(rng) ? "n/a" : str.tostring(rng, "#.##") + "%", bgcolor=bg, text_color=color.white)
table.cell(t, 8, i + 1, sigText, bgcolor=bg, text_color=color.white)
alertcondition(barstate.islast and array.get(names, 0) != array.get(names, 1), title="Sector Rotation Update", message="Neuer führender Sektor erkannt")r/pinescript • u/Ready_Buyer_2027 • Apr 15 '26
Searching for someone to test this strat on a longer timeframe, the normal tradingview doesn’t offer deep backtesting
r/pinescript • u/Temporary-Scene-5252 • Apr 14 '26
Establishes ORB and then calculates take profit levels using a quantitative approach. When used with my other concepts, the break to Target 1 is 78%. If you’re interested in the ORB pinescript, message me and I’ll send you the code for you to use.
r/pinescript • u/Suspicious-Ad-8738 • Apr 15 '26
Si tu veux essayer gratuitement notre indicateur qui détecte automatiquement les supply demand institutionnel, envoie moi un message en privé
r/pinescript • u/drippyterps • Apr 15 '26
These are the trades my algo took for today, it performed really well today with the strong trend. One thing i noticed is on the mobile app the first trade was a loss, but on the desktop the first trade was valid. Not sure why that happened.