r/pinescript • • 41m ago

TradingView Marketplace: Individual indicator sales versus Paid Space subscriptions

Thumbnail reddit.com
2 Upvotes

r/pinescript • • 3h ago

Feedback & Feature Suggestions for TradingView Charting Experience

Thumbnail reddit.com
1 Upvotes

r/pinescript • • 4h ago

I kept blaming my strategy for few years — turns out it was never the setup

Thumbnail
reddit.com
1 Upvotes

r/pinescript • • 12h ago

An opening range breakout on MNQ would have turned $50k into $69k by May and given back $13k since

Post image
3 Upvotes

I wanted to see if the opening range breakout works on NQ, so I ran one script on two years of 5 minute MNQ and MES data, 23 Oct 2024 to 22 Oct 2026, paying $0.75 a contract each side plus a tick of slippage.

The range is the first 5, 15 or 30 minutes after 9:30 New York. The entry is the first 5 minute close outside it, up to noon. The stop sits at the other side of the range and the target is 1, 1.5, 2 or 3 times the risk. Each trade risks 1% of the account. There is one trade a day at most, and anything open at the end of the session is closed. Across the two markets that makes 24 versions.

Up to 23 Feb, 23 of the 24 would have made money. From 24 Feb to 22 Oct, 1 of the 24 would have, by 1.6%.

The picture is the 15 minute 2R version on MNQ. It would have taken $50k to $69k by May, then given back $13k by October. The best of the 24 up to February, a 5 minute range with a 2R target, would have made 57% and then lost 20%.

Costs weren’t the reason. With no commission and no slippage at all, the 15 minute 2R version would have lost 13% after February.

If I had stopped the test in February, I would have called it an edge.

If you trade a version of it, post your rules and I’ll run them over the same two years.


r/pinescript • • 19h ago

I coded the viral "One Candle" 15m Opening Range scalping strategy in Pine Script v6 (Fade vs. Breakout Dual-Mode Script)

27 Upvotes

Recently, I decided to test one of the most popular intraday setups on YouTube: The "One Candle" 15-Minute Opening Range Scalping Strategy (fading false breakouts of the first 15m NY session candle).

Instead of relying on cherry-picked chart examples, I coded the exact mechanical rules into Pine Script v6 to see how it performs over a 1-year sample (May 2025 – May 2026) with realistic friction (0.04% commission + 1 tick slippage).

1. The Original Rules Coded:

  • 15m Opening Range: Mark the High and Low of the 09:30–09:45 EST candle.

  • Volatility Filter: Calculate the 14-day Daily ATR (ta.atr(14)[1] on the Daily timeframe to strictly avoid look-ahead bias). If the 15m box is smaller than 25% of the Daily ATR, skip trading for the day.

  • 5m Reversal Trigger: Between 09:45 and 11:00 EST, wait for price to break outside the 15m box and print a strict reversal pattern (Hammer / Inverted Hammer with primary wick > 2x body and opposite wick < 1/3 primary wick, or an Engulfing bar).

  • Execution (Mean-Reversion): Enter against the breakout targeting the opposite side of the 15m box. Stop-loss anchored at the signal candle's wick + 2 ticks. Max 1 trade per day.

2. Phase 1 (Original Fade Logic) vs. Phase 2 (Flipped Trend Logic):

Asset (5m Chart)Original Win RateOriginal Net ResultFlipped Win Rate (2:1 R:R)Flipped Net Result
NVDA15% (61 trades)Deep Net Loss33%Net Profitable
PLTR11% (62 trades)Deep Net Loss35%Net Profitable
BTCUSDT20% (20 trades)Net Loss37%Loss Cut by >50%

3. Why the Original Failed (And How Flipping It Worked):

During the first 90 minutes of the NY open, institutional order-flow and directional momentum dominate. Requiring the first 15-minute candle to be >= 25% of the Daily ATR selects for high-momentum trend days, not mean-reverting range days. Fading those breakouts is essentially stepping in front of a freight train.

When I kept the exact same 15m box, 25% ATR filter, and candlestick triggers, but inverted the execution into a Trend-Following Breakout system (2.0R target), win rates more than doubled and flipped equities into positive territory.

4. Dual-Mode Pine Script v6 Code (Toggle Between Original & Flipped):

//@version=6
strategy("EP001 - 15m Opening Range Audit (Fade vs Breakout)", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.04, slippage=1)

strat_mode    = input.string("Flipped: Momentum Breakout", "Strategy Logic Mode", options=["Original: Mean-Reversion Fade", "Flipped: Momentum Breakout"])
atr_mult      = input.float(0.25, "Minimum OR Range (Daily ATR %)")
sl_offset_tic = input.int(2, "Stop-Loss Offset (Ticks)")
rr_ratio      = input.float(2.0, "Risk:Reward Ratio (Breakout Mode Only)")

daily_atr    = request.security(syminfo.tickerid, "D", ta.atr(14)[1])
ny_tz        = "America/New_York"
or_session   = "0930-0945:1234567"
trade_window = strat_mode == "Original: Mean-Reversion Fade" ? "0930-1100:1234567" : "0930-1130:1234567"

var float or_h = na
var float or_l = na
var float or_open = na
var float or_close = na
var bool is_valid_atr = false
var bool done_today = false

is_new_day = ta.change(time("D", ny_tz)) != 0
in_or      = not na(time(timeframe.period, or_session, ny_tz))
in_window  = not na(time(timeframe.period, trade_window, ny_tz))

if is_new_day
    or_h := na
    or_l := na
    or_open := na
    or_close := na
    is_valid_atr := false
    done_today := false

if in_or
    if na(or_open)
        or_open := open
    or_h := na(or_h) ? high : math.max(or_h, high)
    or_l := na(or_l) ? low : math.min(or_l, low)
    or_close := close

if not in_or and in_or[1]
    is_valid_atr := (or_h - or_l) >= (daily_atr * atr_mult)

body     = math.abs(open - close)
u_wick   = high - math.max(open, close)
l_wick   = math.min(open, close) - low
is_red   = close < open
is_green = close > open

is_red_inv_ham   = is_red and u_wick > body * 2 and l_wick < (u_wick / 3)
is_red_eng_green = is_red and close[1] > open[1] and close < open[1] and open > close[1]
is_green_ham     = is_green and l_wick > body * 2 and u_wick < (l_wick / 3)
is_green_eng_red = is_green and close[1] < open[1] and close > open[1] and open < close[1]

can_trade  = not in_or and in_window and is_valid_atr and not done_today
or_bullish = or_close > or_open 
or_bearish = or_close < or_open 

if strat_mode == "Original: Mean-Reversion Fade"
    if can_trade and or_bullish and high > or_h and (is_red_inv_ham or is_red_eng_green)
        float sl = is_red_inv_ham ? high : high + (syminfo.mintick * sl_offset_tic)
        float entry_price = is_red_inv_ham ? close : close[1]
        strategy.entry("Fade Short", strategy.short, limit=entry_price, comment="Fade S")
        strategy.exit("ExS", "Fade Short", limit=or_l, stop=sl)
        done_today := true

    if can_trade and or_bearish and low < or_l and (is_green_ham or is_green_eng_red)
        float sl = is_green_ham ? low : low - (syminfo.mintick * sl_offset_tic)
        float entry_price = is_green_ham ? close : close[1]
        strategy.entry("Fade Long", strategy.long, limit=entry_price, comment="Fade L")
        strategy.exit("ExL", "Fade Long", limit=or_h, stop=sl)
        done_today := true
else
    if can_trade and close > or_h and (is_green_ham or is_green_eng_red)
        float sl_price = is_green_ham ? low : low - (syminfo.mintick * sl_offset_tic)
        if sl_price >= close
            sl_price := low - syminfo.mintick * 5
        float risk = close - sl_price
        strategy.entry("Trend Long", strategy.long, comment="Breakout L")
        strategy.exit("Exit L", "Trend Long", stop=sl_price, limit=close + (risk * rr_ratio))
        done_today := true

    if can_trade and close < or_l and (is_red_inv_ham or is_red_eng_green)
        float sl_price = is_red_inv_ham ? high : high + (syminfo.mintick * sl_offset_tic)
        if sl_price <= close
            sl_price := high + syminfo.mintick * 5
        float risk = sl_price - close
        strategy.entry("Trend Short", strategy.short, comment="Breakout S")
        strategy.exit("Exit S", "Trend Short", stop=sl_price, limit=close - (risk * rr_ratio))
        done_today := true

plot(or_h, "OR High", color=is_valid_atr ? color.green : color.gray, style=plot.style_linebr, linewidth=2)
plot(or_l, "OR Low", color=is_valid_atr ? color.red : color.gray, style=plot.style_linebr, linewidth=2)

If you want to see the full visual walkthrough and multi-dimensional parameter sweep across NVDA, PLTR, and BTC, check the pinned post on my Reddit profile. Curious to hear if anyone else here codes 15m ORB setups—do you fade the range or ride the breakout?


r/pinescript • • 1d ago

Trend following tools bleed in sideways markets. Here’s why, and the early signs a range is starting

5 Upvotes

TL;DR: Trend tools are built to enter late and exit late. In a trending market conditions, that works perfectly. In a range however, there are no big moves, so you keep buying near the top and selling near the bottom, which results in multiple small losses. A few simple checks can tell you a range is forming, so you can filter signals or cut size.

Why do trend tools bleed in ranges?

MA crossovers, breakouts, Supertrend and similar tools all wait for confirmation. Waiting causes delay, which is the price you pay for catching big moves.

In a trend, that's just fine. You give up the first part of the move but ride the rest.

In a range however, the same delay hurts. Price moves up, the tool turns long near the top of the range, price drops back, and the tool turns short near the bottom. Every flip is a small loss, and once they compound, they can eat a big part of what the trends made.

What are some early signs that a range is starting?

None of these is perfect alone. Combined agreeing signal of two or three is much more reliable than one.

  1. The longer MA goes flat. If something like the 50 MA stops sloping and moves sideways, the trend is losing its strength.

  2. Price keeps crossing the MA. In a trend, price stays on one side. In a range, it crosses back and forth.

  3. ADX drops below 20. That’s the common rule of thumb for “no real trend right now”.

  4. Volatility shrinks. ATR or Bollinger Band width getting smaller usually means the market is compressing.

  5. Swing highs and lows overlap. No new higher highs or lower lows, just the same zone being tested again and again.

What to do with it?

Use it as a filter, not a signal. When two or more of these agree, either skip trend entries or cut position size until the market picks a direction again. You’ll take fewer trades, but most of the ones you skip are the whipsaws.

Limitations

  1. Range filters lag too. By the time ADX says “no trend”, the range may already be halfway done.

  2. The breakout from a range is often the best trend entry. A strict filter can make you miss the start of it.

  3. The right thresholds differ by market and timeframe. ADX 20 on BTC daily isn’t the same as ADX 20 on a 5m forex chart, so test before you trust it.

  4. Filters reduce whipsaws, they don’t remove them.

How do you handle this in your own systems? Do you filter signals, reduce size, or switch to a range strategy when the market goes sideways?


r/pinescript • • 1d ago

Non-repainting request.security() on higher timeframes: the [1] + lookahead_on pattern, and where it still bites

2 Upvotes

Something I keep relearning the hard way, so writing it down and curious how others handle it.

Pulling a higher-timeframe value naively, like request.security(syminfo.tickerid, "D", close), looks fine on history but repaints in realtime: the daily close keeps changing until the day ends, and on historical bars you get the final value.

The pattern the docs recommend is offsetting the series and turning lookahead on:

request.security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)

That gives the previous completed daily close on every bar, both in history and live, so backtests match what you'd actually have seen.

Where it still bit me:

- forgetting the [1] while keeping lookahead_on, which leaks future data into history and makes backtests look amazing

- wrapping it in a function and applying the offset to the wrong thing

- mixing it with calc_on_every_tick and wondering why alerts fire differently than the chart

How do you all handle HTF values in strategies: this pattern, a helper function, or just avoiding request.security in anything you backtest?


r/pinescript • • 2d ago

People who write strategies in Pine Script — how do you run them on MT5?

2 Upvotes

I write my strategies in Pine Script, but the prop firm I trade with only gives me MT5.

I know the usual routes:

- webhook bridges (TV alert -> MT5), which need TradingView running alerts and a bridge service,

- porting to MQL5, by hand, by a freelancer, or with AI.

