Relative Strength Index with Range Shift

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #204166 quote
    yasyas
    Participant
    Junior
    Can this code be converted into Pro Real Time please if possible this indicator was in tradingview
    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © kevindcarr
    //@version=5
    indicator(title=’Relative Strength Index with Range Shift’, shorttitle=’RSI’, overlay=false, precision=1)
    var table conditionTable = table.new(position=position.top_right, columns=1, rows=1)
    log = input.string(title=’Scale’, options=[‘Logarithmic’, ‘Regular’], defval=’Logarithmic’)
    range_1 = input.string(title=’Range Bias’, options=[‘Bullish’, ‘Strong Bullish’, ‘Bearish’, ‘Strong Bearish’, ‘No Bias’], defval=’Bullish’)
    lookbackPeriod = input(title=’Lookback Period’, defval=14)
    source = input(title=’Source’, defval=close)
    rangeShift(range_2) =>
        if range_2 == ‘Bullish’
            [40, 60, 80]
        else if range_2 == ‘Strong Bullish’
            [45, 65, 85]
        else if range_2 == ‘Bearish’
            [35, 55, 75]
        else if range_2 == ‘Strong Bearish’
            [30, 50, 70]
        else
            [40, 60, 80]
    condition(rsi, range_3) =>
        [lo, mid, hi] = rangeShift(range_3)
        if rsi <= lo
            [color.green, ‘Very Oversold’]
        else if rsi <= mid
            [color.yellow, ‘Oversold’]
        else if rsi <= hi
            [color.orange, ‘Overbought’]
        else
            [color.red, ‘Very Overbought’]
    rsiSource = (log == ‘Logarithmic’ ? math.log(source) : source)
    rsi = ta.rsi(rsiSource, lookbackPeriod)
    [col, txt] = condition(rsi, range_1)
    table.cell(conditionTable, 0, 0, text=txt, bgcolor=col)
    plot(series=rsi, title=’Relative Strength Index’, color=col)
    #204191 quote
    yasyas
    Participant
    Junior

    hi guys

    can the above code can be converted into pro real time please if possible

    many thanks

    #204196 quote
    NicolasNicolas
    Keymaster
    Legend

    ok, but you know that’s a classic RSI with 3 different colors shades, right?

    #204197 quote
    yasyas
    Participant
    Junior

    yes thats correct

    #204214 quote
    NicolasNicolas
    Keymaster
    Legend

    Well ok, here it is. Change the “range bias” with a number in the settings at top of the code:

    lookbackPeriod=14
    rangeBias = 0 //0=bullish, 1=strong bullish, 2=bearish, 3=strong bearish
    
    if rangebias=0 then 
    lo=40
    mid=60
    hi=80
    elsif rangebias=1 then
    lo=54
    mid=65
    hi=85
    elsif rangebias=2 then
    lo=35
    mid=55
    hi=75
    elsif rangebias=3 then
    lo=30
    mid=50
    hi=70
    else
    lo=40
    mid=60
    hi=80
    endif 
    
    source=customclose
    
    irsi=rsi[lookbackperiod](source)
    if irsi <= lo then 
    r=0
    g=255
    elsif irsi <= mid then
    r=255
    g=255
    elsif irsi <= hi then 
    r=255
    g=165
    else
    r=255
    g=0
    endif 
    return irsi coloured(r,g,0)
    rsi-range-bias-shift.png rsi-range-bias-shift.png
    #204216 quote
    yasyas
    Participant
    Junior

    Thank you very much appreciated your help thanks again

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Relative Strength Index with Range Shift


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
yas @yas Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by yasyas
3 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/14/2022
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...