OPEN-SOURCE SCRIPT

On-Chart Buy, Sell, Caution, Resume Indicator

202
## What this script does

**On-Chart BUY, SELL, RESUME & CAUTION (EMA 9/20 + MACD)** marks key decision points directly on your candles using a simple, transparent rule set:
This tool is designed to be used on the **timeframe where you actually plan your entries and exits.**

- **BUY** – Bullish EMA crossover (EMA 9 crossing above EMA 20).
- **SELL** – Bearish EMA crossover (EMA 9 crossing below EMA 20).
- **CAUTION** – Trend still intact, but MACD turns against it.
- **RESUME** – MACD turns back in favor of the trend after CAUTION.

All signals are based on **EMA 9/20 trend structure** and the **MACD line vs signal** relationship on the **current chart timeframe**.

The visual layout (circles + thin connectors) is ATR-based, so labels stay clean above wicks and EMAs without covering price action.

---

## Very important: timeframe usage

This tool is designed to be used on the **timeframe where you actually plan your entries and exits.**

- Every signal is calculated from the **current chart timeframe**:
- A BUY on the 1-minute chart is **not** the same signal as a BUY on the 5-minute or 15-minute chart.
- If you change timeframe, the historical signals will change accordingly, because the EMAs and MACD are different.
- Recommended usage:
- Choose your execution/decision timeframe (e.g., 1m, 3m, 5m, 15m, etc.).
- Apply this indicator there.
- Use higher timeframes with your own tools (or your MTF dashboard) for context, **not** by stacking multiple versions of this script.

This clarification is intentional to avoid confusion: it is **not** a multi-timeframe signal engine. It is a clean on-chart signaling layer for the timeframe you trade.

---

## Signal logic

1. **Trend backbone: EMA 9 vs EMA 20**
- `EMA 9 > EMA 20` → bullish structure.
- `EMA 9 < EMA 20` → bearish structure.

2. **BUY / SELL**
- **BUY**: A confirmed crossover of EMA 9 above EMA 20.
- **SELL**: A confirmed crossunder of EMA 9 below EMA 20.
- Optional setting `Wait for candle close` controls whether signals only print on confirmed bars (non-repainting) or can appear intrabar.

3. **CAUTION**
- When trend and MACD temporarily disagree:
- Bull trend (EMA 9 > EMA 20) but **MACD crosses down** → CAUTION for longs.
- Bear trend (EMA 9 < EMA 20) but **MACD crosses up** → CAUTION for shorts.
- CAUTION means: “Trend is still in place, but momentum just fired a warning.”

4. **RESUME**
- After a CAUTION, if MACD crosses back in favor of the prevailing trend:
- In a bull trend after CAUTION → **RESUME** (green).
- In a bear trend after CAUTION → **RESUME** (red).
- This marks a potential continuation after a pause, not a brand-new crossover.

5. **Visual design**
- EMAs can be shown or hidden.
- Signals are drawn **above** price and EMAs using ATR-based spacing:
- Thin vertical connector (optional)
- Arrow
- Circle with the text: BUY, SELL, CAUTION, or RESUME
- This keeps the price area uncluttered and makes each event easy to see.

6. **Alerts**
- Each event type has its own `alertcondition` with a structured message,
allowing integration with webhooks, bots, or external tools.

---

## Originality & compliance notes

- The script is a **single, coherent tool**:
- It implements a clear 4-state model (BUY / SELL / CAUTION / RESUME) from EMA 9/20 + MACD.
- It includes explicit CAUTION and RESUME behavior, which goes beyond a basic crossover indicator.
- Visual placement is calculated (ATR-based) to be usable in live trading.
- All logic is visible and explained; this is not a closed, black-box mashup.
- For publishing:
- Use a **clean chart** for the public example:
- Candles + this indicator (and only minimal extras if needed to illustrate usage).
- Title is ASCII only and the description explains:
- What it does,
- How it works,
- How and where it should be used,
- Why it produces different signals on different timeframes.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.