Publishing Pine Script Code on TradingView
When you code an indicator or strategy in Pine Script for TradingView, you may want to keep it for personal use, share it with friends or specific clients, make the source code available to others, or publish an indicator publicly so that other TradingView users can find and use it.
TradingView provides different publishing options for each of these needs. Therefore, before publishing a script, it is important to understand who should have access to it and whether or not they should be able to view its source code.
In this tutorial, we will go through the process of publishing a script and explore the key differences between the available publishing and access options on TradingView.
What Should You Do Before Publishing a Script?
The first step is to save your script in the Pine Editor.
After writing the code, choose a name for the script and save it. You should then add the script to your chart.
This step is important because when you select Publish Script, TradingView checks that the script you are trying to publish is currently applied to a chart.
Setting Up the Chart Before Publishing
The image displayed on the script’s publication page is based on the chart’s appearance at the time of publication.
Therefore, before selecting Publish Script, it is a good idea to set up things such as the symbol, timeframe, zoom level, chart type, chart scale, and other indicators on the chart so that the overall appearance presents your indicator clearly.
This image may be the first thing users see when they visit your script’s page, so choosing an appropriate chart setup can make a significant difference.
Publishing a New Script or Updating an Existing One
After selecting Publish Script, TradingView gives you the option to publish a new script or update one that you have already published.
Publish New Script
If you are publishing the script for the first time, select Publish New Script.
You can then:
- Choose a name for the script.
- Write a description.
- Select an appropriate category.
- Add relevant tags.
- Choose the publishing method and access level.
Update Existing Script
If you have already published the script and have now prepared a new version of the code, it is better to use Update Existing Script.
In this case, the new version is published as a Revision of the existing script, while maintaining its connection to the previous version.
Therefore, when making changes or improvements to an already published script, you should not publish it as a completely new script every time.
Public and Private: The First Important Choice
One of the most important settings when publishing a script is Privacy.
There are two main options:
- Public
- Private
Public
When you publish a script publicly, it becomes part of TradingView’s public script library, and other users can find it through script searches.
This option is suitable when you want to:
- Make your script visible to a larger audience.
- Have it appear in TradingView search results.
- Introduce your tool to new users.
- Share an indicator with the wider TradingView community.
However, publishing a script publicly does not mean that any type of code can be published without restrictions.
Public scripts are reviewed by TradingView Moderators and must comply with the platform’s publishing guidelines.
For this reason, the title, description, category, tags, and overall content of the script are all important.
An Important Note About Public Scripts
If you plan to publish an indicator publicly, make sure that it provides genuine value to other users.
The title should not be overly generic or misleading, and the description should clearly explain what the indicator does and how it can be used.
Using irrelevant categories or tags may also cause problems during the script review process.
Private
If you do not want your script to appear in TradingView’s public search results, you can publish it as Private.
This option can be useful when, for example:
- You have developed an indicator for specific clients.
- You want to share it with friends.
- The script is not yet ready for public release.
- You do not want the script to appear in TradingView’s public script library.
In this case, the script will not appear in public searches.
However, you can still share the script’s page link with a specific person, who may be able to access it depending on the applicable access settings.
Visibility: What Can the User See?
After deciding whether the script should be public or private, another important setting determines how much access users have to the script.
There are three main options:
- Open
- Protected
- Invite-only
The differences between these three options are important.
1. Open: Full Access to the Source Code
With Open, users can not only use the indicator but also view its Pine Script source code.
In other words:
Use + View Source Code
are both available to the user.
This option is particularly suitable for Open Source projects. If your goal is to teach Pine Script, share code with other developers, or provide an example for learning purposes, Open is a suitable choice.
Users can view the code, study how it works, and, where permitted, use it as a learning resource or as a basis for other projects.
An important point is that even TradingView’s free Basic accounts can publish scripts using the Open option.
2. Protected: Use the Indicator Without Viewing the Source Code
Protected is suitable when you want users to be able to use your indicator without giving them access to the source code.
In this mode:
Use Script → Yes
View Source Code → No
Users can add the indicator to their charts and use it, but they cannot access the Pine Script source code.
This is particularly useful for developers who want to provide indicators to their clients while keeping the underlying logic private.
According to the tutorial, publishing a Protected script requires an account level higher than Basic.
3. Invite-only: Full Control Over User Access
Invite-only provides the most restricted level of access.
Simply having the script’s link is not enough.
The user:
- Cannot view the source code.
- Cannot use the script without permission from its author.
This means the script owner can specify which TradingView accounts are allowed to use the indicator.
This feature is particularly useful for selling indicator subscriptions and providing exclusive tools to clients.
Comparing the Three Visibility Options
| Visibility | Indicator Access | Source Code | Access Control |
|---|---|---|---|
| Open | ✅ | ✅ | Low |
| Protected | ✅ | ❌ | Medium |
| Invite-only | Authorized users only | ❌ | High |
So, if your goal is to teach or share your code, Open is the most suitable option.
If you want users to use the indicator without seeing the source code, Protected is a good choice.
And if you want to control access on a user-by-user basis, Invite-only is the best option.
Managing Access with Invite-only Scripts
One of the most useful features of Invite-only scripts is the ability to manage individual users.
Suppose a client wants to use your indicator.
First, the user needs to provide you with their TradingView username.
You can then go to Manage Access, select Add New User, and enter their username.
After finding the correct account, you can grant the user access to the script.
Another important feature is the ability to set an expiration date for a user’s access.
For example, access can be granted:
- For one month
- For several months
- Until a specific date
- With no expiration date
This feature is particularly useful for subscription-based products.
For example, if a user purchases a one-month subscription, you can grant access only for that period.
Once the subscription expires, you can remove the user’s access or extend the expiration date if the subscription is renewed.
Removing or Revoking User Access
The Manage Access section allows you to view the list of users who currently have access to the script.
For each user, you can check their access status and expiration date.
If necessary, you can revoke a user’s access.
Once access has been removed, that user will no longer be able to use the Invite-only script.
This makes the system particularly useful for managing subscription-based indicators and other restricted tools.
Author’s Instructions: How Should Users Contact You?
When publishing a script, especially an Invite-only script, you may want to explain to users what they need to do to request access.
You can use the Author’s Instructions section for this purpose.
For example, you can explain:
- How users should contact you.
- Which website or email address they should use.
- That they need to provide their TradingView username.
- How they can request activation.
This section can be especially useful when you are selling an indicator or offering subscription-based access.
An Important Point About Public and Invite-only Scripts
You might assume that if a script is Public, anyone can use it.
However, with an Invite-only script, making the script publicly visible does not automatically give everyone access to the indicator. Actual use still requires authorization from the script owner.
This allows you to make the script visible to potential users, let them learn about the product, and then have interested users contact you to request access.
This approach can be particularly useful when using TradingView as a platform for promoting a commercial indicator.
An Alternative Method: Using a Password in the Code
The tutorial also covers another method for restricting access.
With this approach, you create a string input in Pine Script and require the user to enter a specific value.
You can then add a condition to the code so that the indicator only displays its output when the correct value has been entered.
A simple example would be:
Password = User Input
If Password is correct:
Display the indicator
Otherwise:
Display nothing
This way, even if someone has access to the indicator, they will not be able to see its output without knowing the required value.
However, this method should not be considered a replacement for a proper access-control system. For sensitive commercial products, TradingView’s Invite-only feature and its built-in access management provide a more reliable approach.
An Important Note About Protected Script Links
With Protected scripts, it is important to understand that having the script’s link may be enough for another user to access and use it.
Therefore, if your goal is to ensure that only specific users can use your indicator, Protected is not the ideal option for user-by-user access control.
In such cases, Invite-only offers a major advantage. Even if someone else obtains the script’s link, they will not be able to use the indicator unless their TradingView account has been authorized by the script owner.
Managing and Editing a Published Script
After publishing a script, you can access your published scripts through your TradingView profile.
From there, you can manage your scripts and, depending on the type of change, perform actions such as:
- Edit the description.
- Manage the script.
- Change user access.
- Delete the script where permitted.
- Publish a new version of the code.
If you only need to change the script’s description or other publication details, you can edit the relevant information.
However, if the Pine Script code itself has changed, you should publish the updated version using Update Existing Script.
Important Warning About Deleting a Public Script
One of the important points discussed in the tutorial concerns deleting a Public script.
After publishing a script publicly, there is only a limited period of time (15 minutes) during which you can delete it.
After that, once the script has gone through the review and public publishing process, it cannot be deleted in the same way as an ordinary script.
Therefore, before publishing a script publicly, it is important to carefully check the following:
- The code is final.
- The title is correct.
- The description is appropriate.
- The correct category has been selected.
- The tags are relevant.
- The chart image looks appropriate.
- No sensitive or unintended information is included in the code.
For this reason, it is best to publish a script publicly only when you are confident that it is ready for release.
Conclusion
Publishing a Pine Script on TradingView is not simply a matter of putting your code on the platform. You also need to decide who should have access to the script, what they should be able to see, and how long they should be allowed to use it.
In summary:
- Public is suitable for introducing and publicly sharing a script.
- Private is useful for limited, non-public sharing.
- Open allows users to view the source code.
- Protected allows users to use the indicator without viewing the source code.
- Invite-only provides precise control over authorized users.
- Manage Access allows you to add or remove users and set access periods.
- Update Existing Script is used to publish new versions of an existing script.
If your goal is to develop and sell commercial indicators, one of the most important distinctions to understand is the difference between Protected and Invite-only. Protected is primarily useful for keeping the source code hidden, while Invite-only gives you much greater control over which TradingView accounts are allowed to use your tool.
Ultimately, before publishing any script, first determine whether your goal is teaching and sharing code, public distribution, providing a tool to clients, or selling subscriptions. Then choose the publishing and access settings that best match your needs.