OPEN-SOURCE SCRIPT
EMA + S/R Breakout

Here is the full strategy description:
Strategy Name: EMA + S/R Breakout Strategy
This strategy is based on two core concepts — EMA trend direction and Support/Resistance breakout confirmation.
EMA Logic
Two Exponential Moving Averages are plotted on the chart. EMA 9 is the fast line shown in orange and EMA 20 is the slow line shown in blue. When EMA 9 is above EMA 20 it confirms an uptrend. When EMA 9 is below EMA 20 it confirms a downtrend. These two lines together act as a trend filter so that trades are only taken in the direction of the current trend.
Support and Resistance Logic
Resistance is calculated as the highest high of the last 20 completed bars. Support is calculated as the lowest low of the last 20 completed bars. These levels are drawn on the chart as short dotted segments at pivot points only so the chart stays clean and not cluttered with continuous lines.
Breakout Logic
A buy signal is generated when the closing price crosses above the resistance level and at the same time EMA 9 is above EMA 20. This combination confirms that price has broken a key resistance level and the trend is also supporting the move upward. A sell signal is generated when the closing price crosses below the support level and EMA 9 is below EMA 20 confirming a downside breakout with trend alignment.
Entry
Entry is taken on the same candle where the breakout is confirmed. A green triangle with BUY label appears below the candle for long entry and a red triangle with SELL label appears above the candle for short entry.
Exit Logic
For long trades the target is set at 12 percent above the entry price and the stop loss is set at 6 percent below the entry price. For short trades the target is 12 percent below entry and stop loss is 6 percent above entry. Exits are handled automatically by the strategy and labeled as TP +12% when target is hit and SL -6% when stop loss is triggered.
Risk to Reward
The strategy maintains a fixed 1:2 risk to reward ratio on every trade. You risk 6 percent to make 12 percent which means even if only 40 percent of trades hit target the strategy remains profitable over time.
Best Timeframe
This strategy works best on 5 minute to 1 hour charts for intraday and swing trades. The S/R lookback period and EMA lengths can be adjusted from the settings panel based on the stock or asset being traded.
Strategy Name: EMA + S/R Breakout Strategy
This strategy is based on two core concepts — EMA trend direction and Support/Resistance breakout confirmation.
EMA Logic
Two Exponential Moving Averages are plotted on the chart. EMA 9 is the fast line shown in orange and EMA 20 is the slow line shown in blue. When EMA 9 is above EMA 20 it confirms an uptrend. When EMA 9 is below EMA 20 it confirms a downtrend. These two lines together act as a trend filter so that trades are only taken in the direction of the current trend.
Support and Resistance Logic
Resistance is calculated as the highest high of the last 20 completed bars. Support is calculated as the lowest low of the last 20 completed bars. These levels are drawn on the chart as short dotted segments at pivot points only so the chart stays clean and not cluttered with continuous lines.
Breakout Logic
A buy signal is generated when the closing price crosses above the resistance level and at the same time EMA 9 is above EMA 20. This combination confirms that price has broken a key resistance level and the trend is also supporting the move upward. A sell signal is generated when the closing price crosses below the support level and EMA 9 is below EMA 20 confirming a downside breakout with trend alignment.
Entry
Entry is taken on the same candle where the breakout is confirmed. A green triangle with BUY label appears below the candle for long entry and a red triangle with SELL label appears above the candle for short entry.
Exit Logic
For long trades the target is set at 12 percent above the entry price and the stop loss is set at 6 percent below the entry price. For short trades the target is 12 percent below entry and stop loss is 6 percent above entry. Exits are handled automatically by the strategy and labeled as TP +12% when target is hit and SL -6% when stop loss is triggered.
Risk to Reward
The strategy maintains a fixed 1:2 risk to reward ratio on every trade. You risk 6 percent to make 12 percent which means even if only 40 percent of trades hit target the strategy remains profitable over time.
Best Timeframe
This strategy works best on 5 minute to 1 hour charts for intraday and swing trades. The S/R lookback period and EMA lengths can be adjusted from the settings panel based on the stock or asset being traded.
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.