Bonjour
je souhaitera savoir s’il est possible de convertir le code ci-dessous, importer de Tradung View. Il s’agit d’appliquer une moyenne mobile au RSI.
je souhaiterai pouvoir dans les vraiables choisir le type de moyenne mobile et la longeur.
Merci d’avance !
//@version=5
indicator("Multi-timeframe RSI-based MA", overlay=false)
// Inputs for RSI period and length for moving averages
rsiPeriod = input.int(14, title="RSI Period")
maLength1 = input.int(10, title="MA Length for 1-minute RSI-based MA")
maLength5 = input.int(10, title="MA Length for 5-minute RSI-based MA")
// Calculate RSI for current timeframe
rsi = ta.rsi(close, rsiPeriod)
// Calculate moving averages based on RSI for 1-minute and 5-minute timeframes
rsi_ma_1m = ta.sma(request.security(syminfo.tickerid, "1", rsi), maLength1)
rsi_ma_5m = ta.sma(request.security(syminfo.tickerid, "5", rsi), maLength5)
// Plot the RSI-based moving averages
plot(rsi_ma_1m, color=color.blue, title="RSI-based MA (1m)", linewidth=2)
plot(rsi_ma_5m, color=color.red, title="RSI-based MA (5m)", linewidth=2)
// Add RSI line for reference (optional)
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.purple, linewidth=1)
JSParticipant
Senior
This is the basic conversion:
//------------
// Parameters
//------------
rsiPeriod = 14
maLength1 = 10
maLength5 = 10
//------------
// RSI on current timeframe
//------------
rsiValue = RSI[rsiPeriod](Close)
//------------
// RSI on 1-minute and 5-minute timeframes
//------------
TIMEFRAME(1 Minute)
rsi1m = RSI[rsiPeriod](Close)
maRsi1m = Average[maLength1](rsi1m)
TIMEFRAME(5 Minutes)
rsi5m = RSI[rsiPeriod](Close)
maRsi5m = Average[maLength5](rsi5m)
//------------
// Display
//------------
RETURN maRsi1m AS "RSI MA (1m)", maRsi5m AS "RSI MA (5m)", rsiValue AS "RSI",70,30
Bonsoir JS
Merci beaucoup pour la contribution qui va m’être très utile !
Bonne fin de soirée