[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-114610":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":9,"languages":9,"totalLinesOfCode":9,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":14,"stars7d":15,"stars30d":16,"stars90d":13,"forks30d":13,"starsTrendScore":17,"compositeScore":18,"rankGlobal":9,"rankLanguage":9,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":9,"pushedAt":24,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":13,"starSnapshotCount":13,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},114610,"tradingview-indicator-for-ai-agents","roan-maverick\u002Ftradingview-indicator-for-ai-agents","roan-maverick","Tradingview IndicatorBuilt for AI agents",null,354,63,6,0,3,99,133,25,81.4,"MIT License",false,"main",true,[],"2026-11-13 09:55:48","2026-11-23 16:35:12","# AI Agent Lens\n\n**A TradingView indicator built for AI agents.**\n\nIndicators were built for human eyes: colors, arrows, lines. An AI agent can't trade on colors. AI Agent Lens breaks down every closed candle into clean, structured JSON and sends it to any AI agent the moment the candle closes. Your agent reads the chart candle by candle, understands the context, and turns it into clear trading signals. You make the final call.\n\nIt works with any agent. It's built to shine with long-horizon reasoning models like **Claude Fable 5.2**.\n\nOpen source · MIT license · Pine Script v6 · No repainting\n\n---\n\n## What your agent receives on every candle\n\nOne JSON packet per closed candle with everything a trader looks at:\n\n- **Candle breakdown:** body, wicks, range versus ATR, where it closed in its range, gap, pattern (engulfing, hammer, doji, inside bar and more)\n- **The last 5 candles** in the same format, so the agent reads the sequence, not one bar\n- **Regime:** `TREND_UP`, `TREND_DOWN`, `RANGE` or `HIGH_VOLATILITY`\n- **Trend:** EMA 20\u002F50\u002F200 stack, 200 EMA slope, higher-timeframe bias\n- **Momentum and strength:** RSI, MACD histogram, ADX, DI+ and DI-\n- **Volume and volatility:** relative volume, ATR, ATR percentile\n- **Structure:** swing highs and lows, breakouts and breakdowns\n- **Levels:** previous day high and low, VWAP\n- **Long and short scores (0 to 100)** with the five factors behind each score\n- **Risk map:** entry, ATR stop, 1.5R and 3R targets, and live trade status\n\nFull field list: [docs\u002FPACKET_SCHEMA.md](docs\u002FPACKET_SCHEMA.md) · Example: [examples\u002Fsample_packet.json](examples\u002Fsample_packet.json)\n\n---\n\n## How it works\n\n```\n TradingView chart                 Your AI agent                    You\n ┌───────────────────┐  webhook   ┌──────────────────────────┐    ┌──────────────┐\n │  AI Agent Lens    │ ─────────► │ reads the JSON packet    │ ─► │ signal:      │\n │  closes a candle, │  JSON per  │ breaks down the candles  │    │ LONG \u002F SHORT │\n │  builds a packet  │  candle    │ applies your rules       │    │ WAIT \u002F SKIP  │\n └───────────────────┘            └──────────────────────────┘    │ entry, stop, │\n                                                                  │ targets, why │\n                                                                  └──────────────┘\n```\n\n1. The indicator runs on your TradingView chart and calculates everything on each closed candle.\n2. One TradingView alert sends the packet to your agent's webhook URL.\n3. Your agent (Claude Code with Fable 5.2, an n8n flow, your own bot) reads it with the prompt in [agent\u002FAGENT_PROMPT.md](agent\u002FAGENT_PROMPT.md) and returns a signal: decision, confidence, entry, stop, targets, position size, invalidation and why it could fail.\n\n---\n\n## Quick start\n\n### Step 1. Add the indicator to TradingView (1 minute)\n\n1. Open [ai-agent-lens.pine](ai-agent-lens.pine) and copy all of it.\n2. In TradingView, open the **Pine Editor** at the bottom of the chart.\n3. Delete the default code, paste, and click **Save**, then **Add to chart**.\n\nYou'll see the EMA ribbon, key levels, swing points and structure breaks, ▲ LONG \u002F ▼ SHORT score labels, position boxes for every setup, and the **Agent Readout** panel on the right.\n\n### Step 2. Create one alert (1 minute)\n\n1. Open the alert dialog (clock icon, or `Alt + A`).\n2. **Condition:** `AI Agent Lens` → `Any alert() function call`.\n3. **Notifications:** tick **Webhook URL** and paste your agent's URL (Step 3).\n4. Leave the message box as it is. The indicator writes the message itself.\n5. Click **Create**.\n\nOne alert covers one chart (one symbol on one timeframe). Repeat it for every chart you want your agent to watch.\n\n> Webhook alerts need a paid TradingView plan with two-factor authentication turned on. On the Essential and Plus plans, alerts expire after 2 months, so recreate them when they do.\n\n### Step 3. Connect your agent\n\nPick one.\n\n#### Option A: Claude Code with Fable 5.2 (recommended)\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002Froan-maverick\u002Ftradingview-indicator-for-ai-agents\ncd tradingview-indicator-for-ai-agents\n\n# 1. Start the receiver (Python 3, no installs)\npython3 examples\u002Fwebhook_receiver.py --port 8080 --token YOUR_SECRET\n\n# 2. In a second terminal, give it a public HTTPS address\ncloudflared tunnel --url http:\u002F\u002Flocalhost:8080\n```\n\nYour webhook URL for Step 2 is:\n\n```\nhttps:\u002F\u002F\u003Cyour-tunnel-address>\u002Fwebhook?token=YOUR_SECRET\n```\n\nEvery packet is saved to `packets\u002Flatest.json`, `packets\u002Flatest\u002F\u003CSYMBOL>_\u003CTF>.json` and `packets\u002Fhistory.jsonl`.\n\nNow open Claude Code in the same folder:\n\n```bash\nclaude\n```\n\nand ask:\n\n```\nUse agent\u002FAGENT_PROMPT.md as your instructions. Read packets\u002Flatest.json\nand give me the signal for this candle.\n```\n\nMore things to ask:\n\n```\nRead every file in packets\u002Flatest\u002F and rank the charts by setup quality.\n\nCombine the HYPE 1h and 4h packets: the 4h sets direction, the 1h sets timing.\n\nRead the last 50 lines of packets\u002Fhistory.jsonl for BTC and tell me how\nthe momentum and structure changed over the session.\n```\n\n#### Option B: No-code (n8n, Make, Zapier)\n\n1. Create a **Webhook** trigger and copy its URL into the TradingView alert.\n2. Add an **AI** step (Claude or any LLM). Use the block in [agent\u002FAGENT_PROMPT.md](agent\u002FAGENT_PROMPT.md) as the system prompt and the webhook body as the user message.\n3. Send the reply to Telegram, Discord, Slack or email.\n\n#### Option C: Your own bot\n\nPoint the webhook at your server. The body is plain JSON with the schema `ai-agent-lens\u002Fv1`. Check the `schema` field, then use the fields directly or pass the packet to your model with the agent prompt.\n\n---\n\n## What a signal looks like\n\nExample output from the agent prompt ([examples\u002Fsample_signal.json](examples\u002Fsample_signal.json)):\n\n```json\n{\n  \"decision\": \"LONG\",\n  \"confidence\": 74,\n  \"entry\": 70.71,\n  \"stop\": 69.882,\n  \"target_1\": 71.952,\n  \"target_2\": 73.194,\n  \"candle_read\": \"Three candles of steady higher closes, a bearish engulfing shakeout that held above the last swing low, then a bullish engulfing on 1.31x volume that closed in the top quarter of its range and above the last swing high.\",\n  \"invalidation\": \"A 1h close back below 70.48 or a touch of the 69.882 stop\",\n  \"why_this_could_fail\": \"This could be a relief rally inside a larger daily pullback.\"\n}\n```\n\nThe example files are illustrative, not live market data or a real trade.\n\n---\n\n## What you see on the chart\n\n| Element | What it shows |\n|---|---|\n| **Agent Readout panel** | A clean signal card: LONG, SHORT or WAIT, regime, scores, confluence, the open trade with live R multiple, and market context |\n| **Position boxes** | Every setup is drawn like TradingView's long\u002Fshort tool: a red risk box (entry to stop) and a green reward box (entry to target 2) with a dashed target 1 line. Boxes extend while the trade is open and stop where it closed |\n| **Price tags** | ENTRY, STOP, T1 and T2 tags on the right of the open trade |\n| **Setup labels** | ▲ LONG 81 \u002F ▼ SHORT 77. Hover a label to see the factor breakdown behind the score |\n| **EMA ribbon** | EMA 20 and 50 with a green or red fill between them, and a glowing EMA 200 |\n| **Structure** | Confirmed swing highs and lows as dots, and BOS markers when price breaks them |\n| **Key levels** | Previous day high and low (PDH, PDL) and VWAP |\n| **Optional** | Candles colored by score, background shaded by regime |\n\n### The Agent Readout panel\n\nA clean signal card in the corner of the chart:\n\n| Row | Shows |\n|---|---|\n| Header | AI AGENT LENS, symbol and timeframe |\n| Signal | **LONG**, **SHORT** or **WAIT** in large type, with the score |\n| Status | Setup active, target 1 hit, long building (64 of 70), or no confluence yet |\n| Regime | Trend up, trend down, range, high volatility |\n| Long \u002F Short | Both scores |\n| Confluence | How many of the five factors are clearly aligned |\n| Entry, Stop, Targets, Open P&L | The open trade and its live R multiple (shown only while a trade is open) |\n| Context | Higher-timeframe bias, RSI, ADX |\n| Candle, Structure | Current candle pattern and market structure |\n\nSwitch **Panel mode** to Compact to keep only the signal, regime, scores and confluence. The indicator keeps the chart's status line clean (no input values printed next to its name), and every value is also in TradingView's **Data Window**.\n\n---\n\n## How the scores work\n\nEach score is out of 100: five factors, 20 points each.\n\n| Factor | Long side gets points when |\n|---|---|\n| Trend | EMA 20 > 50 > 200 and close above EMA 20 |\n| Momentum | RSI above 50 (not overbought), MACD histogram positive and rising |\n| Strength | DI+ above DI- and ADX at or above 20 |\n| Volume | Bullish candle on above-average volume |\n| Higher timeframe | 4h close above its 50 EMA |\n\nThe short score mirrors it. A **setup** fires when a score crosses 70 on a closed candle and the regime does not point the other way. While a trade is open, repeat signals in the same direction are ignored, so one move gives one signal. Full rules: [docs\u002FSPECIFICATION.md](docs\u002FSPECIFICATION.md).\n\n---\n\n## Settings\n\n| Setting | Default | What it changes |\n|---|---|---|\n| Setup score threshold | 70 | Higher = fewer, stronger setups |\n| Higher timeframe | 240 (4h) | Use D on a 4h chart, W on a daily chart |\n| Block setups in HIGH_VOLATILITY | On | Skips setups during volatility spikes |\n| Stop distance | 1.5 x ATR | Wider or tighter stops |\n| Target 1 \u002F Target 2 | 1.5R \u002F 3R | Reward multiples |\n| Send JSON packet | Every bar close | Or only setups and trade updates, or off |\n| Recent candles in packet | 5 | 1 to 10 |\n| Show packet preview on chart | Off | Prints the live packet next to price, useful for checking your setup |\n| Panel mode | Full | Full or Compact |\n| Panel position, text size | Top right, Small | Where and how big the panel is |\n| Show position boxes | On | Risk and reward boxes for every setup |\n| Color candles by score | Off | Green or red candles when a side leads |\n\n---\n\n## FAQ\n\n**Does it repaint?**\nNo. Setups, trade tracking and packets use closed candles only. Higher-timeframe and daily values use only bars that have already closed. Swing points appear 5 bars after the pivot and never move.\n\n**Which markets and timeframes?**\nAny symbol on TradingView. Crypto, stocks, forex, futures. Intraday timeframes (5m to 4h) get the most out of VWAP and previous-day levels. Symbols without volume data get `null` volume fields.\n\n**Can I use it on the free TradingView plan?**\nYes. The indicator, panel and Data Window all work. Sending packets to an agent needs webhook alerts, which need a paid plan.\n\n**How many packets will I get?**\nOne per closed candle per chart. A 1h chart sends 24 a day. Switch \"Send JSON packet\" to \"Setups and trade updates\" to receive only the important ones.\n\n**Does it place trades?**\nNo. It produces data and signals. Your agent can be connected to a broker if you choose, but this repository never places orders.\n\n---\n\n## Repository\n\n```\ntradingview-indicator-for-ai-agents\u002F\n├── ai-agent-lens.pine           the indicator (Pine Script v6)\n├── agent\u002FAGENT_PROMPT.md        system prompt for your AI agent\n├── docs\u002FSPECIFICATION.md        every calculation and rule\n├── docs\u002FPACKET_SCHEMA.md        every field in the JSON packet\n├── examples\u002Fwebhook_receiver.py receive packets locally (Python 3, no installs)\n├── examples\u002Fsample_packet.json  example packet\n├── examples\u002Fsample_signal.json  example agent signal\n└── LICENSE                      MIT\n```\n\n---\n\n## Disclaimer\n\nThis project is for education and research. It is not financial advice. The indicator describes the chart using fixed rules; it does not predict the future. Signals from any AI agent can be wrong. Test on paper first, size small, and never risk money you can't afford to lose.\n\n## License\n\nMIT. Use it, fork it, build on it.\n","这是一个专为AI交易代理设计的TradingView指标，将每根K线转化为结构化JSON数据包并实时推送至AI服务端。核心功能包括：自动提取单根及前5根K线的形态、趋势、动量、波动率、结构与关键价格水平等30+维度特征，并输出多空评分与风险地图；技术上基于Pine Script v6实现，无重绘，支持任意AI模型（如Claude Fable 5.2）通过Webhook接收并解析。适用于需将图表信号结构化输入AI进行长周期推理、策略回测或自动化信号生成的量化研究与实盘辅助场景。",2,"2026-11-24 04:49:12","CREATED_QUERY"]