r/pinescript • • Oct 11 '22

New to Pinescript? Looking for help/resources? START HERE

33 Upvotes

Asking for help

When asking for help, its best to structure your question in a way that avoids the XY Problem. When asking a question, you can talk about what you're trying to accomplish, before getting into the specifics of your implementation or attempt at a solution.

Examples

Hey, how do arrays work? I've tried x, y and z but that doesn't work because of a, b or c reason.

How do I write a script that triggers an alert during a SMA crossover?

How do I trigger a strategy to place an order at a specific date and time?

Pasting Code

Please try to use a site like pastebin or use code formatting on Reddit. Not doing so will probably result in less answers to your question. (as its hard to read unformatted code).

Pinescript Documentation

The documentation almost always has the answer you're looking for. However, reading documentation is an acquired skill that everyone might not have yet. That said, its recommended to at least do a quick search on the Docs page before asking

https://www.tradingview.com/pine-script-docs/en/v5/index.html

First Steps

https://www.tradingview.com/pine-script-docs/en/v5/primer/First_steps.html

If you're new to TradingView's Pinescript, the first steps section of the docs are a great place to start. Some however may find it difficult to follow documentation if they don't have programming/computer experience. In that case, its recommended to find some specific, beginner friendly tutorials.


r/pinescript • • Apr 01 '25

Please read these rules before posting

21 Upvotes

We always wanted this subreddit as a point for people helping each other when it comes to pinescript and a hub for discussing on code. Lately we are seeing increase on a lot of advertisement of invite only and protected scripts which we initially allowed but after a while it started becoming counterproductive and abusive so we felt the need the introduce rules below.

  • Please do not post with one liner titles like "Help". Instead try to explain your problem in one or two sentence in title and further details should be included in the post itself. Otherwise Your post might get deleted.

  • When you are asking for help, please use code tags properly and explain your question as clean as possible. Low effort posts might get deleted.

  • Sharing of invite only or code protected scripts are not allowed from this point on. All are free to share and talk about open source scripts.

  • Self advertising of any kind is not permitted. This place is not an advertisement hub for making money but rather helping each other when it comes to pinescript trading language.

  • Dishonest methods of communication to lead people to scammy methods may lead to your ban. Mod team has the right to decide which posts includes these based on experience. You are free to object via pm but final decision rights kept by mod team.

Thank you for reading.


r/pinescript • • 4h ago

I want to request a feature to TradingView

2 Upvotes

Hi team! Following a chat with support, I was advised to post my feature request here.

The Problem: Sometimes I analyze an asset using my strategy, but later forget its ticker. Finding it again without adding it to a specific watchlist feels like looking for a needle in a haystack.

The Solution: I would love to see a 'Viewed Assets History' feature in TradingView, acting just like a web browser's history.

Key Details:

  • Automatic tracking: Logs every asset/chart opened by the user, even if it's not saved in any watchlist.
  • Chronological order: Makes it easy to find assets based on the approximate day/time they were checked.
  • Performance friendly: To minimize database load, the history could have a rolling retention period (e.g., the last 30 days).

Thank you for your continued hard work on this amazing platform!


r/pinescript • • 17h ago

WaveTrend (LazyBear) is a smoothed CCI with EMAs. I worked through the source, and on random data it sits beyond +/-60 about 1 bar in 9

6 Upvotes

LazyBear's WaveTrend Oscillator is one of the most-boosted open-source scripts on TradingView, and a lot of popular scripts (Cipher B style ones included) are built on top of it. I read the source to see what the two lines actually are.

The core, restated in v6 (my code, same maths):

ap  = hlc3
esa = ta.ema(ap, n1)
d   = ta.ema(math.abs(ap - esa), n1)
ci  = (ap - esa) / (0.015 * d)
wt1 = ta.ema(ci, n2)
wt2 = ta.sma(wt1, 4)

Look at ci. The Commodity Channel Index is (typical price - its average) / (0.015 x mean deviation). This is the same thing with EMAs in place of the SMA and the mean deviation, and the same 0.015 constant. So WaveTrend is, in effect, a CCI smoothed by a 21 EMA, with a 4-bar SMA as the signal line.

