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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.