PineScript Coding Tutorial

PineScript Tutorial

Pine can be used for building indicators or fully-automated trading strategies. This tutorial exclusively focuses on coding indicators...PineScript from TradingView is a simple programming language that is specially designed for traders. Pine can be used for building indicators or fully-automated trading strategies. This tutorial exclusively focuses on coding indicators.


The Basics of Creating Scripts


A script can refer to simple research (Study) or an automated system (Strategy). Both elements (Studies and Strategies) include functions and variables. At the beginning of each script there is a statement declaring the version of PineScript, the name of the script, and whether if it is a Study or a Strategy:


study(title, shorttitle, overlay, format, precision)

This is a short explanation of the above parameters:

  • If used, ‘overlay’ defines where the calculation will be shown on the main chart or below the main chart
  • If used, ‘format’ defines the type of formatting in indicator values. The available values are: format.inherit, format.price and format.volume
  • If used, ‘precision’ states the number of digits after the floating point. It must be a non-negative integer and not greater than 16

At the end of each script there are the instructions to plot the results inside the chart window (overlay=true) or below the chart window:

  • If nothing is stated, scripts are designed to plot calculations below the chart window
  • If you add at the beginning the instruction (overlay=true), calculations will be plotted inside the chart window
Pin It

Create PineScript Indicators & Strategies (TradingView)

Custom PineScript (TradingView) IndicatorsHow to create Indicators & Automated Strategies using TradingView PineScript

PineScript is a simple and free-to-use programming language, specially designed for traders, which is incorporated into the TradingView platform.

A few words about TradingView

TradingView is an online platform that is basically free and provides all the charting tools and indicators you need to create trading ideas and share them with the community. The TradingView platform incorporates its own scripting language called PineScript (similar to Python) which allows the creation of custom indicators. All you need to use TradingView and PineScript is a free account:

» Visit TradingView and open a free account

Introduction to the PineScript

PineScript is a cloud-based language, and that means you can create and use indicators in your desktop computer, or your mobile device, without the need of installing any software.

Key Features of Pine scripts

  • A script can be a STUDY or a STRATEGY (review script structures below)
  • At the beginning of each script, there is an annotation defining the version of PineScript used, along with the name and the basic properties of the script
  • Each script’s main body contains FUNCTIONS and VARIABLES. Functions correspond to instructions that lead to calculations. Variables save the values of those calculations in the cloud.
  • PineScript contains built-in functions that you can use in your scripts
  • At the end of each script, you can define which variables will be plotted, and where they will be plotted
Pin It


Automated ForexForexAutomatic is the right place to learn about automated Forex trading and find reviews regarding Expert Advisors, Trading Systems, Signal Providers, and Forex Brokers...

Contact us

Forex AutomaticContact us either you are a Forex trader seeking for advice and joining a Forex rebate plan or you are a Forex Company seeking for high-value Forex flat-advertising opportunities…

» Contact ForexAutomatic