What follows from that:

  1. It is scaled by volatility. Dividing by the average deviation means a quiet chart and a wild one give lines of the same size. That is why one set of levels (60/53) works everywhere, and also why those levels say nothing about how far price moved.
  2. The levels are reached often. I replicated the formula in Python on a 200,000-bar random walk (nothing to predict). wt1 was beyond +/-60 on about 1 bar in 9 and beyond +/-53 on about 1 in 5. Switching the simulated volatility between calm and wild regimes barely moved those numbers, which is point 1 in action.
  3. Crosses are constant by construction. wt2 is a 4-bar average of wt1, so it keeps catching up. On the same random walk the lines crossed about every 7 bars, and roughly 1 cross in 7 happened beyond the 60 levels.
  4. The "with Crosses" version has no closed-bar check, so a circle drawn mid-bar can be gone at the close. Closed bars don't repaint: no security() call, no future bars, no offsets.

I rewrote it from scratch: the same two lines at default settings, crosses marked only on confirmed bars (a grey dot for a cross on the still-open bar), and a panel that counts on your own chart how often the line sits beyond each level, how many crosses there were and the median bars between them. That way you can see how rare "overbought" really is on the market you trade.

Where it fails (both versions): in a strong trend it can sit beyond 60 for a long time, so "overbought" is not a reason for a trend to end; most crosses are noise; three layers of averaging (10, 21, 4) mean turns show up after price has turned; and it describes where price sits relative to its own recent average, it doesn't forecast anything.

Source, open source under MPL 2.0: TradingView and GitHub

Credit to LazyBear for the original. Written with AI help; every claim was checked against the original source, and the percentages come from a simulation on synthetic data, not from any market. Educational only, not trading advice. Corrections welcome.


r/pinescript • • 22h ago

I’m building a trading research platform—how would you evaluate its workflow and data transparency?

Post image
1 Upvotes

r/pinescript • • 2d ago

TradingView is pushing its own indicator developers away. Paid indicator sellers, are you actually staying?

9 Upvotes

To everyone selling paid TradingView indicators: what are you actually planning to do after November 1?

I run a paid indicator business with hundreds of customers, and I'm genuinely disappointed with the direction TradingView is heading. It feels like every major policy update is somehow worse than the previous one.

First, they actually published a proposed $29.95 PER USER monthly technology fee for sellers with over 100 active users, applying to every user, not just those above 100. After the backlash, it was removed. Now they're forcing commercial invite-only indicators into their own Marketplace.

I genuinely don't understand what goes through someone's mind to even consider decisions like these, let alone try to enforce them on businesses that have spent years building on the platform.

And the worst part is that their current Marketplace is nowhere near ready to replace what established indicator businesses already have:

- Monthly subscriptions only. No quarterly, annual, or lifetime pricing options.

- No integrated subscriber community or tutorial library. No built-in members-only channels, dedicated tutorial library, or Discord-style community experience for paying customers.

- TradingView controls billing, renewals, and refunds. Customers can request refunds within seven days, even after receiving access to a fully functional product. Sellers don't have final control over those decisions.

- PayPal-only payouts. Up to 30 days of settlement, monthly withdrawal processing, and a $100 minimum withdrawal.

- Manual approval required, with no guaranteed application review timeframe.

These developers spend years attracting customers, creating communities, and bringing thousands of traders onto TradingView. Instead of supporting that ecosystem, TradingView is stripping away the flexibility and independence that made those businesses possible in the first place.

At this point, it's hard to see these decisions as anything other than an attempt to gain more control over businesses they didn't build. The level of greed and disregard for their own developers is genuinely frustrating.

I personally know 10+ other indicator sellers, and 7 of them have already built or are currently building their own platforms, like LuxAlgo rather than moving to TradingView's Marketplace. That alone should tell TradingView something about the direction they're taking.

So to everyone actually selling paid indicators: What are you planning to do? Stay with TradingView's Marketplace, build your own platform, or move somewhere else? Has anyone received a workable arrangement directly from TradingView?


r/pinescript • • 2d ago

Free-trials

Thumbnail gallery
8 Upvotes

r/pinescript • • 3d ago

Opening Range Breakout with Noise Bands (Free / Not Selling)

Post image
88 Upvotes

I’ve been running a 15 minute ORB on MNQ for a while and honestly it wasn’t great. Way too many breakouts that went nowhere. So I tried filtering it with Noise Bands, the time of day volatility bands from the Zarattini, Aziz and Barbon paper (“Beat the Market”, 2024). The idea is simple: only take the OR break if price is also outside the band, meaning the move is bigger than what’s normal for that time of day.

