Strategy · Pine Script v5 · On the chart

RSI-7 Breakout

by aofwittawat

This strategy identifies breakout trades using a 7-period RSI combined with price extreme lookbacks.

View on GitHub

GitHub stars4on the repository
Pine versionv5runs as is
Lines of code64
Settings7inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago8 Jun 2022

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

64 lines of Pine Script v5 from RSI-7 breakout.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

RSI-7 breakout.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aofwittawat

//@version=5
strategy("RSI-7 breakout", overlay=true, default_qty_value = 2000, default_qty_type= strategy.cash, currency = currency.USDT)

import ZenAndTheArtOfTrading/ZenLibrary/5 as aof

lookback                = input.int(title = "How many lookback-bars", defval = 10,step = 5)
rsi_len                 = input.int(title = "RSI length", defval = 7, step =1)
stop_multiplier         = input.float(title = "Stop Multiplier", defval = 1.0)
rr                      = input.float(title = "RR", defval = 1.2,step = 0.1)
useEMA                  = input.bool(title ="Use ema to prove the trend", defval = true)
ema_len                 = input.int(title = "EMA length", defval = 20,step= 5)
candle_max              = input.float(title = "candleMaxFilter", defval=2.5, minval=0.0, step=0.1)

//indicator
rsi     =   ta.rsi(close, rsi_len)
atr     =   ta.atr(14)
ema     =   ta.ema(close,ema_len)

//candle limit
candle_ok   =   aof.atrFilter(atr, candle_max)

//Entry
buySignal       =   rsi > 70 and close == ta.highest(close, lookback) and not na(rsi) and not na(atr) and strategy.position_size == 0 and barstate.isconfirmed and (useEMA ?  low > ema : true ) and candle_ok
sellSignal      =   rsi < 30 and close == ta.lowest(close, lookback) and not na(rsi) and not na(atr) and strategy.position_size == 0 and barstate.isconfirmed and (useEMA ?  high < ema : true ) and candle_ok


//Calculate MM
longStop    =   low  - (atr * stop_multiplier)
shortStop   =   high + (atr * stop_multiplier)
longStopDistance    =   close - longStop
shortStopDistance   =   shortStop - close
longTarget      =   close + (longStopDistance * rr)
shortTarget     =   close - (shortStopDistance * rr)


var t_stop      =   0.0
var t_target    =   0.0

//Entry order
if buySignal 
    strategy.entry(id="Long", direction=strategy.long,comment = "Long")
    t_stop      :=      longStop
    t_target    :=      longTarget
if sellSignal
    strategy.entry(id="Short", direction=strategy.short,comment ="Short")
    t_stop      :=      shortStop
    t_target    :=      shortTarget

//Exit
strategy.exit(id="Long Exit", from_entry ="Long", limit = t_target, stop=t_stop,when=strategy.position_size> 0, comment = "Long Exit")
strategy.exit(id="Short Exit", from_entry ="Short", limit = t_target, stop=t_stop,when=strategy.position_size< 0, comment = "Short Exit")


//Draw
plotshape(buySignal, style=shape.triangleup,location=location.belowbar,color=color.green)
plotshape(sellSignal, style=shape.triangledown,location=location.abovebar,color=color.red)
plot(strategy.position_size != 0 ? t_stop : na, title = "Stop",color=color.red, style=plot.style_linebr)
plot(strategy.position_size != 0 ? t_target : na, title ="Target", color=color.green, style=plot.style_linebr)
plot(useEMA ? ema :na, color = color.yellow,title ="EMA value")
plotchar(candle_ok,title="Candle OK", color = color.new(color.green,100))
plotchar(syminfo.mintick,title="mintick", color = color.new(color.green,100))

Overview

A long entry triggers when the RSI rises above 70 and price reaches a new lookback high, provided price remains above an optional EMA trend filter and passes an ATR candle size check. Short entries occur when RSI drops below 30 at a new lookback low below the EMA. Risk controls set stop losses using an ATR multiplier and profit targets using a risk-reward ratio, plotting execution levels directly on the price chart.

Details

Published by

aofwittawat on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Oscillators & momentum, Breakout, Trend, Moving averages

Markets

Any symbol

Timeframes

M15-H1, H4 and above

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
How many lookback-barsint10lookback
RSI lengthint7rsi_len
Stop Multiplierfloat1.0stop_multiplier
RRfloat1.2rr
Use ema to prove the trendbooltrueuseEMA
EMA lengthint20ema_len
candleMaxFilterfloat2.5candle_max
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

ADA4H Optuna Strategy

by skywalker0803r
42 stars

This strategy trades longs and shorts on the price chart. Long entries require a close above the prior Donchian high, a close above a long-term SMA, and RSI above a threshold, with size set as a percentage of equity. Long exits use a stop at the prior Donchian

Strategy v5 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of ADA4H Optuna Strategy

Edge 59

by subos2008
6 stars

Edge 59 is a price-chart strategy that combines an ADX directional filter, a weighted moving average, and a trend-follower channel. The channel uses an exponential moving average of close, optionally smoothed by linear regression, and a percentage of a fixed 2

Strategy v5 TrendOscillators & momentum Repaints
Updated 2 years ago · Custom licence GitHub repository of Edge 59

AG Momentum Breakout

by eltonaguiar
4 stars

AG Momentum Breakout is a strategy that identifies continuation signals after pullbacks in trending markets. It filters for uptrends using EMAs and detects recent pullbacks via RSI conditions before entering on RSI crossovers above 50 with ADX confirmation. Th

Strategy v6 TrendOscillators & momentum
Updated today · None stated GitHub repository of AG Momentum Breakout
4 stars

Christian Qullamaggie Strategy is a trend-following and breakout strategy overlay designed to identify high-momentum trading opportunities directly on the price chart. It evaluates market conditions using fast, mid, and slow EMAs, average true range (ATR), and

Strategy v6 BreakoutTrend
Updated 7 months ago · None stated GitHub repository of Christian Qullamaggie Strategy

RSI EMA Breakout

by latentwill
4 stars

This strategy trades momentum breakouts by combining an Exponential Moving Average with the Relative Strength Index. It enters a long position when the closing price is above the EMA and the RSI crosses above the breakout threshold. It enters a short position

Strategy v5 TrendOscillators & momentum
Updated 6 days ago · None stated GitHub repository of RSI EMA Breakout

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers