to navigate
AI Portfolio Project

Elliott Wave
PineScript Generator

An AI-orchestrated pipeline that turns a stock ticker and a date into a fully working TradingView indicator — no coding required.

Claude AI Prompt Engineering Elliott Wave Theory Multi-Agent Pipeline TradingView PineScript Technical Analysis
The Problem

Elliott Wave is powerful
but brutally complex.

Elliott Wave analysis requires simultaneous mastery of wave rules, Fibonacci math, and charting code — a rare combination that keeps it out of reach for most traders.

  • 3 absolute rules that can never be violated, plus 8 additional guidelines to balance
  • Fibonacci levels at 8+ ratios must be computed and validated against real price data
  • PineScript v6 has strict type constraints that cause silent runtime failures
  • Manual chart work for a single ticker can take hours of analysis
📉

Without AI

  • Manually fetch historical OHLC data
  • Identify and validate pivot points by hand
  • Apply Fibonacci measurements to each wave
  • Hand-code the PineScript indicator
  • Debug type errors and coordinate issues
  • Hours of work per ticker
The Solution

Type a ticker.
Get a working indicator.

A Claude AI prompt system orchestrates specialized subagents — each an expert in one domain — to handle the full pipeline automatically.

INPUT
Ticker + Date
e.g. SPY 2022-10-01
PHASE 1
Cache Check
.wave file lookup
PHASE 2
Wave Analysis
Yahoo Finance data
PHASE 3
PineScript Gen
v6 compliant code
PHASE 4
Validation
5 automated passes
OUTPUT
.pine File
Ready for TradingView
0
Lines of code written manually
4
Specialized AI subagents
5
Validation passes
~45K
Lines of generated PineScript
Prompt Engineering

Modular skill architecture
with strict rule ownership.

Each domain has exactly one authoritative source file. No rule duplication. Clear ownership prevents contradictions.

  • Main Orchestrator — controls flow, cache, subagent delegation
  • elliott-wave-analysis.md — 8-step methodology, Fibonacci validation, PIVOT ACCEPTANCE GATE
  • pinescript-generation-rules.md — v6 type constraints, array safety, coordinate system
  • pinescript-visual-style.md — color scheme, label sizes, opacity rules
  • pinescript-validation-passes.md — 5 integrated QA passes (syntax → type → logic → coords → bounds)
  • bug-fix-protocol.md — fixes applied to source to prevent bug reproduction
🔒

PIVOT ACCEPTANCE GATE

Six mandatory validation checks on every data point — ensures only real, confirmed market pivots enter the analysis. No interpolation. No model memory. Yahoo Finance data only.

♻️

Cache Layer

Wave analysis results are persisted to [TICKER] [DATE].wave. Re-runs skip the expensive data fetch and jump straight to PineScript generation.

Elliott Wave Analysis Engine

Real market data.
Rigorous wave counting.

The AI fetches live OHLC data from Yahoo Finance and applies the full Elliott Wave ruleset — including subwave decomposition at one level deep.

  • Primary + Alternate counts with calibrated confidence scores (e.g., 55% / 45%)
  • Fibonacci validation at 23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%, 127.2%, 161.8%
  • Subwaves mandatory for every impulse — 5-wave for motive, 3-wave for corrective
  • Price targets & invalidation levels per count
  • Timeframe selection — daily (≤2 yr) or weekly (>2 yr) automatically
SPY 2022-10-01.wave (excerpt) // Primary Count — 55% confidence // Motive 5-wave impulse up from lows W1: 2022-10-122022-11-01 Low→High W2: 2022-11-012022-11-03 Flat corrective W3: 2022-11-032022-12-13 Longest wave ✓ W4: 2022-12-132022-12-22 Zigzag (a-b-c) W5: 2022-12-222023-02-02 Extension // Subwaves — W3 decomposition W3.1: 392.17398.05 W3.2: 398.05393.58 W3.3: 393.58405.15 // longest ✓ W3.4: 405.15401.20 W3.5: 401.20409.50 // Target: 430–445 | Invalidation: below 348.11
PineScript Generation

Production-grade code.
Zero manual editing.

The generated indicator includes 8 interactive controls and handles all TradingView v6 quirks automatically.

Upward motive (aqua)
Downward motive (fuchsia)
Corrective waves (orange)
  • Show Count: Primary / Both / Alternate
  • Alternate at 55% opacity when "Both" selected
  • Toggle: Invalidation levels, Targets, Projections, Labels, Subwaves, Legend
  • Legend position: 4 corners
  • Collision detection for overlapping labels
