# AlgoPro QuantFlow

## AlgoPro QuantFlow — USER GUIDE

<figure><img src="/files/qyXEodWryz1oWG981hEe" alt=""><figcaption></figcaption></figure>

#### Why QuantFlow is Powerful

* **Multi‑signal engine:** Combine *Range/Price/Volume/Trend* breakouts with a *Daily MA Bias* so only confluence‑backed setups pass.
* **Adaptive exits:** Pick among *TP Methods* (ATR / Percentage / Risk‑Reward / Spread) with optional *Trailing TP*; run classic TP/SL **or** flip into *Swing Trading Mode* for ATR/MA/HL/Percent/Volume trails.
* **Account‑first risk rails:** Intraday loss cap, max drawdown, losing/winning streak caps, daily/weekly trade limits—entries pause automatically when limits hit.
* **Session discipline:** Trade only during selected days/sessions, optionally auto‑close at session end.
* **Automation‑ready:** One‑time **Open/TP/Close** commands are injected into alerts via `{{strategy.order.alert_message}}`.
* **Visual clarity:** On‑chart labels for Long/Short entries, live TP/SL levels, and an Equity Dashboard (daily & monthly %) for quick evaluation.

> **What it is:** QuantFlow is a TradingView **strategy** that orchestrates entry filters, flexible TP/SL (and swing trails), time filters, and robust risk limits—then pipes everything to your webhook/automation.

***

***

### How Entries Are Formed (Logic Overview)

A trade can trigger only if **all gates** are open:

* **Side enabled** (Long/Short) in **TRADE SETUP**
* **Time ok** (inside **TIME FILTERS**)
* **Risk ok** (all chosen limits under **RISK MANAGEMENT**)
* **No position** and **entry cooldown satisfied**
* **Signal confluence** passes under **LONG / SHORT SIGNAL SETUP**

Internally, each enabled filter acts like `(not enabled) OR (condition true)`. So you can start with just one filter, then add more confirmations gradually.

***

### TRADE AUTOMATION COMMANDS

**Purpose:** Provide the exact webhook/alert payloads. In your alert, set **Message** to `{{strategy.order.alert_message}}`.

* **Open Long Command** • **Open Short Command**
* **Long TP1 … TP5 Command**
* **Short TP1 … TP5 Command**
* **Long 100% Close Command (SL, Swing Exit, Early Close)**
* **Short 100% Close Command (SL, Swing Exit, Early Close)**

**Notes**

* Use plain text or JSON—whatever your bot needs. The strategy injects the matching message when that event occurs.
* For entries, the script calls `strategy.entry(..., alert_message = Open Cmd)`; for exits and TP tiers it uses `strategy.exit(..., alert_profit = TP Cmd, alert_loss = Close Cmd)` and full‑close events use your 100% close commands.

***

### LONG / SHORT SIGNAL SETUP

Choose which confirmations must agree for a Long/Short.

**Filters you can toggle** (L and S have mirrors):

* **Range Breakout (ʟ / 🇸)**
  * *Sense (ʟ / 🇸)* — sensitivity of the range filter (higher = stricter).
  * Internals: adaptive EMA‑based range with up/down state.
* **Price Breakout (ʟ / 🇸)**
  * *Sens¹ (ʟ / 🇸)* — lookback for highest/lowest breakout.
  * Logic: close > prior highest (long) or close < prior lowest (short).
* **Volume Breakout (ʟ / 🇸)**
  * *Sens² (ʟ / 🇸)* — lookback for peak volume; demand spike confirmation.
* **Trend Breakout (ʟ / 🇸)**
  * *Sens³ (ʟ / 🇸)* — SMA lookback; price above/below trend.
* **Daily MA Bias (ʟ / 🇸)**
  * *MA (ʟ / 🇸)* — EMA length computed on **1D**, then smoothed. Longs require price above the smoothed daily EMA; shorts require below.

> **Tip:** Start with *Range + Trend + Daily MA Bias* for structure; add *Price* and/or *Volume* to catch momentum bursts.

***

### TRADE SETUP

* **Long Trades / Short Trades** — master side toggles.
* **Close Trades on Opposite Signal** — if the opposite side qualifies, flat the current position.
* **Close Early # Bars** — force‑exit after N bars in a trade.
* **Break Even # Bars** — if price stays favorable for N bars, move SL to entry.
* **Cool Down # Bars** — minimum bars to wait after an entry before any new one.
* **Show Take Profit / Stop Loss** — draw entries/TP/SL on the chart.

***

### SWING TRADING MODE (and Exit Management)

Toggle to manage positions with **dynamic trails** instead of fixed TP tiers.

