How to Publish a Pine Script: Open Source, Private and Licences

Advanced6 min read
Metal letterpress type pieces sitting in a wooden printer's tray
Image by Rodney Truitt Jr on Wikimedia Commons, CC0

How Do You Publish a Pine Script on TradingView?

Open the script in the Pine Editor, put it on a chart, and press the “Publish indicator/strategy/library” button in the top-right corner. Enter a title and description, choose whether the script is public or private and whether its code is open, protected or invite-only, then press the final Publish button.

Those choices are hard to undo, so read this guide before you click. It assumes you can already write a script; if not, begin with your first indicator.

What Is the Difference Between Open, Protected and Invite-Only?

TradingView calls this setting “visibility”. It is chosen on the second page of the publish window and cannot be changed after publishing.

VisibilityWho sees the codeWho can use it
OpenEveryoneEveryone
ProtectedOnly youEveryone
Invite-onlyOnly youOnly users you invite

Protected and invite-only scripts need a paid plan. Invite-only authors must write “Author’s instructions” and count as vendors, with extra requirements. Per the documentation, public invite-only scripts are the only published scripts that may require payment. That rule stands on TradingView’s side; ForexR does not sell or endorse scripts.

What Is the Difference Between Public and Private?

  • Public: listed in the community scripts feed and findable by everyone. Moderators review public scripts, and ones that break the rules are hidden. You can edit or delete a public publication only for 15 minutes after you publish it.
  • Private: not searchable, visible only to people with the link. You can always edit or delete it, so it works well as a draft.

A sensible routine is to publish privately first, check how the page looks, then publish a public version when it is ready. Because libraries are always open source, a private library is still imported the same way; functions and libraries covers that.

What Licence Does an Open-Source Script Use?

The documentation says all open-source scripts on TradingView use the Mozilla Public License 2.0 by default. Authors who prefer another licence can state it in the source code. A licence is a set of terms that says what other people may do with your code. Three well-known choices:

  • MPL-2.0: the TradingView default. If someone changes your files and shares them, those files stay under the same licence.
  • MIT: very short and permissive. People may reuse the code if they keep your copyright notice.
  • GPL-3.0: stricter. Shared changes must stay open under the same licence.

Pick one on purpose, write it at the top of the file, and keep it there when you edit. Licence text is legal language, so for anything commercial, ask a qualified person. The same goes for code you copy: how to edit a Pine Script explains how to keep the author’s licence and credit lines.

What Are the House Rules?

Publications must follow TradingView’s House Rules and its Script Publishing Rules. Points from the documentation:

  • Title and description: neither may be empty. The title uses English in standard 7-bit ASCII with no emoji, and avoids all-caps words (except abbreviations), misleading claims and advertising. The description explains what the script does, how it works, how to use it and why it is original.
  • Chart: the script must be active, with only necessary visuals, and the symbol, timeframe and script name visible. Show the default settings.
  • Reuse: reused code must credit the original author, add meaningful improvements and stay open source unless the author agrees otherwise.
  • Strategies: use realistic starting capital, commission, slippage and margin values. The documentation says risking more than 10% of equity per trade is generally not seen as sustainable, and aims for about 100 or more trades in the default setup.

Do not publish a strategy on Heikin Ashi, Renko or Kagi charts, since the documentation excludes non-standard charts for strategies, alerts and trade signals. The reason is the same one in how to backtest a Pine strategy: results must be reproducible.

What Should You Check Before You Press Publish?

  1. Test it: run the script on several symbols and timeframes, and read the error pane. Pine Script errors and limits helps with that.
  2. Credit others: if you reused code, name the author in the description and in the source. The documentation says reuse needs credit and meaningful improvement.
  3. Describe honestly: say when the script fails, such as in a sideways market, and whether it can repaint.
  4. Choose the licence: write it in the source before you publish.
  5. Start private: look at the page, then go public.

How Do You Update a Published Script?

The “Edit” button on the script page changes only the title, description and tags. To change the code, open the publish window and choose “Update existing script” at the top of the first page. Pick the script, add release notes, check the difference viewer, press “Continue”, then press “Publish new version”. Release notes are final once published, so proofread them.

How Do You Share a Script on GitHub Instead?

GitHub is a site where programmers share code. Many authors put the .pine file in a repository next to a README and a licence file. Choose MIT or GPL-3.0 and add the licence text as a LICENSE file in the repository, so anyone who finds the code knows what they may do with it. A short README should say which Pine version the script uses, what it draws, and what its settings do.

Diagram: your script can be published on TradingView as open-source, protected or invite-only, or put on GitHub with a LICENSE file, where the ForexR crawler lists it and shows code if the licence allows
Illustration: TradingView publishing and GitHub are separate routes. Only the GitHub route reaches the ForexR library, and the licence decides whether its page shows the code.
// Prior day levels
// Author: your name
// Licence: MIT (see LICENSE file in this repository)
//@version=6
indicator("Prior day levels", overlay = true)

The comment lines above the version line carry credit and licence. GitHub is also where open-source EAs live; open-source forex EAs on GitHub covers licences for MetaTrader code.

How Does ForexR List Scripts From GitHub?

