r/pinescript • • 20h ago

tradingview在错误的道路上越走越远了

2 Upvotes

作为一个运行了这么多年的专业交易平台,不去思考如何让更多专业交易员选择平台,相反,却将更多潜在的优质客户推的更远——我这里指的不仅仅是Basic用户,更多的是各类型的付费用户。
数据的及时性、指标数量和运行速度及对开发者的限制、UI的稀烂设计......太多问题了。我都怀疑他们目前的内部运营是不是出了问题?为什么让不做交易或者不懂交易的人,负责这些决策?


r/pinescript • • 21h ago

Feature Request: Global Drawing Synchronization Groups Across Multiple Layouts

Thumbnail reddit.com
1 Upvotes

r/pinescript • • 2d ago

Free Pinescript backtester you can hand to AI agents to auto-tune your strategy

Post image
29 Upvotes

We got tired of changing one input, waiting, testing, changing another, so we built PineStorm. You paste your Pine strategy and it backtests it on the whole Binance history.

• Full history, from the first candle, 1m to 1w

• Fast: 2.5 million 1-minute candles in about a second

• Auto-tune: hand it to Claude Code or Codex and it tunes your inputs for you. One run did 1,344 backtests in 28 minutes.

It's free, and you can try it right in the browser. Crypto only for now. Would love to hear what you think and what you'd want added.

https://pinestorm.dev/playground


r/pinescript • • 2d ago

The 1-Hour EMA Pullback Strategy for Part- Time Traders: Rules, 3-Year Test Data on SPY/QQQ, and Pine Script v5 Code

44 Upvotes

Update 1: As pointed out in the comments, the code posted has a discrepancy with the initial text summary (it uses 1.5 ATR stops, 10% equity sizing, and no friction). When adjusted for commissions, slippage, and overnight hold risk, the numbers compress substantially. Appreciate the sharp eyes from NJ_Algo and others.

