DocsErrors
Syntax Errors
Syntax errors are caught when your code is parsed before execution. The strategy will not run until all syntax errors are fixed.
Common Causes
Missing or Extra Brackets
// Missing closing brace function onBar(ctx, i) { if (ctx.series.close[i] > 100) { ctx.order.market('ASSET', 1); // <-- missing } }
Fix: Match every { with a }, every ( with a ), and every [ with a ]. The editor highlights bracket pairs to help.
Missing Semicolons or Commas
ctx.indicator('sma', 'SMA', { period: 20 // <-- missing comma source: 'close' });
Invalid JavaScript
// Using Python syntax if close > 100: // <-- not valid JavaScript buy() // Correct JavaScript if (ctx.series.close[i] > 100) { ctx.order.market('ASSET', 1); }
How to Fix
- Read the error message — it usually points to the line number
- Check for unmatched brackets near the indicated line
- Look for missing commas in object literals and function arguments
- Use the Monaco editor's syntax highlighting — red underlines indicate problems
Related
syntaxparseasterrorSyntaxErrorcode