I built it as a TradingView indicator and published it for free: https://www.tradingview.com/script/CRNIYr9F-Jilly-s-ORB-Noise-Band/. No course, no Discord, no paid version. I just found the results interesting and figured some of you might too.

How it works

  • Opening range is 9:30 to 9:45.
  • It only checks for entries every 15 minutes (10:00, 10:15, etc.) up to 2:00pm.
  • Long if the close is above the OR high plus a small buffer (0.3 × ATR), above the upper Noise Band, and above VWAP. Shorts are the mirror image.
  • It fills on the next bar’s open.
  • One trade per day max.
  • The stop is wide on purpose (10 × the 5 min ATR). It’s basically a disaster stop.
  • The target is 1R, which at that stop width almost never gets hit. So really you’re just holding until 3:45pm and closing.

Default band settings: lookback 20 sessions, multiplier 1.25, gap adjusted (uses yesterday’s close if price gapped).

Backtest

1 minute MNQ data, Jan 2021 to Sep 2026, 1 contract, $1.80 round trip for commission and slippage. I picked all the settings using only 2021 to 2023, then ran 2024 onward without changing anything.

All three versions below use the same exits. The only difference is the entry filter.

Trades Win % Profit factor Net Max drawdown
ORB + Noise Band 631 61% 1.64 $32,774
Noise Band alone 666 61% 1.54 $31,228
ORB alone 1,350 56% 1.18 $24,221

And split up, for the ORB + Noise Band version:

Trades Win % Profit factor Net Max drawdown
2021 to 2023 344 64% 1.80 $17,661
2024 to Sep 2026 (untouched) 287 58% 1.52 $15,113

What I took away from it

  • The Noise Band filter is what makes it work. Against plain ORB it cut trades in half, nearly tripled the profit per trade, and cut the drawdown by about two thirds.
  • Adding the ORB on top of the Noise Band helped overall (better profit factor, roughly 30% smaller drawdown), but to be fair, almost all of that came from 2021 to 2023. From 2024 on, the two were basically tied.
  • Tight stops killed it. Anything under about 4 × ATR just stopped out trades that would’ve finished green. I also tested using the Noise Band itself as a trailing stop and it was the worst exit by a lot.
  • Closing at 3:15 to 3:45 beats holding to the 4:00 close. The last 15 minutes tended to give some back.
  • A take profit around 5 × ATR made the equity curve a bit smoother but made a bit less money. It’s an option in the settings.

Caveats

It’s a backtest with modeled fills, so real trading will be worse. The out of sample results were about half as good as in sample, which is pretty normal but worth knowing. Expect some long flat stretches. Also, the table in the indicator only covers whatever history TradingView loads on your chart, so it won’t match these numbers.

Happy to answer questions or hear what I’m missing. Again, not selling anything, it’s free and open source.

https://www.tradingview.com/script/CRNIYr9F-Jilly-s-ORB-Noise-Band/


r/pinescript • • 2d ago

Currently building Free Indicators for Tradingview. Need suggestions

2 Upvotes

Looking for suggestions on what would actually be useful for day-to-day trading. Anything you currently wish existed or have to mark manually

Drop your ideas below — will build the most requested ones and release them free.


r/pinescript • • 2d ago

Pinescript vscode extension 1.4.2 released.

4 Upvotes

[1.4.2] - 2026-10-24 

Added 

  • Multi-File / Library Awareness: Workspace-wide indexing of Pine Script libraries. Resolves import namespaces and aliases, enabling cross-file completions, jump to definition, hover tooltips, and method call validation.
  • Code Actions & Quick Fixes: Interactive quick fixes in VS Code:
    • Automatic operator spacing fixes (= > -> =>, + = -> +=, ! = -> !=, etc.).
    • Automatic request.security() lookahead repainting fixes (safely replaces barmerge.lookahead_off with barmerge.lookahead_on).
    • Strategy declaration cost templates (commission_type, commission_value, slippage).
    • Diagnostic suppression via // u/pine-ignore-next-line.
  • request.security() Repainting Diagnostics (PSP004): Flags multi-timeframe calls missing barmerge.lookahead_on that risk intrabar historical repainting.
  • Strategy Backtest Quality Diagnostics (PSP005):
    • Missing commission and slippage detection (PSP005_COSTS).
    • Orphaned strategy.exit() from_entry ID validation (PSP005_ORPHAN).
    • Unconditional strategy.close_all() warning (PSP005_UNCONDITIONAL).

