OPEN-SOURCE SCRIPT
Dee MTF ATR Strategy + Alert (3 TPs)

Dee MTF ATR Strategy follows these 7 clear, mechanical rules for entries, exits, and risk.
Entry Rules
Long Entry (Strong Buy)
Condition 1: LTF Supertrend is bullish (price above LTF Supertrend line).
Condition 2: HTF Supertrend is bullish (higher timeframe Supertrend direction = +1).
Condition 3: Fast SMA(8) ≥ Slow SMA(9) (momentum alignment).
Execution: Enter long at next bar’s open after all 3 conditions align.
Short Entry (Strong Sell)
Condition 1: LTF Supertrend is bearish (price below LTF Supertrend line).
Condition 2: HTF Supertrend is bearish (higher timeframe Supertrend direction = -1).
Condition 3: Fast SMA(8) ≤ Slow SMA(9) (momentum alignment).
Execution: Enter short at next bar’s open after all 3 conditions align.
Position rules: Only 1 position at a time (no pyramiding). No entry if already in a trade.
Exit Rules
For Long Trades
SL: Entry price - (ATR × 1.5) → dynamic trailing stop.
TP1: Entry price + (1.0 × Risk Distance) → exit 33% of position.
TP2: Entry price + (2.0 × Risk Distance) → exit 33% of position.
TP3: Entry price + (3.0 × Risk Distance) → exit 34% of position.
For Short Trades
SL: Entry price + (ATR × 1.5) → dynamic trailing stop.
TP1: Entry price - (1.0 × Risk Distance) → exit 33% of position.
TP2: Entry price - (2.0 × Risk Distance) → exit 33% of position.
TP3: Entry price - (3.0 × Risk Distance) → exit 34% of position.
Risk Distance = |Entry - SL| (so TP1 = 1R, TP2 = 2R, TP3 = 3R).
Risk Management Rules
Position Size:
Fixed: fixedQty contracts (default 1.0).
OR Risk‑based: Size so that SL hit = riskUsdPerTrade (default $100).
Commission: 0.01% per side (adjustable).
Order fill: On bar close (avoids intrabar repainting).
Visual Confirmation Checklist
When you see a SB (Strong Buy) triangle:
Blue HTF Supertrend line should be flat/up (not down).
Green LTF Supertrend line should be below price.
SMA(8) line above or touching SMA(9) line.
When you see a SS (Strong Sell) triangle:
Blue HTF Supertrend line should be flat/down (not up).
Red LTF Supertrend line should be above price.
SMA(8) line below or touching SMA(9) line.
Example Trade Plan (5m NAS100)
Strong Buy signal appears at 1.7500:
Entry: 1.7500
ATR(10): 0.0020
SL: 1.7500 - (1.5 × 0.0020) = 1.7470 (Risk = 30 points)
TP1: 1.7500 + (1 × 30) = 1.7530 (33% out)
TP2: 1.7500 + (2 × 30) = 1.7560 (33% out)
TP3: 1.7500 + (3 × 30) = 1.7590 (34% out)
Strategy Logic Summary
Core idea: Trade only when LTF momentum aligns with HTF trend, using ATR for objective risk/reward scaling.
Edge assumption: HTF trend filter reduces whipsaws, LTF momentum catches pullbacks into trend, 3R scaling captures trend continuation.
Entry Rules
Long Entry (Strong Buy)
Condition 1: LTF Supertrend is bullish (price above LTF Supertrend line).
Condition 2: HTF Supertrend is bullish (higher timeframe Supertrend direction = +1).
Condition 3: Fast SMA(8) ≥ Slow SMA(9) (momentum alignment).
Execution: Enter long at next bar’s open after all 3 conditions align.
Short Entry (Strong Sell)
Condition 1: LTF Supertrend is bearish (price below LTF Supertrend line).
Condition 2: HTF Supertrend is bearish (higher timeframe Supertrend direction = -1).
Condition 3: Fast SMA(8) ≤ Slow SMA(9) (momentum alignment).
Execution: Enter short at next bar’s open after all 3 conditions align.
Position rules: Only 1 position at a time (no pyramiding). No entry if already in a trade.
Exit Rules
For Long Trades
SL: Entry price - (ATR × 1.5) → dynamic trailing stop.
TP1: Entry price + (1.0 × Risk Distance) → exit 33% of position.
TP2: Entry price + (2.0 × Risk Distance) → exit 33% of position.
TP3: Entry price + (3.0 × Risk Distance) → exit 34% of position.
For Short Trades
SL: Entry price + (ATR × 1.5) → dynamic trailing stop.
TP1: Entry price - (1.0 × Risk Distance) → exit 33% of position.
TP2: Entry price - (2.0 × Risk Distance) → exit 33% of position.
TP3: Entry price - (3.0 × Risk Distance) → exit 34% of position.
Risk Distance = |Entry - SL| (so TP1 = 1R, TP2 = 2R, TP3 = 3R).
Risk Management Rules
Position Size:
Fixed: fixedQty contracts (default 1.0).
OR Risk‑based: Size so that SL hit = riskUsdPerTrade (default $100).
Commission: 0.01% per side (adjustable).
Order fill: On bar close (avoids intrabar repainting).
Visual Confirmation Checklist
When you see a SB (Strong Buy) triangle:
Blue HTF Supertrend line should be flat/up (not down).
Green LTF Supertrend line should be below price.
SMA(8) line above or touching SMA(9) line.
When you see a SS (Strong Sell) triangle:
Blue HTF Supertrend line should be flat/down (not up).
Red LTF Supertrend line should be above price.
SMA(8) line below or touching SMA(9) line.
Example Trade Plan (5m NAS100)
Strong Buy signal appears at 1.7500:
Entry: 1.7500
ATR(10): 0.0020
SL: 1.7500 - (1.5 × 0.0020) = 1.7470 (Risk = 30 points)
TP1: 1.7500 + (1 × 30) = 1.7530 (33% out)
TP2: 1.7500 + (2 × 30) = 1.7560 (33% out)
TP3: 1.7500 + (3 × 30) = 1.7590 (34% out)
Strategy Logic Summary
Core idea: Trade only when LTF momentum aligns with HTF trend, using ATR for objective risk/reward scaling.
Edge assumption: HTF trend filter reduces whipsaws, LTF momentum catches pullbacks into trend, 3R scaling captures trend continuation.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.