Pine Script TradingView’s Pine script Introduction

TradingView is proud to present the Pine scripting language! TradingView is the first platform of to have this kind of functionality, combined with advanced real-time charting and a super-engaged community of investors discussing ideas.

TradingView provides a large set of prebuilt PineScripts (indicators) out of the box. We realized that wasn’t enough for all our users, and adding every script would just make TradingView too large to handle. As a solution, we built the Pine programming language specifically so our users could modify existing PineScripts for their own needs or create custom ones.

The project is still in very early stage, but even now can be useful to a large number of people – so we decided to open even the early beta to the public. We invite everyone to try it and give us feedback. It’s a BETA, which means it probably has errors. With your feedback, we promise to work on fixes and improvements. Currently it’s available for free to everyone. In the future, this may or may not change – depending on how it will affect our server loads.

This article will show you how to begin editing and building PineScripts. It assumes that you are familiar with mathematics and programming basics. Although, with perseverance, anyone can figure it out. We deliberately made it as easy as possible, while keeping it flexible and powerful – to make it understandable to the widest possible audience.


The first thing you’ll notice is the new Script Editor button on the toolbar, and the new tab called Custom Scripts in the studies windows.

Through Script Editor you can create a new PineScript or open an existing one. More often it’s easier to tweak existing PineScripts than to create a new one. Start with choosing a template (i.e. which indicator you want to use as the base). We added templates for most indicators available in the default library.


Clicking Save will save the indicator and it’ll appear on the Custom Scripts tab.

Let’s practice! For example, the default Stochastic RSI is just not good enough for you – you want three levels. Let’s customize the existing Stoch RSI:

1. Click Script Editor. Then click New and choose Stochastic RSI.

2. Click Save (or press Ctrl+S on your keyboard). We get this:


3. Add the PineScript to your chart by clicking Add to Chart. In the future, an applied script will recalculate every time you click Save.


4. Now let’s add the levels that we wanted.


5. Click Save and look at the results! Scripts now have an additional button (next to its name) that will open the Script Editor.


Now let’s try ADDING something that’s not a default on TradingView. For example, you read somewhere that the Chande Momentum Oscillator is just the best, and want to try it out.

1. Open the Script Editor. Click New and choose Blank.

2. We’ll give it a name: “Chande Momentum Oscillator” and abbreviation “CMO“. Save, and we get this:


3. Now we need to enter the formula. To find it, use Google or Investopedia.


Pretty simple. The code looks like this:


Click Add to Chart and this is the result


4. Now we need to add the signal line and levels. Here’s what Investopedia says:


So, we need to add a signal line with Length = 9 and levels of 50/-50.


Click Save and we get this.

We tried to make the editor as simple and user-friendly as possible:

  • Syntax has highlighting
  • Help included for all available functions (question mark on the toolbar)
  • Help for functions through tooltip under the cursor
  • Hotkeys
  • Autocomplete through Ctrl-Space.


We hope you enjoy using TradingView’s Pine programming language! Try it and let us know your feedback.


December 13, 2013
spread the love