Conversion RSI basé MA

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #244183 quote
    Bateson
    Participant
    New

    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)
    
    #244241 quote
    JS
    Participant
    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
    Iván González thanked this post
    #244246 quote
    Bateson
    Participant
    New

    Bonsoir JS
    Merci beaucoup pour la contribution qui va m’être très utile !
    Bonne fin de soirée

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Conversion RSI basé MA


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bateson @bateson Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Bateson
11 months, 2 weeks ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/21/2025
Status: Active
Attachments: No files
Logo Logo
Loading...