OPEN-SOURCE SCRIPT
Cập nhật MA Cross with ATR Targets

The MA Cross with ATR Targets is a comprehensive trading indicator designed for traders who follow moving average crossovers and want precise, ATR-based risk management. It detects crossovers between a fast MA (SMA or EMA) and MA200, then automatically calculates and displays three key levels: Stop Loss, First Take Profit (TP1), and Second Take Profit (TP2) based on ATR multipliers.
Additionally, it includes a multi-timeframe MA200 position table to quickly assess market context across 5min, 15min, 1h, 4h, and 1d timeframes.
Key Features
Moving Average Cross Signals
Detects crossovers between MA20 (configurable as SMA or EMA) and MA200
Visual signals:
Green triangle below bar -> Bullish crossover (MA20 crosses above MA200)
Red triangle above bar -> Bearish crossover (MA20 crosses below MA200)
ATR-Based Target Levels
When a crossover occurs, the indicator automatically plots:
Stop Loss (SL) – Red dashed line
First Take Profit (TP1) – Green dashed line (closer target)
Second Take Profit (TP2) – Green dashed line (main target)
All levels are calculated using the current ATR value with customizable multipliers:
SL Distance = ATR x Stop Multiplier
TP1 Distance = SL Distance x First Take Multiplier
TP2 Distance = SL Distance x Take Multiplier
Multi-Timeframe MA200 Context Table
A compact table in the bottom-left corner shows the position of MA200 relative to current price across five timeframes:
5m, 15m, 1h, 4h, 1d
Green cell -> Price is above MA200 (bullish bias)
Red cell -> Price is below MA200 (bearish bias)
This helps you quickly assess the broader trend direction before entering a trade.
Signal Display
All historical signals are displayed on the chart
Older signals appear without price scale markers and without background fill for cleaner visualization
Only the most recent signals have full visual formatting
How to Use
Entry Signals
LONG entry when a green triangle appears below the bar (MA20 crosses above MA200)
SHORT entry when a red triangle appears above the bar (MA20 crosses below MA200)
Exit / Management
Stop Loss – Place your stop at the red dashed line
Take Profit 1 (TP1) – Consider taking partial profits at the first green line
Take Profit 2 (TP2) – Full profit target at the second green line
Context Check
Before entering, glance at the bottom-left table:
If most timeframes show green -> strong bullish alignment
If most timeframes show red -> strong bearish alignment
Mixed colors -> exercise caution
Recommended Additional Indicators
For better confluence and higher probability setups, it is recommended to use this indicator alongside:
MACD – for momentum confirmation
RSI – for overbought/oversold conditions
ADX and DI v4 – for trend strength and direction
Tips
Adjust ATR multipliers based on your risk tolerance and the asset's volatility
Use the multi-timeframe table to avoid trading against the larger trend
The indicator works on all timeframes – from 1-minute to monthly charts
Combine with the recommended indicators for additional confirmation
Notes
- This is a visual indicator only – it does not execute trades automatically
- All levels are calculated based on the closing price of the signal bar
- Historical signals remain visible but without price scale markers or background fill for cleaner chart presentation
Phát hành các Ghi chú
The MA Cross with ATR Targets is a comprehensive trading indicator designed for traders who follow moving average crossovers and want precise, ATR-based risk management. It detects crossovers between a fast MA (SMA or EMA) and MA200, then automatically calculates and displays three key levels: Stop Loss, First Take Profit (TP1), and Second Take Profit (TP2) based on ATR multipliers.In the latest update, the indicator now includes a powerful multi-timeframe table showing both MA200 position and SuperTrend direction across multiple timeframes, helping you make more informed trading decisions.
Key Features
- Moving Average Cross Signals - Detects crossovers between MA20 (configurable as SMA or EMA) and MA200
- ATR-Based Target Levels - Automatically plots Stop Loss, TP1, and TP2 based on customizable ATR multipliers
- Multi-Timeframe Table - Shows MA200 position and SuperTrend direction across 5m, 15m, 30m, 1h, 4h, 12h, 1d, and 1w timeframes
- Trend Strength Visualization - Color-coded cells for quick trend assessment
- Smart Price Formatting - Automatically detects correct decimal places and adds leading zeros
Visual Signals
- Green triangle below bar → Bullish crossover (MA20 crosses above MA200)
- Red triangle above bar → Bearish crossover (MA20 crosses below MA200)
- Stop Loss (SL) – Red dashed line
- First Take Profit (TP1) – Green dashed line (closer target)
- Second Take Profit (TP2) – Green dashed line (main target)
Multi-Timeframe Table
A compact table in the bottom-left corner shows two rows of information:
MA200 Row: Green if price is above MA200, Red if price is below MA200
SuperTrend Row: Green for uptrend, Red for downtrend
The table includes selectable timeframes: 5m, 15m, 30m, 1h, 4h, 12h, 1d, 1w
How to Use the Table
- If all cells are green → strong bullish alignment across all timeframes
- If all cells are red → strong bearish alignment across all timeframes
- Mixed colors → exercise caution, trend is not uniform
- When all cells are the same color, the probability of a successful trade is higher, but always monitor for changes
ATR Calculation
All levels are calculated using the current ATR value with customizable multipliers:
- SL Distance = ATR x Stop Multiplier
- TP1 Distance = SL Distance x First Take Multiplier
- TP2 Distance = SL Distance x Take Multiplier
How to Use
Entry Signals:
- LONG entry when a green triangle appears below the bar (MA20 crosses above MA200)
- SHORT entry when a red triangle appears above the bar (MA20 crosses below MA200)
Exit / Management:
- Stop Loss – Place your stop at the red dashed line
- Take Profit 1 (TP1) – Consider taking partial profits at the first green line
- Take Profit 2 (TP2) – Full profit target at the second green line
Context Check:
- Before entering, check the bottom-left table for multi-timeframe alignment
- If most timeframes show green → strong bullish bias
- If most timeframes show red → strong bearish bias
- Mixed colors → reduced confidence, consider waiting or reducing position size
Important Trading Recommendations
- Do not trade when MA200 is flat and the price is in a range (consolidation)
- Recommended timeframes: 15 minutes and above
- 2-minute charts are possible but VERY risky – only for experienced traders
- For 2-minute charts, experiment with ATR period set to 7 and adjust multipliers accordingly
- Always wait for confirmation – one green or red cell is not enough
Recommended Additional Indicators
For better confluence and higher probability setups, it is recommended to use this indicator alongside:
- MACD – for momentum confirmation
- RSI – for overbought/oversold conditions
- ADX and DI v4 – for trend strength and direction
Tips
- Adjust ATR multipliers based on your risk tolerance and the asset's volatility
- Use the multi-timeframe table to avoid trading against the larger trend
- The indicator works on all timeframes – from 1-minute to monthly charts
- Combine with the recommended indicators for additional confirmation
- For additional information, ask your favorite AI: "how to trade MA20 and MA200 crossover. What to look for and what additional indicators can be used"
Signal Display
- All historical signals are displayed on the chart
- Older signals appear without price scale markers and without background fill for cleaner visualization
- Only the most recent signals have full visual formatting
Notes
- This is a visual indicator only – it does not execute trades automatically
- All levels are calculated based on the closing price of the signal bar
- Historical signals remain visible but without price scale markers or background fill for cleaner chart presentation
- The confirmation filter is disabled by default – enable it in settings if you want signals to only appear when all selected timeframes agree
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.