OPEN-SOURCE SCRIPT
EMA Cross + MACD Confluence (with Session-Start Entry)

EMA Cross + MACD Confluence Strategy (with Session-Start Entry)
Idea originally from kirilov
Description:
This strategy blends a classic Exponential Moving Average (EMA) crossover system
with MACD histogram confirmation, all within your custom trading window. On each bar:
• Calculates two user-defined EMAs (Fast and Slow).
• Computes the MACD line, signal line, and histogram using customizable lengths.
• Only takes new trades during your chosen session hours and date range.
• Enters on a fresh crossover (or crossunder), OR immediately at session start
if the crossover condition is already true.
• Applies MACD confluence: long entries only when the MACD histogram is positive;
short entries only when it’s negative.
• Exits positions when the opposite EMA-cross signal fires or when the session closes.
Key Features:
• 100% user-defined parameters: EMAs, MACD lengths, session times, date range, and
long/short or both directions.
• Session-aware “catch-up” entry—never miss a trend that started before the market open.
• Lightweight and transparent: only standard Pine v6 functions, no external libraries.
Disclaimer:
This script is provided for educational and illustrative purposes only.
It is NOT financial advice, a recommendation to buy or sell, or a substitute for your
own due diligence. Past performance is no guarantee of future results. Trade at your
own risk.
Idea originally from kirilov
Description:
This strategy blends a classic Exponential Moving Average (EMA) crossover system
with MACD histogram confirmation, all within your custom trading window. On each bar:
• Calculates two user-defined EMAs (Fast and Slow).
• Computes the MACD line, signal line, and histogram using customizable lengths.
• Only takes new trades during your chosen session hours and date range.
• Enters on a fresh crossover (or crossunder), OR immediately at session start
if the crossover condition is already true.
• Applies MACD confluence: long entries only when the MACD histogram is positive;
short entries only when it’s negative.
• Exits positions when the opposite EMA-cross signal fires or when the session closes.
Key Features:
• 100% user-defined parameters: EMAs, MACD lengths, session times, date range, and
long/short or both directions.
• Session-aware “catch-up” entry—never miss a trend that started before the market open.
• Lightweight and transparent: only standard Pine v6 functions, no external libraries.
Disclaimer:
This script is provided for educational and illustrative purposes only.
It is NOT financial advice, a recommendation to buy or sell, or a substitute for your
own due diligence. Past performance is no guarantee of future results. Trade at your
own risk.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.