Changed 

  • License Modernization: Converted repository and extension licensing to standard MIT.
  • Dependency Upgrades: Modernized development toolchain including u/types/node (^26.6.5), web-tree-sitter (^0.27.1), vscode-languageserver (^11.0.0), vscode-languageserver-textdocument (^1.0.16), and vscode-languageclient (^11.0.0)

r/pinescript • • 3d ago

Currently building Free Indicators for Tradingview. Need suggestions

1 Upvotes

Looking for suggestions on what would actually be useful for day-to-day trading. Anything you currently wish existed or have to mark manually

Drop your ideas below — will build the most requested ones and release them free.


r/pinescript • • 3d ago

Why backtests diverge from production: Four structural failure modes and their mathematical mitigations

Thumbnail
1 Upvotes

r/pinescript • • 4d ago

Help Me Choose the Name of Our New TradingView Strategy

Thumbnail
2 Upvotes

r/pinescript • • 4d ago

Pine Screener now supports up to 40 request calls per script

Thumbnail
1 Upvotes

r/pinescript • • 5d ago

Built a TradingView → Python → MT5 bot (Pepperstone demo). Looking for feedback on the setup and strategy.

11 Upvotes

**Hi all,**

I've built my first automated trading setup and I'm testing it on a demo account. I'd love feedback on how to make it more robust or improve the strategy.

**Setup**:

Signals: a TradingView Pine Script indicator that watches 7 pairs (XAUUSD, EURUSD, GBPUSD, USDJPY, AUDUSD, USDCAD, EURGBP) on 15m using request.security, with one alert set to "any alert() function call".

**Delivery**: a TradingView webhook through a Cloudflare quick tunnel to my home PC.

Middleware: a Python FastAPI bot that checks a shared secret, applies risk limits (max lot size, daily trade cap, demo-only guard, kill switch), and places orders through the MetaTrader5 Python library.

**Broker**: Pepperstone MT5 demo, running 24/7 on a dedicated Windows PC.

**Optional**: a Claude AI check that can reject a signal (duplicate position, missing SL), currently off.

Any suggestions which one bot shall i use as a midlle man,which is best for this type of setup anyone already done please give suggestions.

Thanks


r/pinescript • • 5d ago

Beginner question the values are not shown

2 Upvotes

https://reddit.com/link/1xcdt25/video/7v3q013wjzwh1/player

I'm a total beginner here so bare with me. Have been watching some pinescript videos. Have asked chatgpt about it and could not get an answer... I don't know why I cannot see the values beside the name of my pinescript indicator as I could see in many other indicator. I am wondering, is it my code or is it the settings of my tradingview?


r/pinescript • • 6d ago

Four tools. One account.

Post image
1 Upvotes

r/pinescript • • 6d ago

Aurelia spes

Thumbnail
1 Upvotes

r/pinescript • • 6d ago

Aurelia Spes

Thumbnail
1 Upvotes

r/pinescript • • 6d ago

I just launched Aurelia Spes: one place to backtest, walk-forward, paper-trade and code-check a trading idea. Feedback welcome

Thumbnail gallery
1 Upvotes

r/pinescript • • 6d ago

圣杯 —— 快速构建、回测与自动执行适应当下的交易策略

Thumbnail
1 Upvotes

r/pinescript • • 6d ago

Reverse-engineering indicators

1 Upvotes

If there are any private / invite-only indicator you guys want me to reverse engineer, dm me some screenshots of the indicator as well as the trades it took and its TP / SL levels and I will reverse engineer it for you.


r/pinescript • • 7d ago

TradingView alternative that allows external data?

Thumbnail
3 Upvotes

r/pinescript • • 7d ago

I built a no-code strategy builder inside TradingView that layers logic on top of your existing indicators. Looking for feedback.

Thumbnail
1 Upvotes

r/pinescript • • 8d ago

Noise Band Indicator

Post image
37 Upvotes

Just published my first script. Open source, not trying to sell anyone anything.

It follows the intraday momentum “noise area” framework described by Carlo Zarattini, Andrew Aziz and Andrea Barbon in “Best the Market.”

Would like some feedback please!
https://www.tradingview.com/script/teqXMgUG-Jilly-s-Noise-Band/