Get up to $5000 trading bonus & Trade Risk-Free.
After learning the basic syntax of the pine script, this article is about variables. Variables are used to store data. Like in terms of forex, if you want to store a value of a currency pair then you will assign that specific value to a custom variable. So that a custom variable can be used throughout the program without calculating a value again and again.
In a programming language, variables are of vital importance. Variables represent data. During program execution, variables are replaced with real data automatically. So instead of entering data again and again within a program, variables are used.
The names which are used for custom variables and functions are called identifiers. A user can store information within names and it can be used throughout the program by calling identifiers.
This is very important because whenever you want the indicator to show a price or line on the chart then you will also use the identifier to store data. You will come to know in the upcoming articles.
The name of identifiers must be unique. It can have the following characteristics
fibonacci_61 = 61.8
Fibonacci _50= 50.0
It’s mean one statement can be written in multiple lines. But the number of spaces must not be multiple of 4. Code will give an error if the number of spaces is 4 or multiple of 4. Pine script has a built-in function of the vertical line after every 4 spaces. So you don’t need to remember the number of spaces.
Check the code below
//@version=4 study("My Script") //comments a= 1 + 1 plot(a)
This code will give you the following error. this error is due to the fact that there are 4 number spaces in the 5th line before digit 1. as I already have told you the number of spaces must not be multiple of 4. also look at the red circle that shows the verticle line. this verticle line reminds you about 4 spaces.
Syntax error at input 'end of line without line continuation'
when you spend hours on technical analysis but don't find any profitable trades.
If you are serious about trading you need more than just signals, and we can help.