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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。