Repaints RSI MTF Panel [xdecow] For ThinkOrSwim

Repaints

Kermit

New member
VIP
Hello all,
I just joined yesterday and so very new to this group. I am trying to understand relationship between RSI values over different time frames..Example when a stock is just getting distributed (sold), RSI on 1 min time frame will read a higher value compared to RSI on 2 hour time frame at that moment. Currently I keep changing the time frame input manually on my ToS chart to read the RSI value for different time frames of interest... My Google search led me to an "RSI MTF Panel" in Trading view at https://www.tradingview.com/script/R5Gr8rUL-RSI-MTF-Panel-xdecow/, really close to what I was thinking, but not sure if something equivalent exists for ToS.. Is there a script available that could extract RSI values over multiple time frames programmatically without me having to manually flip?. Greatly appreciate if any one can educate or throw some ideas on how to go about getting this accomplished.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hello all,
I just joined yesterday and so very new to this group. I am trying to understand relationship between RSI values over different time frames..Example when a stock is just getting distributed (sold), RSI on 1 min time frame will read a higher value compared to RSI on 2 hour time frame at that moment. Currently I keep changing the time frame input manually on my ToS chart to read the RSI value for different time frames of interest... My Google search led me to an "RSI MTF Panel" in Trading view at https://www.tradingview.com/script/R5Gr8rUL-RSI-MTF-Panel-xdecow/, really close to what I was thinking, but not sure if something equivalent exists for ToS.. Is there a script available that could extract RSI values over multiple time frames programmatically without me having to manually flip?. Greatly appreciate if any one can educate or throw some ideas on how to go about getting this accomplished.
check the below.

CSS:
# https://www.tradingview.com/v/R5Gr8rUL/
#// © xdecow
#indicator("RSI MTF Panel [xdecow]", overlay=true)
# Converted and mod by Sam4Cok@Samer800    - 11/2023

input showRatioLabel = yes;
input threshold_ob = 70;            # 'Overbought Threshold'
input threshold_uptrend = 60;       # 'Uptrend Threshold'
input threshold_downtrend = 40;     # 'Downtrend Threshold'
input threshold_os = 30;            # 'Oversold Threshold'
input rsi1_enabled = yes;
input rsi1_tf = AggregationPeriod.FIVE_MIN;
input rsi1_len = 14;
input rsi1_src = FundamentalType.CLOSE;
input rsi2_enabled = yes;
input rsi2_tf =  AggregationPeriod.FIFTEEN_MIN;
input rsi2_len = 14;
input rsi2_src = FundamentalType.CLOSE;
input rsi3_enabled = yes;
input rsi3_tf =  AggregationPeriod.HOUR;
input rsi3_len = 14;
input rsi3_src = FundamentalType.CLOSE;
input rsi4_enabled = yes;
input rsi4_tf =  AggregationPeriod.FOUR_HOURS;
input rsi4_len = 14;
input rsi4_src = FundamentalType.CLOSE;
input rsi5_enabled = yes;
input rsi5_tf =  AggregationPeriod.DAY;
input rsi5_len = 14;
input rsi5_src = FundamentalType.CLOSE;
input rsi6_enabled = yes;
input rsi6_tf =  AggregationPeriod.WEEK;
input rsi6_len = 14;
input rsi6_src = FundamentalType.CLOSE;
input rsi7_enabled = no;
input rsi7_tf =  AggregationPeriod.WEEK;
input rsi7_len = 14;
input rsi7_src = FundamentalType.CLOSE;
input rsi8_enabled = no;
input rsi8_tf =  AggregationPeriod.FIVE_MIN;
input rsi8_len = 14;
input rsi8_src = FundamentalType.CLOSE;
input rsi9_enabled = no;
input rsi9_tf =  AggregationPeriod.WEEK;
input rsi9_len = 14;
input rsi9_src = FundamentalType.CLOSE;
input rsi10_enabled = no;
input rsi10_tf =  AggregationPeriod.WEEK;
input rsi10_len = 14;
input rsi10_src = FundamentalType.CLOSE;


def na = Double.NaN;
def chartAgg = GetAggregationPeriod();
def rsi1tf = if  chartAgg > rsi1_tf then chartAgg else rsi1_tf;
def rsi2tf = if  chartAgg > rsi2_tf then chartAgg else rsi2_tf;
def rsi3tf = if  chartAgg > rsi3_tf then chartAgg else rsi3_tf;
def rsi4tf = if  chartAgg > rsi4_tf then chartAgg else rsi4_tf;
def rsi5tf = if  chartAgg > rsi5_tf then chartAgg else rsi5_tf;
def rsi6tf = if  chartAgg > rsi6_tf then chartAgg else rsi6_tf;
def rsi7tf = if  chartAgg > rsi7_tf then chartAgg else rsi7_tf;
def rsi8tf = if  chartAgg > rsi8_tf then chartAgg else rsi8_tf;
def rsi9tf = if  chartAgg > rsi9_tf then chartAgg else rsi9_tf;
def rsi10tf = if  chartAgg > rsi10_tf then chartAgg else rsi10_tf;
def src1 = if chartAgg > rsi1_tf then na else Fundamental(fundamentalType = rsi1_src, period = rsi1tf);
def src2 = if chartAgg > rsi2_tf then na else Fundamental(fundamentalType = rsi2_src, period = rsi2tf);
def src3 = if chartAgg > rsi3_tf then na else Fundamental(fundamentalType = rsi3_src, period = rsi3tf);
def src4 = if chartAgg > rsi4_tf then na else Fundamental(fundamentalType = rsi4_src, period = rsi4tf);
def src5 = if chartAgg > rsi5_tf then na else Fundamental(fundamentalType = rsi5_src, period = rsi5tf);
def src6 = if chartAgg > rsi6_tf then na else Fundamental(fundamentalType = rsi6_src, period = rsi6tf);
def src7 = if chartAgg > rsi7_tf then na else Fundamental(fundamentalType = rsi7_src, period = rsi7tf);
def src8 = if chartAgg > rsi8_tf then na else Fundamental(fundamentalType = rsi8_src, period = rsi8tf);
def src9 = if chartAgg > rsi9_tf then na else Fundamental(fundamentalType = rsi9_src, period = rsi9tf);
def src10 = if chartAgg > rsi10_tf then na else Fundamental(fundamentalType = rsi10_src, period = rsi10tf);
def rsi1 = RSI(Price = src1 * 10000, Length = rsi1_len);
def rsi2 = RSI(Price = src2 * 10000, Length = rsi2_len);
def rsi3 = RSI(Price = src3 * 10000, Length = rsi3_len);
def rsi4 = RSI(Price = src4 * 10000, Length = rsi4_len);
def rsi5 = RSI(Price = src5 * 10000, Length = rsi5_len);
def rsi6 = RSI(Price = src6 * 10000, Length = rsi6_len);
def rsi7 = RSI(Price = src7 * 10000, Length = rsi7_len);
def rsi8 = RSI(Price = src8 * 10000, Length = rsi8_len);
def rsi9 = RSI(Price = src9 * 10000, Length = rsi9_len);
def rsi10 = RSI(Price = src10 * 10000, Length = rsi10_len);

script f_timeframeToHuman {
    input tf = AggregationPeriod.DAY;
    def day = AggregationPeriod.DAY;
    def month = AggregationPeriod.MONTH;
    def week = AggregationPeriod.WEEK;
    def four = AggregationPeriod.FOUR_DAYS;
    def chartAgg = GetAggregationPeriod();
    def _tf = if chartAgg > tf then chartAgg else tf;
    def seconds = _tf / 1000;
    def val;
    def lab;
    if seconds < 3600 {
        val = (seconds / 60);
        lab = 1; # "m"
    } else if seconds < 86400 {
        val = (seconds / 60 / 60);
        lab = 2; # "H"
    } else {
    if _tf > week {
        lab = 5; # "M"
        val =  _tf / Month;
    } else if _tf > four {
        lab = 4; # "W"
        val = 1;
    } else {
        lab = 3; # "D"
        val = _tf / Day;
    }}
    plot value = val;
    plot unit = lab;
}
Script f_bg {
input _rsi = close;
input threshold_ob = 70;
input threshold_uptrend = 60;
input threshold_os = 30;
input threshold_downtrend = 40;
    def c_line = if isNaN(_rsi) then 0 else
                 if _rsi >= threshold_ob then 2 else
                 if _rsi >= threshold_uptrend then 1 else
                 if _rsi <= threshold_os then -2 else
                 if _rsi <= threshold_downtrend then -1 else 0;
    plot col = c_line;
    plot rsi = Round(_rsi, 2);
}

