Learn the Editor
Explore Editor Workspace for multi-tab editing and advanced features.
This guide walks you through creating your first Pine Script using the AI assistant. By the end, you’ll have a working strategy ready to copy into TradingView.
Before you begin, ensure you have:
Navigate to Algo Trade Analytics → Pine Script AI Editor from the main menu.
The editor loads with:
Click the + button in the editor tab bar to create a new tab.
Name your tab something descriptive like “RSI Strategy v1”.
The editor starts with a blank canvas ready for your code.
In the chat panel on the right, type your request:
Create an RSI mean-reversion strategy for BTCUSD on the 15-minute chart.Entry when RSI crosses below 30, exit when it crosses above 70.Include webhook alerts for Algo Trade Analytics.Press Enter or click Send.
The AI responds with generated Pine Script code.
Key things to check:
If the code looks good, click Apply to insert it into your script.
The code moves from the diff viewer into your actual script tab.
Click the Validate button (checkmark icon) in the toolbar.
Possible outcomes:
Once validation passes:
Here’s an example conversation flow:
You: Create a simple EMA crossover strategy for stocks
AI: Generates a complete EMA crossover strategy with entry/exit logic
You: Add a stop loss at 2% below entry
AI: Shows a diff adding stop loss logic to your existing code
You: Now add webhook alerts that send orders to Algo Trade Analytics
AI: Adds alertcondition() calls with proper JSON payloads
Speed up your workflow with these shortcuts:
| Shortcut | Action |
|---|---|
Ctrl/Cmd + S | Save current tab |
Ctrl/Cmd + Enter | Send chat message |
Ctrl/Cmd + Z | Undo last change |
Ctrl/Cmd + Shift + Z | Redo |
Escape | Dismiss AI suggestion |
❌ “Make a trading strategy”
✅ “Create an RSI strategy for ETHUSD on the 4-hour chart with entries below 25 and exits above 75”
❌ “Fix this error”
✅ “Fix this TradingView error: ‘Undeclared identifier rsi_value’ on line 15”
Instead of asking for everything at once:
Learn the Editor
Explore Editor Workspace for multi-tab editing and advanced features.
Master AI Chat
Read AI Chat Panel to get the most out of your conversations.
Add Report Context
Learn to attach analysis reports for data-driven optimization.
Validate Code
Set up auto-validation to catch errors in real-time.
The AI needs to return code changes. Try asking more specifically:
Click Fix with AI next to any error. The AI will analyze the error and propose a fix.
Ensure you:
//@version=6 headerSee Troubleshooting for more solutions.