Skip to content
Algo Trade Analytics Docs

Code Validation

Basic & Pro Plans

The Code Validation feature checks your Pine Script against TradingView’s actual compiler, catching errors before you copy your code to the platform.


Your Code → Algo Trade Analytics → TradingView Compiler → Results
Errors, Warnings, Info

The system sends your code to TradingView’s validation endpoint and returns:

  • Errors — Must be fixed before the script will compile
  • Warnings — Code works but has potential issues
  • Info — Suggestions and best practices

Click the ✓ Validate button in the editor toolbar.

Process:

  1. Your code is sent for validation
  2. A loading indicator appears
  3. Results display in the validation panel
✓ Script is valid
──────────────────────────────────────────
No errors or warnings detected.

Or with issues:

❌ 2 Errors | ⚠️ 1 Warning
──────────────────────────────────────────
Line 15: Undeclared identifier 'rsi_val' [Fix with AI]
Line 23: Cannot call 'security' with argument... [Fix with AI]
──────────────────────────────────────────
Line 45: Consider using 'request.security' instead [Info]

When enabled, your code validates automatically after changes.

  1. Click the ⚙️ settings icon in the toolbar
  2. Toggle Auto-Validation on
  1. You stop typing for 600ms
  2. Validation runs automatically
  3. Results update in the panel

Missing brackets, incorrect keywords, malformed expressions.

Example:

Line 10: Mismatched input '(' expecting ')'

Common causes:

  • Unclosed parentheses or brackets
  • Missing commas in function calls
  • Typos in keywords

Using variables or functions that don’t exist.

Example:

Line 15: Undeclared identifier 'rsi_val'

Common causes:

  • Typo in variable name
  • Using variable before declaration
  • Missing function import

Using incompatible data types.

Example:

Line 23: Cannot call 'strategy.entry' with argument 'qty'=string

Common causes:

  • Passing string where number expected
  • Using series where simple required
  • Incorrect function signatures

Using outdated Pine Script functions.

Example:

Line 45: 'security' is deprecated. Use 'request.security' instead.

Common in:

  • Code migrated from older Pine Script versions
  • Copy-pasted examples from old tutorials
  • Legacy strategies being updated

Each error and warning includes a Fix with AI button.

  1. The error details are sent to the AI chat.

  2. The AI examines:

    • The error message
    • The surrounding code
    • Your script context
  3. The AI returns a diff showing the proposed fix.

  4. Review the change and apply if correct.

Error:

Line 15: Undeclared identifier 'rsi_val'

AI Response:

entry_condition = rsi_val < 30
entry_condition = rsi_value < 30

Explanation: “The variable rsi_val doesn’t exist. Based on line 8 where you declared rsi_value, this appears to be a typo.”


Providing your TradingView username enables:

  • More accurate validation results
  • Access to your saved libraries
  • Better script compatibility checking
  1. Go to Account Settings
  2. Navigate to Integrations or TradingView
  3. Enter your TradingView username
  4. Save settings

❌ 5 Errors

Action: Fix errors one at a time, starting from the first. Often, later errors are caused by earlier ones.

✓ Valid | ⚠️ 3 Warnings

Action: Warnings won’t prevent compilation, but review them:

  • Deprecated functions should be updated
  • Potential bugs should be investigated
  • Style suggestions can be ignored if intentional
✓ Script is valid

Action: Safe to copy to TradingView. Note that validation doesn’t guarantee the strategy works correctly—only that it compiles.


Validation CatchesTradingView Also Checks
✅ Syntax errors✅ Syntax errors
✅ Type mismatches✅ Type mismatches
✅ Undefined variables✅ Undefined variables
✅ Deprecated functions✅ Deprecated functions
❌ Runtime errors✅ Runtime errors
❌ Series length issues✅ Series length issues

Some errors only appear in TradingView:

  • Data-dependent errors — Errors that depend on actual chart data
  • Runtime limits — Memory or execution time limits
  • Indicator-specific issues — Problems with overlay settings

  • After each significant change
  • Before copying to TradingView
  • After applying AI suggestions
  1. Address errors first (required)
  2. Review warnings (recommended)
  3. Consider info suggestions (optional)

Don’t waste time debugging manually:

  1. Click “Fix with AI”
  2. Review the suggestion
  3. Apply if correct

The AI often provides context and explanations that help you learn.


Causes:

  • Large script
  • Network issues
  • TradingView API delays

Solutions:

  • Wait a moment and retry
  • Check your internet connection
  • Reduce script size if possible

Causes:

  • Empty script
  • Network failure
  • API timeout

Solutions:

  • Ensure script has content
  • Refresh the page
  • Check console for errors