Update 2: As NJ_Algo noted, the code above is raw/frictionless. For anyone testing a live-style setup, set commission_value = 0.05 (or your broker's rate), slippage = 1, and anchor the stop to ta.lowest(low, 10) rather than ATR.

Original post: Hey everyone,

If you trade while working a standard 9-to-5, trying to scalp on 1-minute or 5-minute charts is usually a recipe for burnout and bad fills.

Over at StratOwl, we spend a lot of time running simulation data to find setups that fit working schedules. One of the most consistent setups we evaluate on index ETFs is a 1-Hour EMA Pullback + RSI Invalidation system.

With 1-hour candles on US equities (6.5 candles per session), you only need to check your charts or alerts a few times a day—or let an alert ping you when a bar closes.

Here is the complete setup breakdown, the simulated metrics across 3 years, and the full Pine Script v5 code.

---

1. The Strategy Concept

Most pullback strategies fail because they buy too early during a sharp drop. This setup requires three confirmations:

  1. Macro Trend (Higher Timeframe Filter): Price must be trading above the 200 EMA on the 1-hour chart.

  2. Dynamic Value Zone: The 20 EMA must be above the 50 EMA (bullish alignment), and price must pull back to touch the zone between the 20 and 50 EMA.

  3. Trigger: RSI(14) must cross back above 45 from oversold/neutral territory, confirming momentum is resuming rather than breaking down into a deeper reversal.

Exits:

* Target: 2.0x ATR(14) from entry (or close when RSI crosses above 70).

* Stop Loss: 1.5x ATR(14) below the recent 10-bar swing low.

* Max Hold: If neither TP nor SL is reached within 18 hourly bars (~3 trading sessions), exit at market close to free up capital.

---

2. 3-Year Simulation Results [SIM Data: 2023 – 2026]

Tested strictly on 1H regular trading hours (RTH) with simulated execution on next-bar open:

| Metric | SPY (1H) | QQQ (1H) | AAPL (1H) |

| :--- | :--- | :--- | :--- |

| Win / Strike Rate | 68.2% | 64.7% | 59.3% |

| Total Closed Setups | 66 | 71 | 54 |

| Profit Factor | 1.92 | 1.81 | 1.46 |

| **Max Drawdown [SIM]**| -6.8% | -9.4% | -11.2% |

| Avg Hold Duration | ~8.4 hours | ~7.9 hours | ~9.1 hours |

---

3. What Worked & What Didn't

* Why the 200 EMA filter matters: Without the 200 EMA filter, the win rate on QQQ dropped from 64.7% to 51.2%. Buying pullbacks in a macro downtrend gets you caught in "falling knife" rallies.

* The Time-Stop Advantage: The 18-bar time stop cut maximum drawdown by nearly 30% across all tickers. In trading, dead money in a non-moving setup is often followed by a volatility spike against your position.

* Gap Risk: Because this is an hourly swing setup, holding overnight exposes you to opening gaps. Using position sizing pegged to 1% account risk per ATR stop absorbed gap slippage without wrecking the equity curve.

---

4. Pine Script v5 Code

Here is the clean TradingView script if you want to inspect the candles or run it on your own watchlist:

//@version=5

strategy("1H EMA Pullback & Momentum [SIM]", overlay=true, margin_long=100, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// Inputs

ema_fast_len = input.int(20, "Fast EMA")

ema_mid_len = input.int(50, "Mid EMA")

ema_slow_len = input.int(200, "Macro Trend EMA")

rsi_len = input.int(14, "RSI Length")

atr_len = input.int(14, "ATR Length")

tp_mult = input.float(2.0, "TP (ATR Multiplier)")

sl_mult = input.float(1.5, "SL (ATR Multiplier)")

max_bars = input.int(18, "Max Hold Bars")

// Indicators

ema20 = ta.ema(close, ema_fast_len)

ema50 = ta.ema(close, ema_mid_len)

ema200 = ta.ema(close, ema_slow_len)

rsi = ta.rsi(close, rsi_len)

atr = ta.atr(atr_len)

// Conditions

macro_bull = close > ema200 and ema20 > ema50

in_pullback_zone = low <= ema20 and low >= ema50 or (close <= ema20 and close >= ema50)

rsi_trigger = ta.crossover(rsi, 45)

long_entry = macro_bull and in_pullback_zone and rsi_trigger

// State tracking

var float entry_price = na

var float sl_level = na

var float tp_level = na

var int entry_bar = 0

if (long_entry and strategy.position_size == 0)

entry_price := close

sl_level := close - (atr * sl_mult)

tp_level := close + (atr * tp_mult)

entry_bar := bar_index

strategy.entry("Long", strategy.long)

if (strategy.position_size > 0)

// Dynamic Exit: TP, SL, or Time-based expiry

strategy.exit("Bracket Exit", "Long", stop=sl_level, limit=tp_level)

// Time-based exit

if (bar_index - entry_bar >= max_bars)

strategy.close("Long", comment="Time Stop")

// Plotting

plot(ema20, "20 EMA", color=color.new(color.blue, 0))

plot(ema50, "50 EMA", color=color.new(color.orange, 0))

plot(ema200, "200 EMA", color=color.new(color.white, 20), linewidth=2)

plot(strategy.position_size > 0 ? sl_level : na, "SL", color=color.red, style=plot.style_linebr)

plot(strategy.position_size > 0 ? tp_level : na, "TP", color=color.green, style=plot.style_linebr)

---

Questions & Ticker Requests

I build simulation engines and automated setup monitors at StratOwl so traders don't have to watch charts all day.

If you want to see how this 1-hour setup performs on a specific stock or crypto ticker you trade (e.g., TSLA, AMD, NVDA, SOL), drop the ticker in the comments and I'll run the 3-year numbers for you.


r/pinescript • • 2d ago

process_orders_on_close: next-open fills, signal-bar close fills, and the session last-bar gap

1 Upvotes

Default strategy fill timing is easy to miss until live results diverge from the report.

On historical bars a Pine strategy runs once, at bar close. So that historical and realtime stay consistent, strategies also run at the close of realtime bars by default. The next moment the broker emulator can fill a market entry is the open of the following bar. That is why a crossover at the close of bar N shows a fill on bar N+1 in the report.

process_orders_on_close = true (or "Fill orders / On bar close" in Properties) changes that model: the emulator treats the close of the signal bar as the fill price. strategy.close(..., immediately = true) does a similar thing for that one close only, without flipping the whole strategy.

Where it bites

  • Session last bar: if a signal fires at the final close of the session, a real broker can usually act only on the next session open. The emulator with process_orders_on_close can still book a fill at that session's close. That gap is classic repaint between report and live.

  • Alerts vs fills: an alert at bar close is not the same as a guaranteed exchange fill at that printed close. Bid/ask, latency and the next tradable price sit in between.

  • Mixing models: same-bar exits via stop/limit prices (broker emulator path assumptions) are a different mechanism from forcing market fills on the signal bar's close. Turning both knobs without separating them muddies what the backtest is actually testing.

A rough rule: leave process_orders_on_close, calc_on_every_tick and calc_on_order_fills at false unless the strategy is intentionally an intrabar or close-fill system, and then forward-test that model on purpose instead of treating the report as exchange truth.

Reference: TradingView Pine Script v6 FAQ, Strategies → "Why are my orders executed on the bar following my triggers?" and the repainting notes on strategy properties.

For those who run close-fill strategies in production: do you keep process_orders_on_close on for the whole script, or only use immediately = true on selected closes?


r/pinescript • • 3d ago

I backtested the MACD Momentum swing strategy across SPY, NVDA, and AAPL over 5 years. Here are the real win rates, drawdowns, and where it failed

Thumbnail reddit.com
2 Upvotes

r/pinescript • • 4d ago

A TradingView response the Pine Script community may find interesting

Thumbnail reddit.com
1 Upvotes

r/pinescript • • 4d ago

Tradingview is now restricting free users from drawing on charts???

Thumbnail
reddit.com
2 Upvotes

r/pinescript • • 5d ago

TV is cooked

Post image
14 Upvotes

It isn’t listed on TradingView’s pricing page or in any of the free-plan guides published September–November 2026. All of those talk about the 2-indicators-per-chart limit, but none mention a saved-script cap.


r/pinescript • • 5d ago

BUYER ALERT: Aston Gill Trading, I paid 499 USDT, still haven’t received everything promised, and remain blocked on Discord

Thumbnail gallery
3 Upvotes

r/pinescript • • 5d ago

var vs varip on the realtime bar: rollback, intrabar persistence, and the repaint trap

3 Upvotes

A common source of "it worked on history, it acts weird live" is assuming var and varip differ only in name. On historical bars they usually behave the same. On realtime bars they do not, and the difference is rollback.

var: persists across bars, not across ticks

A var variable keeps its value from bar to bar. But on an open realtime bar, each new tick triggers a rollback before the script runs again: var variables are reverted to their committed state as of the previous bar's close. Only what the script assigns on the bar's closing tick is kept.

So something like var int ticks = 0 / ticks += 1 in an indicator still ends each realtime bar exactly one higher than the previous bar, no matter how many ticks arrived. A tick-by-tick counter or a "already did X this bar" flag in a var gets wiped before every new tick.

varip: escapes rollback

varip ("intrabar persist") is not rolled back. Every change on every tick sticks, and it carries into the following bars until you reassign it. It does not reset at bar close. If you want per-bar intrabar state (ticks seen this bar, intrabar high of some metric, a once-per-bar guard), you have to reset it yourself, for example when barstate.isnew is true.

Where it bites

  • Repainting by design: after the script reloads, elapsed realtime bars become historical bars with no intrabar tick data. Anything derived from varip can produce different values, alerts or strategy results after a reload than it showed live.

  • Strategies: by default a strategy executes once per bar even in realtime, so varip behaves like var. Enable "On realtime bar tick" or "On order fill" and it diverges, and with "On order fill" it can even diverge on historical bars, because the emulator executes again on fills.

  • UDT fields: a varip variable holding a user-defined type object does not make the fields intrabar-persistent. Each field needs its own varip in the type declaration.

  • Type support: varip only works with fundamental types, enums, chart.point / footprint / volume_row, UDTs, and collections of those, so you can't use it to hold line or label IDs.

A rough rule: confirmed, cross-bar state goes in var and only means something at bar close; intrabar bookkeeping goes in varip with an explicit new-bar reset, and anything that feeds signals or alerts from varip should be treated as repainting unless proven otherwise.

Reference: TradingView Pine Script v6 docs, "Variable declarations → Declaration modes" and "Execution model → Realtime bars".

For those who use varip in production indicators: do you keep its output strictly out of alert conditions, or have you found a pattern that makes the intrabar state reproducible after a reload?


r/pinescript • • 7d ago

Free Trading Indicator - Achilles Simplified Trading

24 Upvotes

I have been developing a trading system (free). The entire trading system (all free) can be found on tradingview.

I am sharing it here: https://www.tradingview.com/script/0cUmz20G-Achilles-ST-Simplified-Trading/

Even better when used in combination with Achilles B (Momentum Oscillator): https://www.tradingview.com/script/Dfa5fNQt-Achilles-B/

There are a lot of complex systems behind the indicator, there is a guidebook for it for all those who are interested: https://achillestrading.com/guidebook/Achilles-Guidebook.pdf

All free


r/pinescript • • 7d ago

Are the updated TradingView tick-based calculations available in pinescript?

Thumbnail
reddit.com
1 Upvotes

Is the updated TradingView "Tick-based calculations are now available for Footprint, Volume Delta, and CVD" also available via the pinescript request.footprint call ?

https://www.tradingview.com/blog/en/tick-based-calculations-footprint-volume-delta-cvd-62523/

Thanks!


r/pinescript • • 8d ago

best ai for writing pinescript?

4 Upvotes

been testing a few and keep getting scripts that repaint or throw errors on the first bar. curious what you all actually use for this, chatgpt or claude or something else


r/pinescript • • 8d ago

Tilt Simulator psychology script.

Thumbnail
gallery
9 Upvotes

https://www.tradingview.com/script/BV2XAJpU-Stealth-Umbrella-Tilt-Simulator/

This is designed to battle over trading. After a loss or a win it's a good idea to take a little break and let the euphoria settle down. Avoid the trap.


r/pinescript • • 8d ago

LuxAlgo worth?

Thumbnail reddit.com
1 Upvotes

r/pinescript • • 8d ago

BTC/ETH option

Thumbnail reddit.com
1 Upvotes

r/pinescript • • 8d ago

pine is honestly the only thing still making it hard for me to leave tradingview

Thumbnail
gallery
65 Upvotes

honestly candles are not why tradingview is hard to leave

its the random pine scripts i've accumulated over the last few years

and the annoying part is most of them aren't even impressive lol

one checks a basic EMA condition and throws an alert

one marks session levels the way i like

one has a VWAP + volume condition i changed probably 15 times

there's one modified public script where i genuinely don't remember what the original version looked like anymore

nothing groundbreaking

but i know how all of them behave

thats the problem

i can move drawings

i can rebuild a layout

i can learn where buttons are on another chart

rebuilding all the little logic i've slowly gotten used to is what makes me go “eh i'll just stay on TradingView”

this was basically the last thing i wanted to figure out before taking TradingCharts by Dhan seriously as an alternative for my setup

TradingCharts uses ChartScript, not Pine

Pine logic can be converted into ChartScript and deployed, so i've started with ONE script i actually use instead of trying to migrate my entire graveyard of saved indicators

and honestly thats probably the better test anyway

because i have like 30 scripts saved

i regularly use maybe 3

moved one of the simpler ones first

then sat with both charts and checked the boring stuff

same condition?

same lookback?

same bar-close behaviour?

signals showing roughly where i'd expect historically?

because if a converted script puts the same green arrows on the first screen that doesnt automatically mean i'm done

i'm not trusting conversion blindly

but this changed the question for me a bit

before it was

“i use Pine so obviously i cant move”

now its more

“can the 3 scripts i actually care about survive the move?”

because the rest of my Indian-market charting is already getting harder to justify paying separately for

and if i'm mainly keeping TradingView alive because 3 small scripts live there...

rebuilding/testing 3 scripts starts sounding less painful than paying forever just because i've always had them there

still think Pine's community side is a huge advantage btw

if your setup depends on 20 community scripts or some complicated custom stack, this is probably a completely different conversation

but curious about people here who have used Pine for years

how many of your saved scripts do you ACTUALLY use every week?

not how many are in favourites

actually use


r/pinescript • • 9d ago

Looking for someone who is passionate about developing Pine Script indicators/strategies on TV

9 Upvotes

Hey everyone!
I'm looking for someone who genuinely enjoys coding and developing indicators or strategies in Pine Script.
The idea isn't anything crazy or overly complicated. I've been trying to build it myself with the help of AI, but honestly, I've reached a point where I'm just going in circles and not getting the exact result I'm looking for.
I figured it would be better to connect with someone who actually knows their way around Pine Script and enjoys this kind of stuff.
I'm not looking to hire someone for a big paid project. I'd rather find someone who's passionate about coding and interested in collaborating.
What do you get in return? A pretty useful confirmation indicator that I believe could be valuable for your own trading as well.
If this sounds interesting, feel free to drop a comment or shoot me a DM. I'd be happy to explain the idea in more detail.
Thanks!


r/pinescript • • 9d ago

Open sourced. Sonar battery.

Post image
11 Upvotes

Sonar Battery: A volume-gated Volatility meter that predicts the breakout bias.


r/pinescript • • 9d ago

Fixed RSI levels vs adaptive ones: why 70/30 fails exactly when you need it

12 Upvotes

TL;DR: RSI 70/30 assumes every market behaves the same. It doesn’t. In strong trends RSI can sit above 70 for weeks, and in quiet ranges it barely reaches 70 at all. Adapting the levels to the market usually works better than the fixed ones.

Where 70/30 breaks

In a strong uptrend, RSI above 70 isn’t a sell signal. It can stay above the threshold for days or weeks. Shorting every “overbought” reading means fighting against the trend over and over.

In a calm, ranging market, RSI often swings between 40 and 60. The 70/30 levels never trigger, so the indicator goes silent exactly when mean reversion would actually work.

What works better

Shift the levels with the trend. A common rule of thumb: in uptrends RSI tends to hold roughly 40-80, in downtrends roughly 20-60. A pullback to 40 in an uptrend can be the real buy zone, not 30.

Use percentiles instead of fixed numbers. Instead of “above 70”, ask “is RSI in its top 10% of the last few hundred bars?” The level adjusts to each market automatically.

Add a trend filter. Only take overbought signals when price is below a slow MA, and oversold ones when it’s above.

Limitations

Adaptive levels lag too. When a market switches from trend to range, they take time to catch up.

The 40-80 / 20-60 ranges are rules of thumb, not laws. They differ by market and timeframe, so test before trusting them.

RSI is still just one input. It works best combined with something that measures trend or volatility.


r/pinescript • • 9d ago

Same-bar TP and SL in a backtest: what the broker emulator assumes when both are inside one candle

2 Upvotes

A bracket from strategy.exit() with both limit and stop can have both levels inside the range of a single historical bar. The chart only has OHLC, so the emulator has to guess which level was touched first. The guess is documented, and it's worth knowing because it quietly decides a lot of trades on higher timeframes.

From the Strategies page of the Pine docs, on historical bars with default settings:

  • If the open is closer to the high than to the low, the emulator assumes the path was open, high, low, close.

  • If the open is closer to the low, it assumes open, low, high, close.

  • For price-based orders (everything except market orders), it assumes there are no gaps inside the bar, so any price within the bar's range is a valid fill level.

  • If price jumps over your level in the gap between one bar's close and the next bar's open, it fills at the next bar's open, not at your price.

  • When one strategy.exit() call creates both a take-profit and a stop-loss for an entry, only the first one triggered fills and the other is cancelled.

So for a long with both levels inside one candle, the open's position relative to the high and low decides whether you book the win or the loss. On 4H or daily bars with a tight bracket, that can be a real share of your trades, and none of it is based on what price actually did inside the candle.

Ways to reduce the guesswork:

  • use_bar_magnifier = true in strategy() (the "Bar detalization: High" setting, Premium and Ultimate plans) makes the emulator use lower-timeframe OHLC where available. The docs note a 200,000-bar cap on requested lower-timeframe data, so early bars on a long history can fall back to the default assumptions.

  • Count how many trades open and close on the same bar, and check those separately. If removing them changes the picture, the result depends on the path assumption rather than the signal.

  • Don't backtest on Heikin Ashi or Renko prices unless you switch fills to standard OHLC (fill_orders_on_standard_ohlc = true for HA). The docs are explicit that synthetic prices give unrealistic fills.

One more strategy.exit() detail from the same page that catches people: exit calls reserve quantity in code order. If one call takes 19 of 20 shares for a take-profit and a second call places a stop for 20, that stop can only close 1 share.

Do you filter out same-bar entry+exit trades when you evaluate a strategy, or rely on the bar magnifier and accept the lower-timeframe data limit?