Bulltrading
WebsiteLaunch AppYoutube(FR)Youtube(EN)
  • 📘Preface
  • Bulltrading Designer
    • ⚒️Designer
    • 💻Editor
      • My indicators
      • MarketPlace
      • Create your first indicator
    • 📈My strategies
      • Publish
        • Personal Strategy
        • Strategy To Rent
    • 👨‍💻Pinescript
      • First indicator
      • Pine Script™ v5 User Manual
        • Pine Script™ Execution Model
        • Time Series
        • Pine Script Structure
        • Identifiers
        • Operators
        • Variable declarations
        • Conditional structures
        • Loops
        • Type system
        • Built-ins
        • User-Defined Functions
      • Built-ins
        • Variables
          • Candles
          • Colors
          • Math
          • Ta
        • Functions
          • Indicator
          • Input
          • Plot
          • Na - Nz
          • Math
          • Ta
      • Bulltrading vs TradingView
  • Bulltrading tokens (BLT)
    • 🪙BLT Tokenomics
    • 🧾BLT Contract
    • 🏦Hold Program
    • 🔒BLT Audit
    • 🎯[EN] How to buy BLT ?
    • 🎯[FR] Acheter du BLT
  • Other
    • ⁉️Frequently Asked Question
    • 📺Video Tutorials
    • 📒Glossary
  • 📺[FR] Youtube
  • 📺[EN] Youtube
  • 🦊Twitter
  • 🦊Discord
  • 🦊Telegram
Powered by GitBook
On this page
  • Script Definition
  • Variables and Types
  • Functions and Control Structures
  • Plotting and Visualization
  • Backtesting
  1. Bulltrading Designer
  2. Pinescript
  3. Pine Script™ v5 User Manual

Pine Script Structure

Pine Script is a programming language created by TradingView and Rewrite by Bulltrading for the creation of custom technical analysis tools.

Script Definition

A Pine Script starts with a //@version directive which denotes the version of Pine Script to be used. For instance, //@version=5.

After this, you can define the script properties using indicator for indicators.

Example:

//@version=5
indicator("My Script", shorttitle = "MS")

Variables and Types

Pine Script has several data types including series, float, integer, bool, color, and string. Variables can be declared using the <type> <variable-name> syntax, and assignment is done with the := operator.

Example:

float a = na
a := close

Functions and Control Structures

Pine Script supports built-in functions and control structures.

Functions are defined with parameters and a block of code. They return the result of the last executed line.

Control structures, such as if, for, and while loops, are also available.

Example:

codef_sum(x, y) => 
    x + y

if (high > low)
    result = high - low
else 
    result = 0

Plotting and Visualization

plot function is used for drawing on the chart. It can take several parameters, like the series to plot, color, and line width.

Example:

plot(close, color=color.red, linewidth=2)

Backtesting

Indicators in Pine Script are used for backtesting trading ideas. It include positive or negative signal.

Example:

indicator("My Strategy")
indicator.signal(ta.crossover(sma(close, 14), sma(close, 28)))

This is just a simple overview of Pine Script structure, and the language has many more features and details to be discovered.

PreviousTime SeriesNextIdentifiers

Last updated 1 year ago

👨‍💻