PROTECTED SOURCE SCRIPT
已更新

MA(7/28) + RSI + MACD(hist) — AUTO(exit)(vol2)

20
MA(7/28) + RSI + MACD — One-Shot Entries, Pullback After Flat, Flip, RSI-Confirmed Exits

A clean, rule-driven entry/exit indicator designed for trend-following with disciplined triggers.
It combines two moving averages (7 & 28), RSI(14), and MACD histogram to print one entry per cross, allow pullback entries after you’re flat, and flip (reverse) when the opposite setup appears. Optional RSI confirmation filters exits to avoid whipsaws. Includes TP/SL preview lines based on recent pivots and a status table.

What it does

Trend filter (MA 7/28)

Golden cross (7 > 28) → long bias, Dead cross (7 < 28) → short bias.

Cross is valid for N bars (user-set lookback). Within this window, the first full setup triggers exactly one entry (“one-shot per cross”).

Entry triggers (two paths)

Cross-based entry (one-shot):

Cross is recent (within lookback) and RSI ≥ 50 (long) / ≤ 50 (short) and MACD histogram > 0 (long) / < 0 (short).

Prints exactly one entry label per cross window (no re-entries while holding).

Pullback entry (when FLAT only):

After you are flat, in an uptrend (7 > 28) price pulled below MA7 recently and reclaimed MA7 (strict re-break), MACD histogram turned up, RSI ≥ 50 → long.

Mirror logic for downtrend (7 < 28) → short.

This lets you re-enter trends without a fresh MA cross after a clean dip.

Flip (instant reverse):

If you hold long and a valid short entry appears, the script will print a long-exit label and immediately a short-entry label on the same bar (and vice versa).

Exits (pattern/behavioral):

Base exit is MACD histogram slope reversal (e.g., long: falling N bars; short: rising N bars).

Optional RSI confirmation: require RSI down/up for N bars to validate the exit (helps avoid premature exits).

TP/SL preview (visual only):

On entry, draws dashed TP/SL lines derived from the last pivot low/high and your chosen R:R (e.g., 1:1.5, 1:2, 1:3).

“TP/SL touch” markers are optional visual cues only (they do not force exits).

Re-entry control:

preventReEntry blocks same-direction re-entries while in position.

oneShotPerCross ensures only one entry per cross window.

After you exit and are flat, pullback entries can re-arm you even without a new cross.

Default settings (editable)

MAs: length 7 & 28, EMA/SMA selectable (default: EMA).

RSI: length 14, thresholds 50 / 50.

MACD: fast 26, slow 100, signal 9 (matches your spec).

Cross lookback: 1–3 bars (default 2) → one shot per cross.

Exit sensitivity: exitBars = 2 (increase to 3 for fewer exits, set 1 for faster).

RSI exit confirm: on/off, with rsiExitBars = 1–3 (default 2).

Pullback after flat: pbLookback (how far back a dip can be found, e.g., 6–8),
pbRiseBars (MACD turn strength, start at 1 for earlier trigger).

R:R preview: choose 1:1.5 / 1:2 / 1:3, pivots via pivotLen (default 5).

Visuals

Entry/Exit labels (readable on dark charts):

Long Entry → green label_up (white text)

Short Entry → red label_down (yellow text)

Long Exit → green label_down (white text)

Short Exit → red label_up (yellow text)

TP/SL preview → dashed lines (green for TP, red for SL).

Optional touches → TP (flag), SL (cross).

Background bias → soft green/red when MA+RSI+MACD agree.

Status table (top-right) → key parameters, state, prices, R:R, and switch statuses.

Alerts

All alerts use fixed messages (Pine v6 constraint). Add them from the Alerts panel:

LONG Entry, SHORT Entry

LONG Exit, SHORT Exit

How to tune (quick guide)

Too many early exits?

Increase exitBars to 2–3; enable useRsiExitConfirm and set rsiExitBars = 2.

Entries feel late after a pullback?

Set pbRiseBars = 1 (earlier MACD turn acceptance).

Keep RSI at 50; if still late, try 49–49.5 (careful: more signals).

Miss cross candle but want one shot soon after?

crossLookback = 2–3.

Remember: one-shot fires once per cross window while holding is prevented from re-firing.

Too many signals in chop?

Keep requireCross = ON, exitBars = 2–3, and useRsiExitConfirm = ON.

Important notes

This is an indicator, not a strategy. To get full backtests (PnL, win rate), convert the entry/exit/flip logic to strategy.entry/close. The logic is already cleanly separated, so conversion is straightforward.

Signals are generated on confirmed bars by default to avoid repaint; disable onlyConfirmed only if you fully understand the implications.

TP/SL preview lines are visual; exits are governed by your exit logic (MACD slope ± RSI confirm), not by TP/SL touches (unless you code it that way in a strategy).

Why traders like this template

Clear, single-shot triggers prevent over-trading around crosses.

Pullback after flat gives a second chance to re-join a trend without requiring a new cross.

Flip on opposite setup captures regime changes decisively.

Exit confirmation balances responsiveness and noise filtering.