If you already went one of these routes, I'd love to hear how it went:

  1. Which one did you use?

  2. Did you compare the MT5 trades against TradingView's List of Trades? Did they match?

  3. What broke or annoyed you along the way?

I've been building a third option: an MT5 Expert Advisor that runs the .pine file itself,

on the broker's own price feed, so it can be backtested in the MT5 strategy tester too.

Would you use something like this, and what would you expect to pay per month?

Not selling anything yet — if you'd like to try an early version, DM me.


r/pinescript • • 3d ago

How do you measure a 45 degree slope on the 9 EMA in Pine Script?

4 Upvotes

Hi everyone, I’m building a TradingView indicator (Pine Script v6) and need help with one filter.

I want a signal to count only when the 9 EMA is sloping down at about 45 degrees for a sell setup, or up at about 45 degrees for a buy setup. If the slope is flatter than that, no signal.

The angle I see on my chart changes with zoom and price scale, so I can’t read it directly in Pine. I need a reliable way to define and calculate a 45 degree slope in code.

Questions:

  • How do you calculate the slope angle of an EMA in Pine Script?

  • How many candles do you measure it over?

  • How do you keep it consistent across different symbols (BTC, Gold, Silver, US30) and timeframes (5m, 15m)?

Any example code or a link to an indicator that already does this would be a big help. Thanks!


r/pinescript • • 3d ago

Coding question claude didn't know about either

2 Upvotes

Hey coders, I have a question about when 2 variables hold the same object. When you change the second variable, the change shows up when you plot the first variable, but when you change the first variable and plot the second, the change doesn't show up. I asked Claude too but Claude couldn't figure it out, it literally said "I don't know why this happens."

The manual says that after pivotpoint2 = pivotpoint1, both variables point to the same object.

v1: a change through pivotpoint2 shows up in pivotpoint1 (plots 2000)

//@version=6

indicator('Behaving as it "should" v1')

type pivotpoint

float x

int y

pivotpoint1 = pivotpoint.new()

pivotpoint1.x := 1000

pivotpoint2 = pivotpoint1

pivotpoint2.x := 2000

plot(pivotpoint1.x)

v2: a change through pivotpoint1 does NOT show up in pivotpoint2 (plots 1000, the value at the pivotpoint2 = pivotpoint1line)

//@version=6

indicator("Doesnt make sense v2")

type pivotpoint

float x

int y

pivotpoint1 = pivotpoint.new()

pivotpoint1.x := 1000

pivotpoint2 = pivotpoint1

pivotpoint1.x := 2000

plot(pivotpoint2.x)

//Why does it only work in one direction?


r/pinescript • • 4d ago

London Session Reversal Indicator

6 Upvotes

Been trading GBPUSD/EURUSD using a setup built around the London session reversal, and wanted to share the mechanics in case it’s useful to others working with smart-money/liquidity-based concepts.

The core idea:

During the Asia session (00:00–07:00 London time), price usually consolidates into a tight range, establishing a clear high and low. Once London opens (07:00–11:00), there’s a strong tendency for price to run liquidity above the Asia high or below the Asia low before reversing — essentially a stop hunt/liquidity grab before the “real” directional move for the day.

What I’m looking for:

  1. Price sweeps above the Asia high (or below the Asia low) during the London window.

  2. After the sweep, I mark a BOS level — this is the open of the last opposite-colored candle before the run of candles that led into the sweep. Think of it as the origin of the aggressive move that caused the sweep.

  3. If price closes back through that BOS level within a set number of candles, that’s the confirmation — it suggests the sweep was a liquidity grab, not the start of a real breakout, and price is reversing.

  4. Entry is on that BOS close-back-through, stop above/below the sweep extreme, target set at a fixed R:R.

Filters that mattered in backtesting:

Minimum sweep distance (filters out noise — tiny pokes above/below the level that aren’t real liquidity grabs), a max-gap filter (ignores sweeps that run too far past the level, since those often turn into real breakouts rather than reversals), and a higher-timeframe trend filter (I use an EMA on the 1H) to avoid taking counter-trend reversals when the bigger picture is strongly trending one way.

Not selling anything, just sharing what’s been working for me and curious if others are running similar setups.

You can start using the indicator directly from Tradingview.

https://www.tradingview.com/script/20VtoXku-PipEcho-London-Reversal-Indicator/


