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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.