OPEN-SOURCE SCRIPT
AI Agent PRIMEFLOW v1

AI Agent PRIMEFLOW v1 — Trend + Breakout + Smart Stops
*By AI Agent Community*
## Overview
PRIMEFLOW v1 is a clean, rules-based signal tool that fires only when **trend + regime + market structure** align.
It combines a **baseline trend**, a **volatility regime filter** (ATR z-score), and **Donchian breakouts**, with **ATR bands** and **Chandelier-style stops** for risk control. Optional **HTF confirmation** keeps entries in sync with higher-timeframe bias.
> Built from public trading concepts (EMA/KAMA/HMA baselines, Donchian breakout, ATR trailing). No proprietary code used.
---
## What it does (3-Layer Confirmation)
1. **Trend** – EMA50/200 relationship + user-selectable baseline (EMA/HMA/KAMA).
2. **Regime** – ATR% z-score filter reduces chop; “Conservative/Balanced/Aggressive” modes adjust threshold.
3. **Structure** – Donchian breakout confirms momentum beyond recent range.
Only when all three align do BUY/SELL labels appear. ATR bands and dynamic stops are plotted for exits and trailing.
---
## Signals & Risk
* **Long**: Trend up (EMA50>EMA200), regime trending, price crosses above baseline **and** breaks the prior Donchian high.
* **Short**: Mirror conditions to the downside.
* **Stops**: Auto-plotted **Long/Short Stop** (ATR-based, Chandelier-style).
* **Targets**: Consider 1.5–2× ATR or ATR bands; keep a runner with trailing stop.
---
## Inputs (key)
* **Signal Mode**: Conservative / Balanced / Aggressive (regime threshold).
* **Use Heikin Ashi Source** (optional smoothing).
* **Structure Lookback (Donchian)**.
* **Volatility Lookback** (for ATR z-score).
* **Baseline Type & Length**: EMA / HMA / KAMA.
* **Trend Filter EMAs**: Fast (default 50) vs Slow (default 200).
* **HTF Confirmation**: set a higher TF (blank = off).
* **ATR Length & Multiplier** (bands & stops).
* **Style toggles**: Bands, regime background, labels.
---
## Recommended Presets
**XAUUSD – M15 (scalping/intraday)**
* Mode: *Balanced* · Baseline: *EMA 50* · Donchian: *20* · ATR: *10 × 2.5* · HTF: *H1*.
**XAUUSD – H1 (intraday)**
* Baseline: *KAMA 50* · Donchian: *25* · ATR: *14 × 2.5* · HTF: *H4*.
**BTCUSDT – H1 (crypto)**
* Baseline: *EMA 100* · Donchian: *30* · ATR: *14 × 2.0* · HTF: *H4* · Mode: *Conservative* in chop.
---
## Alerts (ready)
Create alerts **Once Per Bar Close**:
* **PRIMEFLOW Long** – long entry condition met.
* **PRIMEFLOW Short** – short entry condition met.
* **Trail Flip (Long)** – long trailing stop flips (exit/trim).
* **Trail Flip (Short)** – short trailing stop flips.
Tip: Route alerts to your bot/Telegram/WA webhook. Include placeholders (e.g., `{{ticker}} | {{interval}} | {{close}} | LONG/SHORT | SL: {{plot("Long Stop")}}`).
---
## Best Practices
* Avoid taking breakouts that are **>1.5× ATR** away from baseline (overextended).
* Re-enter on pullbacks while trend & regime remain valid.
* Around high-impact news (NFP/FOMC), wait 15–30 minutes after release.
* Use **HTF 4×** your chart TF (e.g., M15→H1, H1→H4).
---
## Who it’s for
Swing/scalp traders who want higher-quality trend entries with **built-in structure confirmation** and **clear risk lines**, especially on **XAUUSD** and **BTC**.
---
## Notes
* This is an **indicator** (not a strategy). A strategy/backtest version can be provided.
* Educational purposes only. Not financial advice. Trading involves risk.
**Tags:** trend, breakout, ATR, Donchian, chandelier stop, regime filter, XAUUSD, BTC, scalping, intraday, multi-timeframe, heikin ashi
**Changelog**
v1.0 – Initial release: 3-Layer Confirmation, ATR bands/stops, HTF bias, 4 alerts.
*By AI Agent Community*
## Overview
PRIMEFLOW v1 is a clean, rules-based signal tool that fires only when **trend + regime + market structure** align.
It combines a **baseline trend**, a **volatility regime filter** (ATR z-score), and **Donchian breakouts**, with **ATR bands** and **Chandelier-style stops** for risk control. Optional **HTF confirmation** keeps entries in sync with higher-timeframe bias.
> Built from public trading concepts (EMA/KAMA/HMA baselines, Donchian breakout, ATR trailing). No proprietary code used.
---
## What it does (3-Layer Confirmation)
1. **Trend** – EMA50/200 relationship + user-selectable baseline (EMA/HMA/KAMA).
2. **Regime** – ATR% z-score filter reduces chop; “Conservative/Balanced/Aggressive” modes adjust threshold.
3. **Structure** – Donchian breakout confirms momentum beyond recent range.
Only when all three align do BUY/SELL labels appear. ATR bands and dynamic stops are plotted for exits and trailing.
---
## Signals & Risk
* **Long**: Trend up (EMA50>EMA200), regime trending, price crosses above baseline **and** breaks the prior Donchian high.
* **Short**: Mirror conditions to the downside.
* **Stops**: Auto-plotted **Long/Short Stop** (ATR-based, Chandelier-style).
* **Targets**: Consider 1.5–2× ATR or ATR bands; keep a runner with trailing stop.
---
## Inputs (key)
* **Signal Mode**: Conservative / Balanced / Aggressive (regime threshold).
* **Use Heikin Ashi Source** (optional smoothing).
* **Structure Lookback (Donchian)**.
* **Volatility Lookback** (for ATR z-score).
* **Baseline Type & Length**: EMA / HMA / KAMA.
* **Trend Filter EMAs**: Fast (default 50) vs Slow (default 200).
* **HTF Confirmation**: set a higher TF (blank = off).
* **ATR Length & Multiplier** (bands & stops).
* **Style toggles**: Bands, regime background, labels.
---
## Recommended Presets
**XAUUSD – M15 (scalping/intraday)**
* Mode: *Balanced* · Baseline: *EMA 50* · Donchian: *20* · ATR: *10 × 2.5* · HTF: *H1*.
**XAUUSD – H1 (intraday)**
* Baseline: *KAMA 50* · Donchian: *25* · ATR: *14 × 2.5* · HTF: *H4*.
**BTCUSDT – H1 (crypto)**
* Baseline: *EMA 100* · Donchian: *30* · ATR: *14 × 2.0* · HTF: *H4* · Mode: *Conservative* in chop.
---
## Alerts (ready)
Create alerts **Once Per Bar Close**:
* **PRIMEFLOW Long** – long entry condition met.
* **PRIMEFLOW Short** – short entry condition met.
* **Trail Flip (Long)** – long trailing stop flips (exit/trim).
* **Trail Flip (Short)** – short trailing stop flips.
Tip: Route alerts to your bot/Telegram/WA webhook. Include placeholders (e.g., `{{ticker}} | {{interval}} | {{close}} | LONG/SHORT | SL: {{plot("Long Stop")}}`).
---
## Best Practices
* Avoid taking breakouts that are **>1.5× ATR** away from baseline (overextended).
* Re-enter on pullbacks while trend & regime remain valid.
* Around high-impact news (NFP/FOMC), wait 15–30 minutes after release.
* Use **HTF 4×** your chart TF (e.g., M15→H1, H1→H4).
---
## Who it’s for
Swing/scalp traders who want higher-quality trend entries with **built-in structure confirmation** and **clear risk lines**, especially on **XAUUSD** and **BTC**.
---
## Notes
* This is an **indicator** (not a strategy). A strategy/backtest version can be provided.
* Educational purposes only. Not financial advice. Trading involves risk.
**Tags:** trend, breakout, ATR, Donchian, chandelier stop, regime filter, XAUUSD, BTC, scalping, intraday, multi-timeframe, heikin ashi
**Changelog**
v1.0 – Initial release: 3-Layer Confirmation, ATR bands/stops, HTF bias, 4 alerts.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.