This strategy overlays two exponential moving averages and ATR-based price targets directly on the price chart while calculating the Relative Vigor Index internally.
1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
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
78 lines of Pine Script v5 from Bitcoin trend RVI and Ema.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
Bitcoin trend RVI and Ema.pine
//this strategy works well on h4 (btc or eth)
//@version=5
strategy(title="Relative Vigor Index", shorttitle="RVGI",overlay=true)
//indicator(title="Relative Vigor Index", shorttitle="RVGI", format=format.price, precision=4, timeframe="", timeframe_gaps=true)
len = input.int(4, title="Length rvi", minval=1)
rvi = math.sum(ta.swma(close-open), len)/math.sum(ta.swma(high-low),len)
sig = ta.swma(rvi)
offset = input.int(0, "Offset rvi", minval = -500, maxval = 500)
atrlength = input.int(19,title="Atr Length",minval=1)
ema1 = input.int(95,title="Long EMA rapida",minval=1,step=10)
ema2 = input.int(200,title="Long EMA lenta",minval=1,step=10)
atrSL = input.float(2.0,title="Atr SL", step=0.1)
atrTP = input.float(1.0,title="Atr TP", step=0.1)
atr = ta.atr(atrlength)
esalcista = low > ta.ema(close,ema1) and ta.ema(close,ema1) > ta.ema(close,ema2)
bajista = high < ta.ema(close,ema1) and ta.ema(close,ema1) < ta.ema(close,ema2)
//plot(high + atr)
//plot(low - atr)
//strategy.entry("compra",strategy.long, when=ta.crossover(rvi,sig))
//strategy.close("compra",when=ta.crossunder(rvi,sig))
//plot(rvi, color=#008000, title="RVGI", offset = offset)
//plot(sig, color=#FF0000, title="Signal", offset = offset)
//plotshape(true,style=shape.xcross)
var TP = 0.0
var SL = 0.0
comprado = strategy.position_size>0
vendido = strategy.position_size<0
crucepositivo = ta.crossover(rvi,sig)
crucenegativo = ta.crossunder(rvi,sig)
if comprado
// ver SL
if low < SL
strategy.close("BUY",comment="SL")
if comprado
//ver tp
if high > TP
strategy.close("BUY",comment="TP")
if not comprado and not vendido
if crucepositivo and esalcista
strategy.entry("BUY",strategy.long)
SL := low - (atr * atrSL)
TP := high + (atr * atrTP)
alert("BUY",alert.freq_once_per_bar)
//---------------
if vendido
// ver SL
if high > SL
strategy.close("SELL",comment="SL")
if vendido
//ver tp
if low < TP
strategy.close("SELL",comment="TP")
if not vendido and not comprado
if crucenegativo and bajista
strategy.entry("SELL",strategy.short)
SL := high + (atr * atrSL)
TP := low - (atr * atrTP)
alert("SELL",alert.freq_once_per_bar)
//----------------
//plotshape(comprado,style=shape.xcross)
plot( comprado ? SL : na, color=color.red,style=plot.style_circles)
plot( comprado ? TP : na, color=color.blue,style=plot.style_circles)
plot( ta.ema(close,ema1),color=color.orange)
plot( ta.ema(close,ema2),color=color.yellow)
plot( vendido ? SL : na, color=color.red,style=plot.style_circles)
plot( vendido ? TP : na, color=color.blue,style=plot.style_circles)
Expand (108 lines)
Overview
Relative Vigor Index enters long positions when the RVI line crosses above its signal line during an established EMA uptrend. Conversely, it opens short positions on a bearish RVI crossover during an EMA downtrend. Exits trigger when price breaches dynamic stop loss or take profit levels calculated using Average True Range multipliers. Configurable inputs include EMA lengths, RVI periods, and ATR target ratios.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Length rvi
int
4
len
Offset rvi
int
0
offset
Atr Length
int
19
atrlength
Long EMA rapida
int
95
ema1
Long EMA lenta
int
200
ema2
Atr SL
float
2.0
atrSL
Atr TP
float
1.0
atrTP
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.
This strategy overlays a trend moving average and Supertrend bands directly on the price chart while calculating Stochastic RSI values internally. Long positions trigger when price exceeds the moving average, Supertrend signals bullish momentum, and the StochR
This strategy combines exponential moving averages (EMA 9, 21, 50), RSI, MACD, and Supertrend indicators to enter long positions. It triggers trades using six dynamic setups based on momentum breakouts, EMA crossovers, and pullbacks. Position sizing is compute
CombinedBinHAndClucV6 is a trading strategy based on the popular BinHV45 and ClucMay72018 algorithms. It calculates dual Bollinger Bands, Exponential Moving Averages, Relative Strength Index, Average True Range, and volume metrics across primary and one-hour h
This strategy calculates Bollinger Bands, a configurable moving average slope, Stochastic RSI, ATR, and ADX directly on the price chart. It evaluates trend bias and momentum conditions to generate long and short swing entries using percent-of-equity sizing. Th
This strategy trades long and short on the price chart using a multi-timeframe TradingLatino setup. It requires EMA 10 to cross or sit above or below EMA 55 on the one-hour, four-hour, and daily charts, together with a positive ADX slope, a directional monitor
This strategy evaluates market trend and momentum to generate long and short trading signals on price charts. It plots 100-period and 500-period moving averages (EMA or SMA) to establish macro trend direction. Long entries require trend alignment alongside opt