A very specific and nerdy question!
You're referring to the error messages in TradingView's Pine Script editor, right?
When you see an error message in TradingView, it usually follows this format:
line X: error message (dot notation) problem
Here's a breakdown:
line X: indicates the line number in your Pine Script code where the error occurred.
error message: a brief description of the error (e.g., "Syntax error", "Undeclared variable", etc.).
(dot notation): this is the part you're asking about. It's a cryptic notation that points to the exact location within the line where the error was detected.
problem: a short phrase that repeats the error message (mostly redundant, but helps with search engines).
Now, let's dissect the dot notation:
In TradingView's error messages, the dot notation is written as .X of Y, where:
X (the first number): indicates the error position within the line (1-based index). It points to the specific token (a token is a single unit of code, like a variable, operator, or keyword) that's causing the issue.
Y (the second number): represents the total number of tokens on that line.
When you see .1 of 1, it means:
1 of 1: There is only 1 token on that line (Y = 1), and the error is at the very first token (X = 1) of that line.
In other words, .1 of 1 indicates that:
- The line has only one element (e.g., a single variable, a lone operator, etc.).
- The error is right at the beginning of that line (no preceding tokens).
Here are some examples to illustrate this:
Case 1: Simple error
study("My Script")
a = // syntax error here
Error message: line 2: Syntax error .1 of 1 problem
- Line 2 has only 1 token (the incomplete assignment
a =).
- The error is at the first (and only) token (
.1 of 1), indicating that the script expected something more (e.g., a value) after the = operator.
Case 2: Longer line with multiple tokens
study("My Script")
b = close + // syntax error here
Error message: line 2: Syntax error .4 of 4 problem
- Line 2 has 4 tokens:
b, =, close, +.
- The error is at the 4th token (
.4 of 4), which is the + operator. The script expected another operand (value) after the +, but found none.
Case 3: Another example
study("My Script")
if true then
a = 5
Error message: line 2: "then" not expected .3 of 3 problem
- Line 2 has 3 tokens:
if, true, then.
- The error is at the 3rd token (
.3 of 3), which is the then keyword. In Pine Script, then is not needed (unlike some other languages). The script didn't expect then here, hence the error.
Now, back to your original question: .1 of 1 means the error is:
- On a line with only one token.
- Right at the start of that token.
Common causes for .1 of 1 errors:
- Empty lines with invisible characters (e.g., spaces, tabs).
- Unexpected characters (e.g., a lone
;, @, or $).
- Incomplete statements (e.g.,
a = without a value).
- Syntax errors at the very beginning of a line (e.g., starting with an operator like
+ or *).
When you see .1 of 1, inspect that line carefully:
- Check for invisible characters (delete and retype the line).
- Verify that the statement is complete (e.g., add a value after an assignment operator).
- Ensure the line starts with a valid Pine Script keyword or variable.
Hope this explanation clarifies the mysterious dot notation! Happy debugging on TradingView!