OPEN-SOURCE SCRIPT
MACD & RSI Long/Short Indicator

This indicator generates momentum and trend-reversal alerts by combining standard MACD crossovers with RSI extreme zone breakouts. It relies on an internal state machine and an adjustable signal cooldown timer to filter out market noise and prevent rapid, repetitive entries on lower timeframes.
Core Logic & Indicators
RSI (Relative Strength Index): Triggers LE when crossing above the user-defined oversold line and Short signals when crossing below the overbought line.
MACD: Triggers LE and SE alerts based on the crossover of the MACD line and the Signal line.
EMAs: Plots customizable Moving Averages (9, 21, 50, 100, 200) strictly for visual trend context. EMAs do not dictate trade entries or exits.
Key Features
Modular Signal Routing: Independently toggle RSI or MACD Alerts. When both are enabled, the script executes based on whichever indicator fires first.
Signal Cooldown: A customizable bar delay limits how quickly a new signal can trigger after a previous execution, minimizing false Alerts in choppy conditions.
State Machine Guardrails: Enforces a strict 1-LE / 1-SE alternation rule to prevent multiple overlapping orders in the same direction.
Risk Management: Includes native percentage-based Stop Loss (SL) and Take Profit (TP) parameters.
Date Range Filter: Allows users to restrict execution to specific calendar periods.
How to Use
Select your preferred signal source (RSI, MACD, or both) in the settings panel. Adjust the "Signal Cooldown" parameter based on your specific chart timeframe to filter out immediate whipsaws (higher timeframes may require shorter cooldowns). Use the Enable LE/SE checkboxes to test directional bias independently, and calibrate the percentage inputs to establish your SL/TP risk framework.
Core Logic & Indicators
RSI (Relative Strength Index): Triggers LE when crossing above the user-defined oversold line and Short signals when crossing below the overbought line.
MACD: Triggers LE and SE alerts based on the crossover of the MACD line and the Signal line.
EMAs: Plots customizable Moving Averages (9, 21, 50, 100, 200) strictly for visual trend context. EMAs do not dictate trade entries or exits.
Key Features
Modular Signal Routing: Independently toggle RSI or MACD Alerts. When both are enabled, the script executes based on whichever indicator fires first.
Signal Cooldown: A customizable bar delay limits how quickly a new signal can trigger after a previous execution, minimizing false Alerts in choppy conditions.
State Machine Guardrails: Enforces a strict 1-LE / 1-SE alternation rule to prevent multiple overlapping orders in the same direction.
Risk Management: Includes native percentage-based Stop Loss (SL) and Take Profit (TP) parameters.
Date Range Filter: Allows users to restrict execution to specific calendar periods.
How to Use
Select your preferred signal source (RSI, MACD, or both) in the settings panel. Adjust the "Signal Cooldown" parameter based on your specific chart timeframe to filter out immediate whipsaws (higher timeframes may require shorter cooldowns). Use the Enable LE/SE checkboxes to test directional bias independently, and calibrate the percentage inputs to establish your SL/TP risk framework.
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.