def c_rsi1 = f_bg(rsi1, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi1 = f_bg(rsi1).rsi;
def v_rsi1 = f_timeframeToHuman(rsi1_tf).val;
def u_rsi1 = f_timeframeToHuman(rsi1_tf).unit;

def c_rsi2 = f_bg(rsi2, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi2 = f_bg(rsi2).rsi;
def v_rsi2 = f_timeframeToHuman(rsi2_tf).val;
def u_rsi2 = f_timeframeToHuman(rsi2_tf).unit;

def c_rsi3 = f_bg(rsi3, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi3 = f_bg(rsi3).rsi;
def v_rsi3 = f_timeframeToHuman(rsi3_tf).val;
def u_rsi3 = f_timeframeToHuman(rsi3_tf).unit;

def c_rsi4 = f_bg(rsi4, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi4 = f_bg(rsi4).rsi;
def v_rsi4 = f_timeframeToHuman(rsi4_tf).val;
def u_rsi4 = f_timeframeToHuman(rsi4_tf).unit;

def c_rsi5 = f_bg(rsi5, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi5 = f_bg(rsi5).rsi;
def v_rsi5 = f_timeframeToHuman(rsi5_tf).val;
def u_rsi5 = f_timeframeToHuman(rsi5_tf).unit;

def c_rsi6 = f_bg(rsi6, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi6 = f_bg(rsi6).rsi;
def v_rsi6 = f_timeframeToHuman(rsi6_tf).val;
def u_rsi6 = f_timeframeToHuman(rsi6_tf).unit;

def c_rsi7 = f_bg(rsi7, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi7 = f_bg(rsi7).rsi;
def v_rsi7 = f_timeframeToHuman(rsi7_tf).val;
def u_rsi7 = f_timeframeToHuman(rsi7_tf).unit;

def c_rsi8 = f_bg(rsi8, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi8 = f_bg(rsi8).rsi;
def v_rsi8 = f_timeframeToHuman(rsi8_tf).val;
def u_rsi8 = f_timeframeToHuman(rsi8_tf).unit;

def c_rsi9 = f_bg(rsi9, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi9 = f_bg(rsi9).rsi;
def v_rsi9 = f_timeframeToHuman(rsi9_tf).val;
def u_rsi9 = f_timeframeToHuman(rsi9_tf).unit;

def c_rsi10 = f_bg(rsi10, threshold_ob, threshold_uptrend, threshold_os, threshold_downtrend).col;
def r_rsi10 = f_bg(rsi10).rsi;
def v_rsi10 = f_timeframeToHuman(rsi10_tf).val;
def u_rsi10 = f_timeframeToHuman(rsi10_tf).unit;

def  val1 = rsi1_enabled and !isNaN(src1);
def  val2 = rsi2_enabled and !isNaN(src2);
def  val3 = rsi3_enabled and !isNaN(src3);
def  val4 = rsi4_enabled and !isNaN(src4);
def  val5 = rsi5_enabled and !isNaN(src5);
def  val6 = rsi6_enabled and !isNaN(src6);
def  val7 = rsi7_enabled and !isNaN(src7);
def  val8 = rsi8_enabled and !isNaN(src8);
def  val9 = rsi9_enabled and !isNaN(src9);
def  val10 = rsi10_enabled and !isNaN(src10);

def strength1 = if val1 then c_rsi1 else 0;
def strength2 = if val2 then c_rsi2 else 0;
def strength3 = if val3 then c_rsi3 else 0;
def strength4 = if val4 then c_rsi4 else 0;
def strength5 = if val5 then c_rsi5 else 0;
def strength6 = if val6 then c_rsi6 else 0;
def strength7 = if val7 then c_rsi7 else 0;
def strength8 = if val8 then c_rsi8 else 0;
def strength9 = if val9 then c_rsi9 else 0;
def strength10 = if val10 then c_rsi10 else 0;

def sumVal = val1 + val2 + val3 + val4 + val5 +
             val6 + val7 + val8 + val9 + val10;
def sumStr = strength1 + strength2 + strength3 + strength4 + strength5 +
             strength6 + strength7 + strength8 + strength9 + strength10;
def ratio = sumStr/sumVal;

AddLabel(showRatioLabel,"Strength(" + ratio + ")", if ratio >= 1 then Color.GREEN else
                       if ratio > 0 then Color.DARK_GREEN else
                       if ratio ==0 then Color.GRAY else
                       if ratio > -1 then Color.DARK_RED else Color.RED);

AddLabel(rsi1_enabled and src1, "TF("+v_rsi1+
         (if u_rsi1==1 then "m" else
          if u_rsi1==2 then "H" else
          if u_rsi1==3 then "D" else
          if u_rsi1==4 then "W" else "M") + ")" + "RSI(" + r_rsi1 + ")" ,
          if c_rsi1==2 then Color.GREEN else
          if c_rsi1==1 then Color.DARK_GREEN else
          if c_rsi1==-2 then Color.RED else
          if c_rsi1==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi2_enabled and src2, "TF("+v_rsi2+
         (if u_rsi2==1 then "m" else
          if u_rsi2==2 then "H" else
          if u_rsi2==3 then "D" else
          if u_rsi2==4 then "W" else "M") + ")" + "RSI(" + r_rsi2 + ")" ,
          if c_rsi2==2 then Color.GREEN else
          if c_rsi2==1 then Color.DARK_GREEN else
          if c_rsi2==-2 then Color.RED else
          if c_rsi2==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi3_enabled and src3, "TF("+v_rsi3+
         (if u_rsi3==1 then "m" else
          if u_rsi3==2 then "H" else
          if u_rsi3==3 then "D" else
          if u_rsi3==4 then "W" else "M") + ")" + "RSI(" + r_rsi3 + ")" ,
          if c_rsi3==2 then Color.GREEN else
          if c_rsi3==1 then Color.DARK_GREEN else
          if c_rsi3==-2 then Color.RED else
          if c_rsi3==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi4_enabled and src4, "TF("+v_rsi4+
         (if u_rsi4==1 then "m" else
          if u_rsi4==2 then "H" else
          if u_rsi4==3 then "D" else
          if u_rsi4==4 then "W" else "M") + ")" + "RSI(" + r_rsi4 + ")" ,
          if c_rsi4==2 then Color.GREEN else
          if c_rsi4==1 then Color.DARK_GREEN else
          if c_rsi4==-2 then Color.RED else
          if c_rsi4==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi5_enabled and src5, "TF("+v_rsi5+
         (if u_rsi5==1 then "m" else
          if u_rsi5==2 then "H" else
          if u_rsi5==3 then "D" else
          if u_rsi5==4 then "W" else "M") + ")" + "RSI(" + r_rsi5 + ")" ,
          if c_rsi5==2 then Color.GREEN else
          if c_rsi5==1 then Color.DARK_GREEN else
          if c_rsi5==-2 then Color.RED else
          if c_rsi5==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi6_enabled and src6, "TF("+v_rsi6+
         (if u_rsi6==1 then "m" else
          if u_rsi6==2 then "H" else
          if u_rsi6==3 then "D" else
          if u_rsi6==4 then "W" else "M") + ")" + "RSI(" + r_rsi6 + ")" ,
          if c_rsi6==2 then Color.GREEN else
          if c_rsi6==1 then Color.DARK_GREEN else
          if c_rsi6==-2 then Color.RED else
          if c_rsi6==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi7_enabled and src7, "TF("+v_rsi7+
         (if u_rsi7==1 then "m" else
          if u_rsi7==2 then "H" else
          if u_rsi7==3 then "D" else
          if u_rsi7==4 then "W" else "M") + ")" + "RSI(" + r_rsi7 + ")" ,
          if c_rsi7==2 then Color.GREEN else
          if c_rsi7==1 then Color.DARK_GREEN else
          if c_rsi7==-2 then Color.RED else
          if c_rsi7==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi8_enabled and src8, "TF("+v_rsi8+
         (if u_rsi8==1 then "m" else
          if u_rsi8==2 then "H" else
          if u_rsi8==3 then "D" else
          if u_rsi8==4 then "W" else "M") + ")" + "RSI(" + r_rsi8 + ")" ,
          if c_rsi8==2 then Color.GREEN else
          if c_rsi8==1 then Color.DARK_GREEN else
          if c_rsi8==-2 then Color.RED else
          if c_rsi8==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi9_enabled and src9, "TF("+v_rsi9+
         (if u_rsi9==1 then "m" else
          if u_rsi9==2 then "H" else
          if u_rsi9==3 then "D" else
          if u_rsi9==4 then "W" else "M") + ")" + "RSI(" + r_rsi9 + ")" ,
          if c_rsi9==2 then Color.GREEN else
          if c_rsi9==1 then Color.DARK_GREEN else
          if c_rsi9==-2 then Color.RED else
          if c_rsi9==-1 then Color.DARK_RED else Color.GRAY);

AddLabel(rsi10_enabled and src10, "TF("+v_rsi10+
         (if u_rsi10==1 then "m" else
          if u_rsi10==2 then "H" else
          if u_rsi10==3 then "D" else
          if u_rsi10==4 then "W" else "M") + ")" + "RSI(" + r_rsi10 + ")" ,
          if c_rsi10==2 then Color.GREEN else
          if c_rsi10==1 then Color.DARK_GREEN else
          if c_rsi10==-2 then Color.RED else
          if c_rsi10==-1 then Color.DARK_RED else Color.GRAY);

#-- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
334 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top