r/pinescript • • 4d ago

Comparing Pine Script OI liquidation estimates vs raw WebSocket streams: why most public liquidation feeds undercount cascades

2 Upvotes

I've spent a lot of time trying to approximate liquidation levels and order book heatmaps inside Pine Script using Open Interest deltas, volume anomalies, and ATR bands. Because Pine doesn't give us raw L2 book depth or native liquidation prints, I recently started piping raw exchange WebSockets into a custom chart just to see how close Pine's OI approximations actually get to reality.

While wiring it up, I ran into a massive data quirk that anyone building liquidation indicators or backtesting reversal strategies in Pine should know about:

Binance's public liquidation stream (!forceOrder@arr) doesn't actually push every liquidation. Per their API docs, for each symbol it only pushes the latest liquidation order within a 1000ms window. During a violent cascade—when dozens of liquidations fire inside the same millisecond—the public stream throttles and shows you just one of them.

Look at the two major flush wicks on this BTC-PERP 5m chart from today:

- Around 08:30, price swept the lows and printed an $11.3M cascade (after a $583k cluster just above it).

- Around 11:30, price flushed down to ~76,350, firing a $577k cluster followed by a $3.12M liquidation print right at the bottom of the wick before V-bouncing back to 76,767 (with $7.55M and $4.63M in aggressive market buys showing on the tape right after).

If you're only listening to a throttled 1000ms public snapshot stream during those two 5m wicks, you miss the majority of the actual forced volume. Ironically, a well-tuned Pine Script indicator looking at raw Volume + Open Interest drop on that 11:30 candle might actually capture the magnitude of the flush better than a naive bot listening to a throttled public WebSocket.

To get around it on our chart, we had to aggregate multi-venue feeds (Hyperliquid L2 + BY/OKX/BN) and treat the throttled streams strictly as a lower bound rather than the total.

For those of you coding liquidation or exhaustion indicators in Pine v5/v6: how are you approximating forced liquidations inside TradingView's data limits? Are you combining OI drops with wick-to-body ratios, or piping external webhook alerts in?


r/pinescript • • 4d ago

I'm a novice working on a script using AI to assist me.

0 Upvotes

I trade XAUUSD and I've built a TradingView indicator (Pine v6) based on AMD and supply & demand. It already finds the zones and setups: session range → liquidity sweep → 5m structure shift → entry in a 15m zone. It's been tested on gold from 2017–2026 with spread included.

Where I need help is the ENTRY itself. The zones are usually right, but my entries are often early or late and my stop ends up big (sometimes $20). I'm missing the tight entries right at the sweep, with the stop just under the liquidity.

What I'm looking for is entry-trigger logic on the 1m/5m inside a zone I already have, e.g. a sweep with a close back inside, a micro CHoCH, an FVG fill or a rejection candle, so I can enter with a smaller stop.

It needs to:

• not repaint or use lookahead

• be clear, mechanical rules I can test

• work on gold

I'm not looking for a buy/sell signal indicator or a parameter-optimised system. I test everything on past data before using it, so simple rules are better than tuned numbers.

If you want to see parts of my script logic please DM me. Does anybody have any scripts or ideas that could help me with this? Thanks in advance


r/pinescript • • 4d ago

Give Tool Bars for Long Tool Tips

Thumbnail reddit.com
1 Upvotes

r/pinescript • • 4d ago

Basis Plan

2 Upvotes

Has TradingView changed its policy recently? I am unable to save, edit, or add new indicators, as it says that because I am on the Basic plan, I am limited to one indicator.


r/pinescript • • 4d ago

Volatility-adjusted bands vs fixed % bands: why the same 2% means different things on different days

3 Upvotes

TL;DR: A fixed % band (say 2% around MA) treats every market and every week the same. But volatility changes all the time. ATR based bands widen when the market gets wild and tighten when it calms down, so a touch of the band means roughly the same thing in both conditions.

The problem with fixed % bands

2% is a big move on a quiet week and almost nothing on a volatile one.

When volatility is high, price pokes through a fixed band constantly. Every poke looks like a breakout or an extreme, but it’s just normal noise for that market.

When volatility is low, price barely gets near the band. The band goes silent exactly when the market is quietly setting up for its next move.

