Get up to $5000 trading bonus & Trade Risk-Free.
In this article we will cover basic overview of pine script editor as well as basic syntax.
So, let us get started
The first step is to click on the pencil icon. It is used to rename your script. Or simply click on the untitled script and easily rename your script. My script 1 is the default text. Look at the highlighted area in the image below.
To the right of the pencil icon, there are two more icons. Star icon is used to add the script to favorite so you can easily access your script. A search icon is used to find or replace a specific text in the script.
While editing the script in the pine editor, A small red star icon will appear with the script name. it indicates unsaved script so remember to save your script.
Another important option here is revision. Whenever you will save your script, the number will continue adding up by one. By default, it will be 1.0. Now you have written your script and press save then it will turn 2.0 so you can access your previous script easily by switching the number to 1.0 This is an awesome feature.
Another feature of the pine script editor is the option of “open”. By clicking here, you can access your previous scripts, use built-in scripts, create a new indicator and a strategy.
Publish script option is used to share your script with the public. A trader can sell his script to others easily and safely by using this feature. Also, you can take help from other programmers by sharing questions about a particular script.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © forexbee
The above two lines are comments by default. To write a comment in pine script, start with two forward slashes. The text/code written after two forward slashes will not be executed by the compiler.
This piece of code indicates the version of pine script you are using. There are currently four versions of pine script and they are incompatible with one another. By default, it will be version=4 because it is the latest version and has much more features as compared to previous versions. There is also an option of converting older version scripts to version 4. So before modifying an old script in the public library, first remember to convert it.
study("My Script") plot(close)
Study and strategy are two functions. A function is used to do calculations and variable is used to store these calculations.
strategy("My Strategy", overlay=true) longCondition = crossover(sma(close, 14), sma(close, 28)) if (longCondition) strategy.entry("My Long Entry Id", strategy.long) shortCondition = crossunder(sma(close, 14), sma(close, 28)) if (shortCondition) strategy.entry("My Short Entry Id", strategy.short)
Strategy function must contain at least a strategy like entry, strategy, etc like shown in the above code (the code is to just show you the difference between study and strategy at this level). Otherwise, you will get errors. So, the function call is necessary to show the return value.
The strategy function is used to plot information on chart as well as to backtest a specific strategy.
Video Tutorial 👇👇
I hope you will like this Article. For any Questions Comment below, also share by below links.
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.