How to debug pinescript?

  For debugging of pinescript, coders have a console window just below pinescript editor window. If the console window is not visible. Right click on the menu bar of editor window and select console. All the script related errors are generated and shown in console window. Coders can then take overview of error from the error description generated and debug pinescript errors. 

Taking Hints from Pinescript Console Window

The above shows console option when right clicked on the menu bar of editor window.When any error is found in script by the pinescript editor it highlights the error in console window with red colour. The line number of possible error is also generated. In the example below, line no 3 has generated error. The description of error is "Undeclared identifier close1" . This error means that you have used a variable without declaration, this normally happens when you have written the name of variable wrong or the variable name has typo error.  

In the above example , I have written close1 in place of close that has caused the error. Sometimes you may have logical errors that are not generated from syntax, but out of logical mistake in making the algorithm or arrangement of instructions. Here, you may be required to print output of pinescript variable for debugging. Such type of debugging can be done by printing variable values through labels.

This is very common question asked by almost every new coder. When you are new, you often make mistake and for learning debugging is very important.

Resources

Highest Rated Udemy Course on PineScript - Grab your Seat Now 

Udemy Discount Coupon Code : UDEMY-JAN23 (Valid upto 30th Nov 2023)

Learn more about coding on tradingview in PineScript through Books on pinescript available on amazon and kindle.


200+ pages book100 pages book200+ pages book


Point and Figure Charts : A Time-Tested Tool for Technical Analysis

In the dynamic world of financial markets, investors and traders constantly seek tools that can provide valuable insights into market trends...