The ForexR Pine Script Library is a free directory of open-source Pine scripts published on GitHub. A crawler searches GitHub every week for new Pine files, and stars, update dates and licences are refreshed daily. A repository needs at least one star to be listed, and copies of the same code are listed once. Each page links back to the original repository and file.

Whether a page shows the code depends on the licence. Open licences such as MIT, GPL and Apache, or TradingView’s Mozilla Public License 2.0 header, let ForexR show the source. For other files, the page says “The code stays on GitHub” and the Copy script button reads the file from GitHub. So a clear licence line makes your script easier to find and share, and you can see how it will look by browsing the indicators category. How to use the Pine library shows the page from a reader’s side.

Publishing a script does not make it good. ForexR does not test or recommend any script, and a published script can still repaint, overfit or fail in a range. Leveraged forex and CFD trading carries a high risk of loss, so only risk money you can afford to lose.

FAQ

Can I sell a Pine Script on TradingView?

Under the documentation, public invite-only scripts are the only published scripts that may require payment. Open-source, protected and private scripts cannot be sold. Authors of invite-only scripts count as vendors and must meet extra requirements, so read TradingView’s current rules before you set any terms.

Can I change a script from open to protected after publishing?

No. The documentation says visibility and privacy are chosen when you publish and cannot be changed afterwards. If you need a different setting, you have to publish a new script. Decide on the setting before you press publish, and use a private publication as a draft.

Do I need a licence file to put Pine code on GitHub?

Nothing forces you, but without a licence other people have no clear permission to reuse your code. Adding a LICENSE file with MIT or GPL-3.0 text, and a comment at the top of the script, makes the terms plain. For legal questions about licences, ask a qualified person.

Why does my script not show its code in the ForexR library?

The library shows source code only when the licence allows it, such as MIT, GPL, Apache or a Mozilla Public License 2.0 header. With no clear licence, the page says the code stays on GitHub and the Copy script button reads the file from there. A visible licence line is the usual fix.

Related on ForexR

Next lesson How to Send TradingView Alerts to MT4 or MT5 Continue

More Advanced Guides

Multi-Timeframe Analysis in Forex: A Top-Down Routine Price Action Trading: Market Structure, Zones & Liquidity Smart Money Concepts (SMC) Explained: A Practical Guide Fair Value Gap (FVG) Explained: How to Find and Trade It The Wyckoff Method: Accumulation, Distribution and Market Cycles Elliott Wave Theory Explained: The 5-3 Wave Pattern Made Simple London Breakout Strategy: Rules, Example & Backtesting Currency Correlation in Forex: Pairs That Move Together Hedging in Forex: How It Works, Strategies and Real Costs US Dollar Index (DXY) Explained: How to Read & Use It Carry Trade & Interest Rates: How Swap Shapes Forex Trades Trading the News in Forex: NFP, CPI & Rate Decisions Non-Farm Payrolls (NFP): How to Trade the US Jobs Report CPI and Forex: How Inflation Data Moves Currencies FOMC Meetings Explained: How Fed Rate Decisions Move Forex XAU/USD Explained: Contract Specs, Volatility and ATR Stops Gold Price History: 1971 to 2020 in Cycles, Not Straight Lines Gold Futures vs Spot vs CFDs: Contango, Roll and Which to Trade LBMA Gold Price and the London Fix: How Gold's Benchmark Is Set Central Bank Gold Buying: Why They Buy and What It Does to Price Gold Supply and Demand: Mines, Recycling, Jewellery and ETFs Gold Seasonality: Festivals, Weddings and What the Data Say Gold EAs and Trading Bots: Why XAU/USD Breaks Forex Robots Hedging Physical Gold With XAU/USD: A Guide for Jewellers How to Trade Silver (XAG/USD): What Moves It and How It Differs How to Trade Bitcoin (BTC/USD): A Guide for Forex Traders Forex Robots & Expert Advisors (EAs): A Practical Guide Running an EA 24/7: Forex VPS, Forward Testing & Going Live Open-Source Forex EAs on GitHub: Licences, Compiling & Editing How to Backtest a Pine Script Strategy in TradingView How Pine Script Runs: Bars, Series and the History Operator Pine Script Strategy Orders: Entries, Stops and Position Size Pine Script Functions, Methods and Libraries: Reuse Your Code Pine Script Drawings: Lines, Labels, Boxes and Tables Pine Script Errors and Limits: How to Fix the Common Ones How to Send TradingView Alerts to MT4 or MT5 AI in Forex Trading: What It Can and Cannot Do for You Machine Learning in Forex: What Works and What Fails What Is MCP? The Model Context Protocol for Traders How to Build an AI Trading Bot: An Honest Walkthrough How to Backtest an AI Trading Strategy the Right Way Martingale and Grid Trading Explained: How They Work, Pros & Cons Backtesting & Trading Journal: Test Your Forex Strategy Prop Firm Challenges Explained: Rules, Maths & How to Pass Trading Psychology in Forex: Discipline, Bias & Routine

Choose a Regulated Broker

Put what you’ve learned to work with a regulated broker. Compare costs, platforms and licences side by side.

Compare top brokers