Skip to content
Algo Trade Analytics Docs

Diff Viewer

Basic & Pro Plans

The Diff Viewer shows you exactly what the AI wants to change before you apply it. This gives you full control over modifications to your code.


When the AI suggests code changes:

  1. AI returns a diff — Changes are shown as additions/deletions
  2. Diff viewer displays — You see the before/after comparison
  3. You decide — Apply, dismiss, or ask for modifications
┌─────────────────────────────────────────────┐
│ Current Code │ Suggested Code │
├─────────────────────────────────────────────┤
│ rsi = ta.rsi(close,14)│ rsi = ta.rsi(close,14)
│- entry = rsi < 30 │+ entry = rsi < 30 and
│ │+ volume > avgVol
│ if entry │ if entry
└─────────────────────────────────────────────┘

ColorMeaning
🟢 GreenNew code being added
🔴 RedExisting code being removed
GrayUnchanged context lines
PrefixMeaning
+Addition
-Deletion
(space)Unchanged

Shows current code on the left, suggested code on the right.

Best for:

  • Comparing large blocks of code
  • Understanding structural changes
  • Wide screens

Shows changes inline with additions/deletions highlighted.

Best for:

  • Small changes
  • Quick review
  • Narrow screens

Accepts all changes and modifies your script.

Keyboard: Ctrl/Cmd + Enter (when diff is focused)

What happens:

  1. Deletions are removed
  2. Additions are inserted
  3. Diff viewer closes
  4. Editor shows updated code

Rejects the changes without modifying your script.

Keyboard: Escape

What happens:

  1. Diff viewer closes
  2. Original code unchanged
  3. AI suggestion cleared

If the suggestion isn’t quite right:

  1. Keep the diff open
  2. Type your feedback in chat
  3. AI responds with a revised diff

Example:

“This looks good but add a volume filter too”


rsi = ta.rsi(close, 14)
rsi = ta.rsi(close, 21)

Meaning: The RSI period is changing from 14 to 21.

strategy.entry("Long", strategy.long, when=longCondition)
strategy.exit("Long Exit", "Long", stop=stopPrice)

Meaning: A new line is being added (exit logic).

//@version=6
indicator("My Indicator")
strategy("My Strategy", overlay=true)
rsi = ta.rsi(close, 14)
plot(rsi)
longCondition = rsi < 30
if longCondition
strategy.entry("Long", strategy.long)

Meaning: Converting an indicator to a strategy with entry logic.


Use the scrollbar to review all changes. Context lines help you understand where changes occur.

Look for colored sections:

  • Skip gray unchanged sections
  • Focus on green (additions) and red (deletions)

You asked: “Fix the error on line 15”

Expected diff: Small, targeted change near line 15

Red flag: Large changes throughout the file

You asked: “Add a stop loss”

Expected diff: A few new lines adding exit logic

Red flag: Changes to unrelated entry logic

You asked: “Refactor this code for clarity”

Expected diff: Reorganization with same functionality

Red flag: Added or removed trading logic


If you apply a change and realize it’s wrong:

  1. Press Ctrl/Cmd + Z to undo
  2. The entire AI change is reverted as one step
  3. Your original code is restored

Always validate after applying AI changes:

  1. Apply the suggestion
  2. Click Validate
  3. Fix any new errors

The AI usually explains what it’s changing:

“I’ve updated your RSI strategy to include a volume filter. The entry condition now requires both RSI below 30 AND volume above the 20-period average.”

Understanding the intent helps you review the code.

Always verify that:

  • Entry conditions match your requirements
  • Exit conditions are correct
  • Risk management is preserved

For complex changes:

  1. Apply one feature at a time
  2. Validate between changes
  3. Test in TradingView periodically

Causes:

  • Code changed since AI response
  • Conflict between changes
  • Malformed diff from AI

Solutions:

  • Re-request the change in a new message
  • Copy the suggested code manually
  • Clear the diff and try again

Causes:

  • AI referenced different code version
  • Context mismatch

Solutions:

  • Share your current code again
  • Ask AI to regenerate based on current state

Solutions:

  1. Immediately press Ctrl/Cmd + Z
  2. Review the original diff
  3. Ask AI to try again with clearer requirements