Skip to content

PineConnector PineScript 101

Welcome to the PineConnector PineScript 101, everything you should know when about PineScript when trying to use PineConnector. If you are looking for a library with scripts already compatible with PineConnector, please visit the PineConnector Script Library.

Section Description Remarks
1 Creating a PineScript Creating a script in the Pine Editor
2 Basics Version, Identifiers, Comments, Strategy vs Study, Overlay
3 Plotting Shapes, Arrows, Characters, and Data Series
4 Alerts Alert() and Alertconditon()
5 Best Practices asd
If there is something else that we should cover, please drop us a note.

Section 1: Creating a PineScript

PineScript, the scripting language designed by TradingView.

Description Remarks
1 At the bottom of your TradingView tab, click "Pine Editor". PineConnector
2 At the bottom panel, click "Open" and then click "New blank indicator". PineConnector
3 You will see the default code shown in the attached image. PineConnector
4 You are now ready to code your script.

// Let's get started!

Section 2: Basics

Basic, but important.

Component Remarks
PineScript Version Number

When you open your Pine Editor, you should see the Version number at the top few rows.

If your script is on Version 3,
you may convert it easily by clicking the ellipsis (⋯) followed by "convert to v4".

If your script is on Version 4,
you may convert it easily by clicking the ellipsis (⋯) followed by "convert to v5".
pinescript pine script pineconnector convert from v4 to v5

  • Any text that starts with "//" is a comment
  • Comments will not run and are are used for documentation.
  • Remember to document frequently so you can refer back at a later point and understand what you've coded.

//Welcome to my script 
StopLoss = 10 // Crafting standardized 10 pips SL for my strategy
  • Identifiers are used for your variables and functions.
  • Identifiers cannot begin with a number and are case-sensitive.

indicator('PineConnector Identifiers')

IAmAnIdentifier = 25 //having an identifier with a constant value of 25
//plot(IAmAnIdentifier) //since plot commented, PineScript will not execute it

FastPeriod = 20 //storing fast MA parameter
SlowPeriod = 50 //storing slow MA parameter

FastEMA = ta.ema(close, FastPeriod) //creating and storing the fast EMA in FastEMA
SlowEMA = ta.ema(close, SlowPeriod) //creating and storing the slow EMA in SlowEMA

plot(FastEMA,, 0)) //plotting the fast MA in green
plot(SlowEMA,, 0)) //plotting the slow MA in red

Strategy vs Study
  • Strategy scripts are used for backtesting.
  • This means Strategy Codes can be used to simulate buy and sell orders.

strategy('My Strategy', overlay=true)

longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if longCondition
strategy.entry('My Long Entry Id', strategy.long)
  • Study are for normal script calculations but cannot be used for backtesting.
    Without the simulation of orders, less resources are used and will run faster.
    Use this, unless backtesting.

indicator('My Script')
  • Set overlay=true if you want the plots to be on your main chart
  • Set overlay=false if you want the plots to be at a separate panel
indicator("PineConnector Super RSI", overlay=true)  //add plot to main chart
SuperRSI = rsi(close,9)				    //creating Super RSI with 9 period close data
plot(SuperRSI) 					    //plot SuperRSI
With overlay=true, the plot was added on the chart itself.
With RSI ranging between 0 and 100 and EURUSD hovering around 1.18,
the combined output means you can only see the RSI.

indicator("PineConnector Super RSI", overlay=false) //add plot to a different panel
SuperRSI = rsi(close,9)				    //creating Super RSI with 9 period close data
plot(SuperRSI) 					    //plot SuperRSI
With overlay=false, RSI has its own pane below the chart.

Section 3: Plotting

Plot everything so you can see what you are doing.

Component Remarks
  • aadd123
  • aadd123
  • aadd123
Data Series
  • asdasd