Minimal but informative UI (labels, preview lines, table, background).
發行說明
MA(7/28) + RSI + MACD — One-Shot Entries, Pullback After Flat, Flip, RSI-Confirmed Exits

A clean, rule-driven entry/exit indicator designed for trend-following with disciplined triggers.
It combines two moving averages (7 & 28), RSI(14), and MACD histogram to print one entry per cross, allow pullback entries after you’re flat, and flip (reverse) when the opposite setup appears. Optional RSI confirmation filters exits to avoid whipsaws. Includes TP/SL preview lines based on recent pivots and a status table.

What it does

Trend filter (MA 7/28)

Golden cross (7 > 28) → long bias, Dead cross (7 < 28) → short bias.

Cross is valid for N bars (user-set lookback). Within this window, the first full setup triggers exactly one entry (“one-shot per cross”).

Entry triggers (two paths)

Cross-based entry (one-shot):

Cross is recent (within lookback) and RSI ≥ 50 (long) / ≤ 50 (short) and MACD histogram > 0 (long) / < 0 (short).

Prints exactly one entry label per cross window (no re-entries while holding).

Pullback entry (when FLAT only):

After you are flat, in an uptrend (7 > 28) price pulled below MA7 recently and reclaimed MA7 (strict re-break), MACD histogram turned up, RSI ≥ 50 → long.

Mirror logic for downtrend (7 < 28) → short.

This lets you re-enter trends without a fresh MA cross after a clean dip.

Flip (instant reverse):

If you hold long and a valid short entry appears, the script will print a long-exit label and immediately a short-entry label on the same bar (and vice versa).

Exits (pattern/behavioral):

Base exit is MACD histogram slope reversal (e.g., long: falling N bars; short: rising N bars).

Optional RSI confirmation: require RSI down/up for N bars to validate the exit (helps avoid premature exits).

TP/SL preview (visual only):

On entry, draws dashed TP/SL lines derived from the last pivot low/high and your chosen R:R (e.g., 1:1.5, 1:2, 1:3).

“TP/SL touch” markers are optional visual cues only (they do not force exits).

Re-entry control:

preventReEntry blocks same-direction re-entries while in position.

oneShotPerCross ensures only one entry per cross window.

After you exit and are flat, pullback entries can re-arm you even without a new cross.

Default settings (editable)

MAs: length 7 & 28, EMA/SMA selectable (default: EMA).

RSI: length 14, thresholds 50 / 50.

MACD: fast 26, slow 100, signal 9 (matches your spec).

Cross lookback: 1–3 bars (default 2) → one shot per cross.

Exit sensitivity: exitBars = 2 (increase to 3 for fewer exits, set 1 for faster).

RSI exit confirm: on/off, with rsiExitBars = 1–3 (default 2).

Pullback after flat: pbLookback (how far back a dip can be found, e.g., 6–8),
pbRiseBars (MACD turn strength, start at 1 for earlier trigger).

R:R preview: choose 1:1.5 / 1:2 / 1:3, pivots via pivotLen (default 5).

Visuals

Entry/Exit labels (readable on dark charts):

Long Entry → green label_up (white text)

Short Entry → red label_down (yellow text)

Long Exit → green label_down (white text)

Short Exit → red label_up (yellow text)

TP/SL preview → dashed lines (green for TP, red for SL).

Optional touches → TP (flag), SL (cross).

Background bias → soft green/red when MA+RSI+MACD agree.

Status table (top-right) → key parameters, state, prices, R:R, and switch statuses.

Alerts

All alerts use fixed messages (Pine v6 constraint). Add them from the Alerts panel:

LONG Entry, SHORT Entry

LONG Exit, SHORT Exit

How to tune (quick guide)

Too many early exits?

Increase exitBars to 2–3; enable useRsiExitConfirm and set rsiExitBars = 2.

Entries feel late after a pullback?

Set pbRiseBars = 1 (earlier MACD turn acceptance).

Keep RSI at 50; if still late, try 49–49.5 (careful: more signals).

Miss cross candle but want one shot soon after?

crossLookback = 2–3.

Remember: one-shot fires once per cross window while holding is prevented from re-firing.

Too many signals in chop?

Keep requireCross = ON, exitBars = 2–3, and useRsiExitConfirm = ON.

Important notes

This is an indicator, not a strategy. To get full backtests (PnL, win rate), convert the entry/exit/flip logic to strategy.entry/close. The logic is already cleanly separated, so conversion is straightforward.

Signals are generated on confirmed bars by default to avoid repaint; disable onlyConfirmed only if you fully understand the implications.

TP/SL preview lines are visual; exits are governed by your exit logic (MACD slope ± RSI confirm), not by TP/SL touches (unless you code it that way in a strategy).

Why traders like this template

Clear, single-shot triggers prevent over-trading around crosses.

Pullback after flat gives a second chance to re-join a trend without requiring a new cross.

Flip on opposite setup captures regime changes decisively.

Exit confirmation balances responsiveness and noise filtering.

Minimal but informative UI (labels, preview lines, table, background).

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。