OPEN-SOURCE SCRIPT
On-Chart Buy, Sell, Caution, Resume Indicator

## 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.
**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.
Script open-source
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Declinazione di responsabilità
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Script open-source
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Declinazione di responsabilità
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.