Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

A syntax error in a for loop and array in Pine Script can be caused by various factors, such as:

  1. Incorrect syntax: This is the most common reason for a syntax error. It occurs when the syntax of the for loop or array declaration is not correct. This can be due to a typing error, missing parentheses, or an extra comma.

  2. Invalid variable name: If you use an invalid variable name in the for loop or array declaration, you may get a syntax error. Variable names should start with a letter, followed by letters, numbers, or underscores.

  3. Incorrect data types: If you use incorrect data types in the for loop or array declaration, you may get a syntax error. For example, you cannot mix data types in an array declaration, such as strings and integers.

  4. Missing closing bracket or parenthesis: Forgetting to close a bracket or parenthesis in the for loop or array declaration can also result in a syntax error.

Overall, it is important to ensure that the syntax of your for loop and array declarations are correct and free from errors.