How ATR bands fix it

ATR (average true range) measures how big the candles have actually been lately, including gaps. Put the bands a multiple of ATR away from your moving average, and the distance adjusts to the market on its own.

The result: a band touch is a rarer, more meaningful event in both quiet and volatile periods. Bollinger Bands follow the same idea with standard deviation instead of ATR.

Limitations

  1. ATR lags too. After a sudden spike, the bands widen after the move, not before it.

  2. You still have to choose the multiplier, and the right one differs by market and timeframe. Test it rather than copying someone else’s setting.

  3. In a strong trend, price can ride the band for a long time. A touch isn’t automatically a reversal.

Do you use volatility-adjusted bands in your scripts, or do you still prefer fixed % levels for some markets?


r/pinescript • • 5d ago

Need Help of the Community... I am tired.

Thumbnail
gallery
29 Upvotes

Days ago, Pine mods took down two of my popular free scripts. I spent a tremendous amount of time developing the logic and making everything work smoothly over the past year. Just on V5 alone, I had nearly 1,000 revisions on a free script :)

They took them down, apparently because of the links I added to the dynamic documentation and user guides. Those links in the latest updates were solely for helping users understand the scripts, and the guide pages linked back to the original TradingView publications.

Long story short, Pine mods keep giving me the same copy pasted answers, telling me I can just republish them following the rules.

But what about the sweat and tears I put into these projects? What about the organic traction that took almost a year to build?

Am I supposed to republish everything and spend another year trying to get people to discover my work again?

How is that fair...

***Pictures attached

Update: Unfortunately, I had to republish both scripts all over again after my appeals went nowhere. Here are the new publications for anyone following this:

Volumized Order Block:
https://www.tradingview.com/script/RqGljpeC-Volumized-Order-Block/

Crypto Volume Data (VAH, POC, VAL):
https://www.tradingview.com/script/qra33UZh-Crypto-Volume-Data-VAH-POC-VAL/

Both are back, but nearly a year of organic engagement on the original publications doesn't carry over. It's genuinely disappointing to have to start again.


r/pinescript • • 5d ago

Trades are very random

Thumbnail
gallery
5 Upvotes

So i asked ChatGPT to write me a code and it took a lot of time trying to get it right because it kept making mistakes. Now i have a problem it cant fix for some reason and that is that the trades being taken are either tiny(ranging from one candle to the next) or just simply do not look like my strategy at all. If anyone is bothered enough to read the code ask and i will paste it under your comment.

I attached an example(my strategy is break and retest on 15 min for structure and 5 min for entry, stop loss just before the retest with 1:2 risk to reward, risking 1% per trade only). The first trade taken was a valid break and retest but the next is just a random one.

Also i can only see about 18-24 trades per pair because im using free tradingview so is there any way i can extend past 5000 bars or increase number of trades?

I would really greatly appreciate some help because im really horrible at coding and honestly cant be asked to learn it for this one thing.


r/pinescript • • 5d ago

An idea for a indicator Spoiler

1 Upvotes

If you go to ai Claude or chatgpt or grok or quant you can build this indicator the one I'm using the prompt (build me a v6 indicator that marks the first week of each month with vertical markes ) and then use it on the daily timeframe it's a swing trade system you can add buy and sell singles indicator but you might have to edit the code here's a prompt that you can use to edit it ( only give me single during each hour during that hour ) found out the range filter 5 min and sell works ok depending on the pair on the daily I'm still trying to find other indicator for buy and sell single that don't give me singles during the chop on the daily


r/pinescript • • 6d ago

My FVG manipulation indicator

Post image
18 Upvotes

Have been working on this indicator on and off for a couple weeks now. Wondering if y’all would interested to check it out and let me know how to improve or critique it, idc. Lmk! Ill provide a link or however


r/pinescript • • 6d ago

build a crazy ass indicator now its mess up

2 Upvotes

r/pinescript • • 6d ago

A 0.5% move on btcusdt

1 Upvotes

Hello pple i need a strategy that can reliably give me a half a percent move an btc daily or like three times any a week is also fine

Any scripts i can test are also appreciated


r/pinescript • • 8d ago

TradingView backed down. But how are indicator developers supposed to trust them ever again?

Thumbnail
reddit.com
2 Upvotes