* **Swing Trail Method:** *ATR Trail* / *Volume Trail* / *MA Trail* / *HL Trail* / *Percent Trail*
* **ATR Trail (ʟ / 🇸)** — ATR multipliers for swing SL.
* **Percent Trail (ʟ / 🇸)** — initial % and **P¹** trail speed.
* **MA Trail (ʟ / 🇸)** — choose the MA type and length.
* **High/Low Trail (ʟ / 🇸)** — lookback & source for structural trailing.
* **Vol. Trail (ʟ / 🇸)** — VIDYA‑based dynamic bands with momentum and band distance controls.
* **Swing TP (ʟ / 🇸)** — ATR‑derived *management levels* used to trigger:
  * **BE¹ … BE⁵** — move SL to **Break Even** at the matching Swing TP.
  * **After¹ … After⁵** — *exit* after hitting a higher Swing TP (closes at the prior level).

> Swing TP markers are there to drive **BE/After** behavior; they are **not** partial‑close orders by themselves.

***

### TAKE PROFIT METHOD

Pick how TP levels are placed (when **not** in Swing Mode). The script builds **TP1…TP5** upon entry and can **trail TPs toward entry** over time.

* **Take Profit Method** — *ATR*, *Percentage*, *Risk Reward*, or *Spread*
  * **RR TP (ʟ / 🇸)** — multiplier of the initial risk (entry vs SL)
  * **ATR TP (ʟ / 🇸)** — ATR multipliers
  * **Percent TP (ʟ / 🇸)** — percent from entry
  * **Spread TP (ʟ / 🇸)** — multiple of avg bar spread
* **Trailing TP -** — enable TP trailing
  * **TP Trail Speed** — how quickly each TP decays toward entry

***

### STOP LOSS METHOD

Define the base stop and optional trailing.

* **Stop Loss Method** — *ATR*, *True Range*, *Percentage*, *Moving Average*, *High/Low*, *Spread*
  * **ATR/TR SL (ʟ / 🇸)** — ATR/TR multipliers
  * **Percent SL (ʟ / 🇸)**
  * **MA SL Type / MA² (ʟ / 🇸)** — MA‑based SL
  * **High/Low SL (ʟ / 🇸)** — structural SL
  * **Spread SL (ʟ / 🇸)**
* **Trailing SL -** — enable SL trailing
  * **SL Trail Speed** — blend the SL toward price each bar
* **Stop Loss % Cap -** — hard cap on SL distance by % of price

> In Swing Mode, the separate swing trail controls take precedence.

***

### STOP LOSS MANAGEMENT

Automate SL moves when TP tiers hit (non‑swing mode):

* **Enable Move SL to Break Even after TP** — choose **TP¹…TP⁴** that move SL to entry.
* **Enable Move SL after each TP is Hit** — cascade moves behind the latest TP (e.g., to TP1 after TP2, etc.).

***

### TAKE PROFIT LEVELS

Turn on any of **TP¹…TP⁵** and set how much to close at each:

* **%¹ … %⁵** — portion of position to close at that TP.

> If **Show Take Profit / Stop Loss** is on, the TP/SL and Entry lines + labels are drawn live.

***

### TIME FILTERS

* **Close at Session End** — force‑flat at your session close.
* **Custom Timezone (UTC±)** — override chart timezone.
* **Start From / End To** — backtest/live restriction by date.
* **Mon…Sun** — select tradable weekdays.
* **Session 1 / Session 2** — custom windows (e.g., 0700–1600 & 1300–2200).

***

### RISK MANAGEMENT

Apply prop‑style risk constraints. When any enabled limit is breached, **new entries halt** (and some rules can flatten):

* **Loss Streak** — max consecutive losing trades
* **Win Streak** — max consecutive winning trades
* **Row Loss InDay** — max losing **days** in a row
* **DrawDown ％** — max equity drawdown
* **InDay Loss ％** — max intraday equity loss
* **Daily Trades** — cap orders per day
* **Weekly Trades** — cap orders per week

***

### EQUITY PERFORMANCE DASHBOARD

Overlay table showing Monthly and Daily % performance across recent periods. Use the *Dashboard Position* and *Dashboard Size* inputs to place/scale it.

***

### Alerts → Webhooks (step‑by‑step)

1. Open **TRADE AUTOMATION COMMANDS** and paste the exact payloads your bot expects (Open/TP/Close for Long & Short).
2. On the chart, click **Alert** → **Condition:** *AlgoPro QuantFlow* (this strategy) → **Any alert() function call** or the specific order events, depending on preference.
3. **Message:** `{{strategy.order.alert_message}}` (this replaces the alert body with the proper command at runtime).
4. If using a webhook, paste your webhook URL in the TradingView alert form.

***

***

### Troubleshooting

* **No trades?** Check Time Filters, Risk caps (they block entries), side toggles, and Cooldown.
* **TPs not closing?** Ensure TP tiers are enabled and % set > 0; confirm you’re **not** in Swing Mode.
* **Swing exits not firing?** Swing Mode must be on; BE/After toggles drive the actual closes at the defined Swing TP markers.
* **Alerts send wrong payload?** Verify the command fields under Automation and that your alert message is exactly `{{strategy.order.alert_message}}`.

***

### Safety & Notes

* Backtest slippage/fees to approximate real fills.
* Session close exits require sessions enabled.
* This is a rules engine, not financial advice. Markets involve risk.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://algopro.gitbook.io/traders-trail-faq/algopro-quantflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
