OPEN-SOURCE SCRIPT
AetherEdge - Multi-Agent RL Consensus Engine

🖊️ Overview
A council of independent reinforcement-learning agents that debate, then vote. Three to five lightweight Actor-Critic agents run in parallel, each trained under a DIFFERENT reward function — trend-following, mean-reversion, risk-averse, breakout, and volatility-scaled — so each develops its own "personality" and reads the same market through a different lens. Every bar, each agent casts a directional vote, and a CONSENSUS score measures how strongly the council agrees. The engine speaks only when the agents do: a large arrow appears only on high agreement, and a single Consensus Meter (0–100%) shows the strength of the collective conviction. The evolution of a single RL optimizer into a "debate among multiple AIs."
🔶 Key Features
Multi-agent council — 3–5 independent RL agents learn in parallel and form consensus by voting
Different reward functions (personalities) — trend, mean-reversion, risk-averse, breakout, volatility-scaled
Consensus scoring — combines how many agents agree with their confidence into an agreement score
Meritocratic voting (optional) — better-performing agents get a larger say in the consensus
Fires only on high agreement — the large arrow appears only when council agreement clears the gate
Consensus Meter — a single 0–100% gauge of agreement, lit in the direction color on consensus
Per-agent vote dots — tiny dots show each agent's individual vote at the signal bar
Intelligence panel — consensus score, vote tally, and each agent's name / vote / performance at a glance
🧠 Technical Architecture
The agents perceive the market as a four-dimensional state vector (momentum spread, RSI deviation, Bollinger position, position-within-range — all z-normalized). The core is N independent Actor-Critic agents, each producing Actor logits (3 actions → softmax policy) and a Critic value from a compact shared trunk (tanh).
Agents differentiate via personality-specific reward shaping. From a common risk-adjusted (volatility-normalized) return, the trend agent amplifies reward in strong trends, mean-reversion when stretched, risk-averse shrinks reward in high vol and penalizes drawdown, breakout near range edges, and vol-scaled by volatility magnitude. The agents thus learn distinct behaviors from the same price data. Learning is Advantage Actor-Critic (A = r + γV(s′) − V(s) driving the Actor's policy gradient) from a shared replay buffer.
In the consensus process, every bar each agent produces a policy and votes its max-probability action. Each vote is weighted by "performance × confidence" (when meritocratic), and the weighted long vs. short sums determine the consensus direction. The consensus score is a [0,1] blend of the dominant side's weighted share (its fraction of the council's total voice) and the raw vote agreement (fraction of agents on the dominant side). Only when this clears the gate do the large arrow and meter light up.
⚙️ Recommended Settings & Tuning Guide
BTC (1H–4H): Number of Agents 5, γ 0.93, Min Consensus 0.60, Weight by Performance ON. The full 5-personality roster fits well
ETH (1H–4H): As BTC, with Reward Lookahead 5–8
SOL (15m–1H): High volatility favors Min Consensus 0.65–0.7 to be stricter, where the risk-averse agent earns its keep
XRP (1H–4H): Spike-prone; Agents 5 to include breakout and vol-scaled, Consensus Smoothing 3 to stabilize agreement
Number of Agents: more gives diverse views but makes consensus harder; 5 for all personalities, 3 for the core (trend / mean-rev / risk-averse)
Min Consensus to Signal: higher (0.7+) makes arrows rare and high-quality; lower (0.5) more frequent — raise it if you want near-unanimity only
Weight by Performance: ON for meritocracy (favoring better agents), OFF for equal say; ON is recommended in stable markets
Consensus Smoothing: higher smooths the agreement; lower is more reactive
💡 How to Use in Practice
Reacting to the large arrow: the arrow is a "collective verdict" where the council reached high agreement — multiple distinct strategy-AIs concurring, a core basis for trend-following entries
Reading the Consensus Meter: a full gauge lit in the direction color = strong agreement; under half = a split council, so standing aside is wise
Using vote dots & panel: check each agent's (TREND / MEAN-REV / RISK-AVERSE / BREAKOUT / VOL-SCALED) vote and performance to see which strategy backs the current market
Using disagreement as caution: low consensus marks an uncertain market where strategies diverge — a reason to skip entries
Watching performance scores: the per-agent performance reveals which strategy is working now (e.g. a high-performing trend agent suggests a trend regime)
Multi-timeframe usage: confirm the council's big-picture agreement on the higher timeframe (4H), then refine timing on consensus signals on the lower one (15m–1H)
⚠️ Important Notes
Initial learning period: right after launch the buffer is nearly empty and all agents are immature; treat signals as low-confidence until agreement stabilizes (several hundred bars)
Learning resets: changing parameters, switching symbol/timeframe, or recompiling reinitializes all agent weights, performance scores, and the buffer, restarting learning from zero
Nature of consensus: high agreement means "multiple strategies concurred," but markets exist where all agents are wrong at once (shock events) — consensus is not a guarantee of certainty
On forward-looking reward: rewards use closed-bar forward returns (a standard RL training construct); current-bar votes are on confirmed values, but as with any adaptive system, historical and live behavior can differ — always forward-test
Constraints: this is a lightweight implementation operating within Pine's compute budget; more agents increase compute proportionally
🚨 Disclaimer
This indicator is an analytical and educational visualization tool. The multi-agent reinforcement learning, per-agent reward shaping, consensus score, and Consensus Meter are quantitative heuristics computed on-chart from price data — they are not financial advice, buy/sell signals, or any guarantee of future performance. Even a consensus of multiple agents can be wrong. Always combine any tool with your own analysis and disciplined risk management.
A council of independent reinforcement-learning agents that debate, then vote. Three to five lightweight Actor-Critic agents run in parallel, each trained under a DIFFERENT reward function — trend-following, mean-reversion, risk-averse, breakout, and volatility-scaled — so each develops its own "personality" and reads the same market through a different lens. Every bar, each agent casts a directional vote, and a CONSENSUS score measures how strongly the council agrees. The engine speaks only when the agents do: a large arrow appears only on high agreement, and a single Consensus Meter (0–100%) shows the strength of the collective conviction. The evolution of a single RL optimizer into a "debate among multiple AIs."
🔶 Key Features
Multi-agent council — 3–5 independent RL agents learn in parallel and form consensus by voting
Different reward functions (personalities) — trend, mean-reversion, risk-averse, breakout, volatility-scaled
Consensus scoring — combines how many agents agree with their confidence into an agreement score
Meritocratic voting (optional) — better-performing agents get a larger say in the consensus
Fires only on high agreement — the large arrow appears only when council agreement clears the gate
Consensus Meter — a single 0–100% gauge of agreement, lit in the direction color on consensus
Per-agent vote dots — tiny dots show each agent's individual vote at the signal bar
Intelligence panel — consensus score, vote tally, and each agent's name / vote / performance at a glance
🧠 Technical Architecture
The agents perceive the market as a four-dimensional state vector (momentum spread, RSI deviation, Bollinger position, position-within-range — all z-normalized). The core is N independent Actor-Critic agents, each producing Actor logits (3 actions → softmax policy) and a Critic value from a compact shared trunk (tanh).
Agents differentiate via personality-specific reward shaping. From a common risk-adjusted (volatility-normalized) return, the trend agent amplifies reward in strong trends, mean-reversion when stretched, risk-averse shrinks reward in high vol and penalizes drawdown, breakout near range edges, and vol-scaled by volatility magnitude. The agents thus learn distinct behaviors from the same price data. Learning is Advantage Actor-Critic (A = r + γV(s′) − V(s) driving the Actor's policy gradient) from a shared replay buffer.
In the consensus process, every bar each agent produces a policy and votes its max-probability action. Each vote is weighted by "performance × confidence" (when meritocratic), and the weighted long vs. short sums determine the consensus direction. The consensus score is a [0,1] blend of the dominant side's weighted share (its fraction of the council's total voice) and the raw vote agreement (fraction of agents on the dominant side). Only when this clears the gate do the large arrow and meter light up.
⚙️ Recommended Settings & Tuning Guide
BTC (1H–4H): Number of Agents 5, γ 0.93, Min Consensus 0.60, Weight by Performance ON. The full 5-personality roster fits well
ETH (1H–4H): As BTC, with Reward Lookahead 5–8
SOL (15m–1H): High volatility favors Min Consensus 0.65–0.7 to be stricter, where the risk-averse agent earns its keep
XRP (1H–4H): Spike-prone; Agents 5 to include breakout and vol-scaled, Consensus Smoothing 3 to stabilize agreement
Number of Agents: more gives diverse views but makes consensus harder; 5 for all personalities, 3 for the core (trend / mean-rev / risk-averse)
Min Consensus to Signal: higher (0.7+) makes arrows rare and high-quality; lower (0.5) more frequent — raise it if you want near-unanimity only
Weight by Performance: ON for meritocracy (favoring better agents), OFF for equal say; ON is recommended in stable markets
Consensus Smoothing: higher smooths the agreement; lower is more reactive
💡 How to Use in Practice
Reacting to the large arrow: the arrow is a "collective verdict" where the council reached high agreement — multiple distinct strategy-AIs concurring, a core basis for trend-following entries
Reading the Consensus Meter: a full gauge lit in the direction color = strong agreement; under half = a split council, so standing aside is wise
Using vote dots & panel: check each agent's (TREND / MEAN-REV / RISK-AVERSE / BREAKOUT / VOL-SCALED) vote and performance to see which strategy backs the current market
Using disagreement as caution: low consensus marks an uncertain market where strategies diverge — a reason to skip entries
Watching performance scores: the per-agent performance reveals which strategy is working now (e.g. a high-performing trend agent suggests a trend regime)
Multi-timeframe usage: confirm the council's big-picture agreement on the higher timeframe (4H), then refine timing on consensus signals on the lower one (15m–1H)
⚠️ Important Notes
Initial learning period: right after launch the buffer is nearly empty and all agents are immature; treat signals as low-confidence until agreement stabilizes (several hundred bars)
Learning resets: changing parameters, switching symbol/timeframe, or recompiling reinitializes all agent weights, performance scores, and the buffer, restarting learning from zero
Nature of consensus: high agreement means "multiple strategies concurred," but markets exist where all agents are wrong at once (shock events) — consensus is not a guarantee of certainty
On forward-looking reward: rewards use closed-bar forward returns (a standard RL training construct); current-bar votes are on confirmed values, but as with any adaptive system, historical and live behavior can differ — always forward-test
Constraints: this is a lightweight implementation operating within Pine's compute budget; more agents increase compute proportionally
🚨 Disclaimer
This indicator is an analytical and educational visualization tool. The multi-agent reinforcement learning, per-agent reward shaping, consensus score, and Consensus Meter are quantitative heuristics computed on-chart from price data — they are not financial advice, buy/sell signals, or any guarantee of future performance. Even a consensus of multiple agents can be wrong. Always combine any tool with your own analysis and disciplined risk management.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.