OPEN-SOURCE SCRIPT
9 EMA First Full Candle Entry + EMA Cross Exit (Strategy)

This strategy is designed to create a simple, mechanical trading system using only the 9 EMA on the 5-minute chart.
Entry Logic
A trade is entered on the first candle that closes completely on one side of the 9 EMA:
Long entry: the candle’s low is above the 9 EMA
Short entry: the candle’s high is below the 9 EMA
Only the first qualifying candle is used, preventing repeated entries during the same move.
Exit Logic
Once in a trade, the position is closed when price crosses back through the 9 EMA:
Long exits when price crosses below the EMA
Short exits when price crosses above the EMA
On the exit candle, the 9 EMA is highlighted yellow to clearly mark the exit point.
Visual Cues
Entry candle is colored yellow
EMA is normally orange and turns yellow on the exit candle only
No background shading, labels, or extra indicators
Purpose
This strategy is built to minimize decisions by:
Using a single timeframe (5-minute)
Using a single indicator (9 EMA)
Defining objective entry and exit rules
Designed for:
SPY and other highly liquid ETFs
Intraday trend continuation
Clean, rules-based execution with minimal discretion
Best performance is typically seen during strong trend periods and reduced during sideways or low-volatility conditions.
Entry Logic
A trade is entered on the first candle that closes completely on one side of the 9 EMA:
Long entry: the candle’s low is above the 9 EMA
Short entry: the candle’s high is below the 9 EMA
Only the first qualifying candle is used, preventing repeated entries during the same move.
Exit Logic
Once in a trade, the position is closed when price crosses back through the 9 EMA:
Long exits when price crosses below the EMA
Short exits when price crosses above the EMA
On the exit candle, the 9 EMA is highlighted yellow to clearly mark the exit point.
Visual Cues
Entry candle is colored yellow
EMA is normally orange and turns yellow on the exit candle only
No background shading, labels, or extra indicators
Purpose
This strategy is built to minimize decisions by:
Using a single timeframe (5-minute)
Using a single indicator (9 EMA)
Defining objective entry and exit rules
Designed for:
SPY and other highly liquid ETFs
Intraday trend continuation
Clean, rules-based execution with minimal discretion
Best performance is typically seen during strong trend periods and reduced during sideways or low-volatility conditions.
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.