Pine Script syntax rules Flashcards
What are the Case Sensitivity rules on Pine Script?
Always use the correct casing for functions, variables, and keywords.
What are the Whitespace rules on Pine Script?
You should not have whitespace (spaces and line breaks) within variable names, functions, and operators.
What are the Comments rules on Pine Script?
Comments are ignored by the script interpreter and are meant to add explanations to your code.
// This is a single-line comment
What are Statements and Expressions on Pine Script?
Pine Script is built on statements and expressions.
- Statements are complete lines of code that perform actions.
// Statement
variable = 10 - Expressions are combinations of variables and operators that return a value.
// Expression
result = variable + 5
What are Variable Declarations on Pine Script?
Variables are declared using the var keyword, followed by the variable name and an optional initial value.
var myVariable = 5 or myVariable = 5
What are Function Calls?
Functions are called by their name followed by parentheses () containing any required arguments. Arguments are separated by commas.
plot(close, title=”Close Price”)
What are Operators?
Pine Script uses common operators like +, -, *, /, ==, !=, >, <, >=, and <= for arithmetic and comparison operations.
a = 10
b = 5
result = a + b
What are Strings?
String literals are enclosed in double quotes (“ “).
myString = “Hello, Pine Script!”
What are the rules for Indents and Newlines?
It’s a good practice to indent code blocks for readability.
// Indent for readability
if (condition)
doSomething()