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

his 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.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.