OPEN-SOURCE SCRIPT

MACD Crossover Strategy [Long/Short]

537
MACD Crossover Strategy [Long/Short]

A clean, fully configurable MACD-based strategy built on Pine Script v6.
Supports two entry modes, independent Long/Short toggles, and four alert conditions — ready for both backtesting and live trading.

━━━━━━━━━━━━━━━━━━━━━━━
🔹 ENTRY CONDITIONS (selectable)
━━━━━━━━━━━━━━━━━━━━━━━
- MACDxSignal — Enter when the MACD line crosses the Signal line.
Fast, reactive. Suitable for trending markets.

- HistCross0 — Enter when the Histogram crosses zero.
Slightly smoother signal. Helps reduce noise in choppy conditions.

━━━━━━━━━━━━━━━━━━━━━━━
🔹 FEATURES
━━━━━━━━━━━━━━━━━━━━━━━
- Independent Long / Short toggles
→ Disable either direction to run a one-sided strategy.
→ When one side is off, the opposite signal still closes the open position.

- Lot Size input
→ Set a fixed quantity per entry.

- Commission & Slippage
→ Defaults: 0.1% commission, 2 ticks slippage.
→ Edit directly in the script, or override via Strategy Properties tab.

- Visual entry markers
→ Green ▲ for Long entries, Red ▼ for Short entries, plotted on the MACD pane.

━━━━━━━━━━━━━━━━━━━━━━━
🔹 ALERT CONDITIONS (4 total)
━━━━━━━━━━━━━━━━━━━━━━━
- 🟢 Long Entry — Long signal triggered
- 🔴 Short Entry — Short signal triggered
- 📈 Hist Rising — Histogram switched from falling to rising
- 📉 Hist Falling — Histogram switched from rising to falling

━━━━━━━━━━━━━━━━━━━━━━━
🔹 SETTINGS
━━━━━━━━━━━━━━━━━━━━━━━
- Fast Length: 12 (default)
- Slow Length: 26 (default)
- Signal Length: 9 (default)
- Oscillator / Signal MA Type: EMA or SMA

━━━━━━━━━━━━━━━━━━━━━━━
⚠️ DISCLAIMER
━━━━━━━━━━━━━━━━━━━━━━━
This script is for educational and backtesting purposes only.
Past performance does not guarantee future results.
Always apply proper risk management before using any strategy in live markets.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。