PineScript v6 //@version=6 indicator("SPY Elliott Wave — 2022-10-01", overlay=true, max_lines_count=500) // ── Inputs ────────────────────────────── showCount = input.string("Primary Only", options=["Primary Only","Both","Alternate Only"]) showSubs = input.bool(true, "Show Subwaves") showTgt = input.bool(true, "Show Targets") // ── Drawing (only on last bar) ────────── if barstate.islast altAlpha = showCount == "Both" ? 55 : 100 // Primary W1 — aqua upward line.new(x1=timestamp(2022,10,12), y1=348.11, x2=timestamp(2022,11,01), y2=393.84, xloc=xloc.bar_time, color=color.new(color.aqua,0), width=2) // ... (hundreds more lines auto-generated)
Live Result

SPY Elliott Wave — rendered on TradingView.

Primary count (55% confidence) — 5-wave motive impulse from the October 2022 lows. Subwaves, Fibonacci labels, projected correction targets, and invalidation level all generated automatically.

SPY Elliott Wave indicator on TradingView
SPY Elliott Wave indicator on TradingView (mobile)
Quality Assurance

5-pass automated validation
before any output is written.

🔤

Pass A — Syntax

Verifies PineScript v6 syntax. Checks //@version=6 header, balanced brackets, no v4/v5 deprecated constructs.

🏷️

Pass B — Type Safety

Validates that label style constants are declared as string, not as type keywords. Prevents silent runtime failures.

🧠

Pass C — Logic

Confirms wave ordering is chronologically correct, primary vs alternate drawing separation, and that alternate opacity applies in "Both" mode.

📐

Pass D — Coordinates

Ensures xloc.bar_time is used (never bar index), timestamps are in milliseconds, and zoom stability is preserved.

📦

Pass E — Array Bounds

Every array access guarded by array.size() check. Y-offset collision detection verified for dense pivot regions.

Result

Scripts compile and execute on first paste into TradingView — no manual debugging needed after generation.

Continuous Improvement

Prompt optimization
as an engineering discipline.

A structured optimization report identified 14 weak spots across the prompt system, categorized by severity and impact.

  • Tier 1 — Critical: Ambiguous Fibonacci validation criteria causing pivot misidentification
  • Tier 1 — Critical: Three-way textalign contradiction between skill files (discovered & documented)
  • Tier 2 — Medium: Subwave coverage rule lacked explicit "skip is forbidden" enforcement
  • Tier 2 — Medium: Timeframe boundary at 730 days not propagated to all downstream modules
  • Tier 3 — Low: Cache invalidation keywords list incomplete (missing "redo", "recount")
"Treating prompts like source code — with version control, ownership tables, and structured QA — is what separates a one-off experiment from a reliable AI system."
14
Weak spots identified
3
Severity tiers
6
Skill files with clear ownership
Key Takeaways

What this project demonstrates.

🤖

Multi-Agent Orchestration

Decomposing a complex task into specialized subagents — each with focused context — dramatically improves output quality and reliability over a single monolithic prompt.

📐

Prompt as Architecture

Modular skill files with explicit rule ownership, a cache layer, and a validation pipeline mirrors software engineering best practices applied to AI system design.

📈

Domain Depth Matters

Embedding expert-level financial analysis rules (Elliott Wave theory, Fibonacci ratios, PineScript v6 constraints) is what makes AI output actually useful in a professional context.

🔄

Caching & Efficiency

Smart caching means the expensive data-fetch and wave-counting step runs once. Subsequent visual iterations are near-instant — a real productivity multiplier.

🧪

QA Built In

5-pass automated validation isn't an afterthought — it's a core phase of the pipeline. The system self-corrects before handing output to the user.

📝

Continuous Refinement

A structured optimization report treats prompts as living artifacts — bugs fixed in source, contradictions documented, and weak spots prioritized by severity.

AI PORTFOLIO

From ticker symbol
to TradingView indicator
with one AI prompt.

This project shows that when AI is architected thoughtfully — with domain expertise, modular design, and built-in QA — it can automate genuinely complex professional workflows.

Claude AI Prompt Engineering Elliott Wave Theory Financial Analysis PineScript v6 TradingView

Built with Claude Code · github.com/fede_/ElliotWavePineScriptGenerator