Pine Script syntax rules Flashcards

1
Q

What are the Case Sensitivity rules on Pine Script?

A

Always use the correct casing for functions, variables, and keywords.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the Whitespace rules on Pine Script?

A

You should not have whitespace (spaces and line breaks) within variable names, functions, and operators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the Comments rules on Pine Script?

A

Comments are ignored by the script interpreter and are meant to add explanations to your code.

// This is a single-line comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are Statements and Expressions on Pine Script?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are Variable Declarations on Pine Script?

A

Variables are declared using the var keyword, followed by the variable name and an optional initial value.

var myVariable = 5 or myVariable = 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are Function Calls?

A

Functions are called by their name followed by parentheses () containing any required arguments. Arguments are separated by commas.

plot(close, title=”Close Price”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are Operators?

A

Pine Script uses common operators like +, -, *, /, ==, !=, >, <, >=, and <= for arithmetic and comparison operations.

a = 10
b = 5
result = a + b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Strings?

A

String literals are enclosed in double quotes (“ “).

myString = “Hello, Pine Script!”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the rules for Indents and Newlines?

A

It’s a good practice to indent code blocks for readability.

// Indent for readability
if (condition)
doSomething()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly