OPEN-SOURCE SCRIPT
MACD Crossover Strategy [Long/Short]

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.
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.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.