Repaints Multiple Time Frame (MTF) RSI Indicator for ThinkorSwim

Repaints
This will display labels showing the RSI value for various timeframes. If over_bought then the color will be red, oversold will be green, and white otherwise.
SleepyZ - for some reason the labels will show on the 5min but not on 10 or 30 min charts. Is there something I have to adjust for that to occur? Thanks and have a good trading day in this whacky market!
 
SleepyZ - for some reason the labels will show on the 5min but not on 10 or 30 min charts. Is there something I have to adjust for that to occur? Thanks and have a good trading day in this whacky market!

TOS will not allow secondary periods less than the chart's aggregation period to be displayed. As written, when you went on a chart with a higher aggregation than the lowest aggregation in above code of 5 min, then this created an error and the whole script would not plot.

The following modification will eliminate that error and just plot blank labels in the above scenario. The labels equal to or greater than the chart's aggregation will show otherwise.

The image shows a Daily chart with the Daily and Weekly labels showing in white and the rest showing blank in black
Screenshot-2023-03-01-065153.png
Code:
#RSI_MTF_Labels

declare upper;
script R {
    input agg = AggregationPeriod.DAY;
    input length = 14;
    input over_Bought = 70;
    input over_Sold = 30;

    def price = close(period = agg);

    input averageType = AverageType.WILDERS;
    input showBreakoutSignals = no;

    def NetChgAvg = MovingAverage(averageType, price - price[1], length);
    def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
    def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

    plot RSI = 50 * (ChgRatio + 1);

}
input over_sold   = 30;
input over_bought = 70;

def RW;
if GetAggregationPeriod() > AggregationPeriod.WEEK {
    RW = Double.NaN;
} else {
    RW = R(agg = "WEEK");
}

def RD;
if GetAggregationPeriod() > AggregationPeriod.DAY {
    RD = Double.NaN;
} else {
    RD = R(agg = "DAY");
}

def R4;
if GetAggregationPeriod() > AggregationPeriod.FOUR_HOURS {
    R4 = Double.NaN;
} else {
    R4 = R(agg = "FOUR_HOURS");
}

def RH;
if GetAggregationPeriod() > AggregationPeriod.HOUR {
    RH = Double.NaN;
} else {
    RH = R(agg = "HOUR");
}

def R30;
if GetAggregationPeriod() > AggregationPeriod.THIRTY_MIN {
    R30 = Double.NaN;
} else {
    R30 = R(agg = "THIRTY_MIN");
}

def R15;
if GetAggregationPeriod() > AggregationPeriod.FIFTEEN_MIN {
    R15 = Double.NaN;
} else {
    R15 = R(agg = "FIFTEEN_MIN");
}

def R5;
if GetAggregationPeriod() > AggregationPeriod.FIVE_MIN {
    R5 = Double.NaN;
} else {
    R5 = R(agg = "FIVE_MIN");
}

AddLabel(yes, "W: " + Round(RW), if RW >= over_bought then Color.RED else if RW <= over_sold then Color.GREEN else Color.WHITE);
AddLabel(yes, "D: " + Round(RD), if RD >= over_bought then Color.RED else if RD <= over_sold then Color.GREEN else Color.WHITE);
AddLabel(yes, "4H: " + Round(R4), if R4 >= over_bought then Color.RED else if R4 <= over_sold then Color.GREEN else Color.WHITE);
AddLabel(yes, "H: " + Round(RH), if RH >= over_bought then Color.RED else if RH <= over_sold then Color.GREEN else Color.WHITE);
AddLabel(yes, "30m: " + Round(R30), if R30 >= over_bought then Color.RED else if R30 <= over_sold then Color.GREEN else Color.WHITE);
AddLabel(yes, "15m: " + Round(R15), if R15 >= over_bought then Color.RED else if R15 <= over_sold then Color.GREEN else Color.WHITE);
AddLabel(yes, "5m: " + Round(R5), if R5 >= over_bought then Color.RED else if R5 <= over_sold then Color.GREEN else Color.WHITE);
 
Last edited:
TOS will not allow secondary periods less than the chart's aggregation period to be displayed. As written, when you went on a chart with a higher aggregation than the lowest aggregation in above code of 5 min, then this created an error and the whole script would not plot.

The following modification will eliminate that error and just plot blank labels in the above scenario. The labels equal to or greater than the chart's aggregation will show otherwise.

The image shows a Daily chart with the Daily and Weekly labels showing in white and the rest showing blank in black
Sorry for the delayed reply. Tough week for me. Thanks a ton for helping out with this. Has helped alert me to the chart for a good time to sell calls a few times already. Truly appreciated.
 
This will display labels showing the RSI value for various timeframes. If over_bought then the color will be red, oversold will be green, and white otherwise.
@SleepyZ
Is it possible you could add the individual RSI label to appear next to the individual product so that I could see product label and have the RSI label right next to it? ie... [/NQ:XCME] [H: 55.98] I have included the Pairs Continuity Label I pulled and modified the other day. I'd love to see it for all four products. Thank you

# Compare Symbols
# Mobius

input symb_1 = "/NQ";
input symb_2 = "/ES";
input symb_3 = "/YM";
input symb_4 = "VXX";

script Scale {
input c = close;
def Min = LowestAll(close);
def Max = HighestAll(close);
def hh = HighestAll(c);
def ll = LowestAll(c);
plot Range = (((Max - Min) * (c - ll)) / (hh - ll)) + Min;
}
plot symb1 = Scale(close(symb_1));
plot symb2 = Scale(close(symb_2));
plot symb3 = Scale(close(symb_3));
plot symb4 = Scale(close(symb_4));
addLabel(1, symb_1, symb1.TakeValueColor());
addLabel(1, symb_2, symb2.TakeValueColor());
addLabel(1, symb_3, symb3.TakeValueColor());
addLabel(1, symb_4, symb4.TakeValueColor());
#------NQ-----#
symb1.SetDefaultColor(GetColor(1));
symb1.SetDefaultColor(Color.UPTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb1.SetDefaultColor(Color.DOWNTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb1.DefineColor( "up", Color.UPTICK );
symb1.DefineColor( "dn", Color.DOWNTICK );
symb1.DefineColor( "def", Color.plum);

symb1.AssignValueColor(
if symb1 > symb1[1] then symb1.Color( "up" )
else if symb1 < symb1[1] then symb1.Color( "dn" )
else symb1.Color( "def" ) );
#------ES-----#
symb2.SetDefaultColor(GetColor(1));
symb2.SetDefaultColor(Color.UPTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb2.SetDefaultColor(Color.DOWNTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb2.DefineColor( "up", Color.UPTICK );
symb2.DefineColor( "dn", Color.DOWNTICK );
symb2.DefineColor( "def", Color.plum);

symb2.AssignValueColor(
if symb2 > symb2[1] then symb2.Color( "up" )
else if symb2 < symb2[1] then symb2.Color( "dn" )
else symb2.Color( "def" ) );
#------YM-----#
symb3.SetDefaultColor(GetColor(1));
symb3.SetDefaultColor(Color.UPTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb3.SetDefaultColor(Color.DOWNTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb3.DefineColor( "up", Color.UPTICK );
symb3.DefineColor( "dn", Color.DOWNTICK );
symb3.DefineColor( "def", Color.plum);

symb3.AssignValueColor(
if symb3 > symb3[1] then symb3.Color( "up" )
else if symb3 < symb3[1] then symb3.Color( "dn" )
else symb3.Color( "def" ) );
#------VXX-----#
symb4.SetDefaultColor(GetColor(1));
symb4.SetDefaultColor(Color.UPTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb4.SetDefaultColor(Color.DOWNTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb4.DefineColor( "up", Color.UPTICK );
symb4.DefineColor( "dn", Color.DOWNTICK );
symb4.DefineColor( "def", Color.plum);

symb4.AssignValueColor(
if symb4 > symb4[1] then symb4.Color( "up" )
else if symb4 < symb4[1] then symb4.Color( "dn" )
else symb4.Color( "def" ) );

#AssignBackgroundColor(if symb1 > symb1[1] then if symb2 > symb2[1] then symb3 > symb3[1] color.green else if
#symb1 < symb1[1] then if symb2 < symb2[1] then symb3 < symb3[1] color.red else Color( "current" ));
#----End Code-----#
#prsiMA.AssignValueColor(if prsiMA >= 50 then if prsiMA > prsiMA[1] then prsiMA.Color("Positive and Up") else #prsiMA.Color("Positive and Down") else if RSI < prsiMA[1] then prsiMA.Color("Negative and Down") else prsiMA.Color("Negative and Up"));
 
@SleepyZ
Is it possible you could add the individual RSI label to appear next to the individual product so that I could see product label and have the RSI label right next to it? ie... [/NQ:XCME] [H: 55.98] I have included the Pairs Continuity Label I pulled and modified the other day. I'd love to see it for all four products. Thank you

# Compare Symbols
# Mobius

input symb_1 = "/NQ";
input symb_2 = "/ES";
input symb_3 = "/YM";
input symb_4 = "VXX";

script Scale {
input c = close;
def Min = LowestAll(close);
def Max = HighestAll(close);
def hh = HighestAll(c);
def ll = LowestAll(c);
plot Range = (((Max - Min) * (c - ll)) / (hh - ll)) + Min;
}
plot symb1 = Scale(close(symb_1));
plot symb2 = Scale(close(symb_2));
plot symb3 = Scale(close(symb_3));
plot symb4 = Scale(close(symb_4));
addLabel(1, symb_1, symb1.TakeValueColor());
addLabel(1, symb_2, symb2.TakeValueColor());
addLabel(1, symb_3, symb3.TakeValueColor());
addLabel(1, symb_4, symb4.TakeValueColor());
#------NQ-----#
symb1.SetDefaultColor(GetColor(1));
symb1.SetDefaultColor(Color.UPTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb1.SetDefaultColor(Color.DOWNTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb1.DefineColor( "up", Color.UPTICK );
symb1.DefineColor( "dn", Color.DOWNTICK );
symb1.DefineColor( "def", Color.plum);

symb1.AssignValueColor(
if symb1 > symb1[1] then symb1.Color( "up" )
else if symb1 < symb1[1] then symb1.Color( "dn" )
else symb1.Color( "def" ) );
#------ES-----#
symb2.SetDefaultColor(GetColor(1));
symb2.SetDefaultColor(Color.UPTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb2.SetDefaultColor(Color.DOWNTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb2.DefineColor( "up", Color.UPTICK );
symb2.DefineColor( "dn", Color.DOWNTICK );
symb2.DefineColor( "def", Color.plum);

symb2.AssignValueColor(
if symb2 > symb2[1] then symb2.Color( "up" )
else if symb2 < symb2[1] then symb2.Color( "dn" )
else symb2.Color( "def" ) );
#------YM-----#
symb3.SetDefaultColor(GetColor(1));
symb3.SetDefaultColor(Color.UPTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb3.SetDefaultColor(Color.DOWNTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb3.DefineColor( "up", Color.UPTICK );
symb3.DefineColor( "dn", Color.DOWNTICK );
symb3.DefineColor( "def", Color.plum);

symb3.AssignValueColor(
if symb3 > symb3[1] then symb3.Color( "up" )
else if symb3 < symb3[1] then symb3.Color( "dn" )
else symb3.Color( "def" ) );
#------VXX-----#
symb4.SetDefaultColor(GetColor(1));
symb4.SetDefaultColor(Color.UPTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb4.SetDefaultColor(Color.DOWNTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb4.DefineColor( "up", Color.UPTICK );
symb4.DefineColor( "dn", Color.DOWNTICK );
symb4.DefineColor( "def", Color.plum);

symb4.AssignValueColor(
if symb4 > symb4[1] then symb4.Color( "up" )
else if symb4 < symb4[1] then symb4.Color( "dn" )
else symb4.Color( "def" ) );

#AssignBackgroundColor(if symb1 > symb1[1] then if symb2 > symb2[1] then symb3 > symb3[1] color.green else if
#symb1 < symb1[1] then if symb2 < symb2[1] then symb3 < symb3[1] color.red else Color( "current" ));
#----End Code-----#
#prsiMA.AssignValueColor(if prsiMA >= 50 then if prsiMA > prsiMA[1] then prsiMA.Color("Positive and Up") else #prsiMA.Color("Positive and Down") else if RSI < prsiMA[1] then prsiMA.Color("Negative and Down") else prsiMA.Color("Negative and Up"));

Here is MTF selected RSI label, colored white for each of the 4 symbols in your script.

The image is a AAPL 15min chart with Weekly agg RSI selected for the 4 symbols.
Screenshot-2023-03-14-132800.png
Ruby:
# Compare Symbols
# Mobius
# Sleepyz added MTF selected RSI label

input agg = aggregationPeriod.Hour;
input over_sold   = 70;
input over_bought = 30;
input symb_1 = "/NQ";
input symb_2 = "/ES";
input symb_3 = "/YM";
input symb_4 = "VXX";

script Scale {
    input c = close;
    def Min = LowestAll(close);
    def Max = HighestAll(close);
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) / (hh - ll)) + Min;
}
script R {
    input sym = "/NQ";
    input agg = AggregationPeriod.DAY;
    input length = 14;
    input over_Bought = 70;
    input over_Sold = 30;

    def price = close(symbol = sym, period = agg);

    input averageType = AverageType.WILDERS;
    input showBreakoutSignals = no;

    def NetChgAvg = MovingAverage(averageType, price - price[1], length);
    def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
    def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

    plot RSI = 50 * (ChgRatio + 1);

}
plot symb1 = Scale(close(symb_1));
plot symb2 = Scale(close(symb_2));
plot symb3 = Scale(close(symb_3));
plot symb4 = Scale(close(symb_4));
AddLabel(1, symb_1, symb1.TakeValueColor());
AddLabel(yes, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")         
+ Round(R(symb_1, agg)), Color.WHITE);
AddLabel(1, symb_2, symb2.TakeValueColor());
AddLabel(yes, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")         
+ Round(R(symb_2, agg)), Color.WHITE);
AddLabel(1, symb_3, symb3.TakeValueColor());
AddLabel(yes, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")         
+ Round(R(symb_3, agg)), Color.WHITE);
AddLabel(1, symb_4, symb4.TakeValueColor());
AddLabel(yes, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")         
+ Round(R(symb_4, agg)), Color.WHITE);
#------NQ-----#
symb1.SetDefaultColor(GetColor(1));
symb1.SetDefaultColor(Color.UPTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb1.SetDefaultColor(Color.DOWNTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb1.DefineColor( "up", Color.UPTICK );
symb1.DefineColor( "dn", Color.DOWNTICK );
symb1.DefineColor( "def", Color.PLUM);

symb1.AssignValueColor(
if symb1 > symb1[1] then symb1.Color( "up" )
else if symb1 < symb1[1] then symb1.Color( "dn" )
else symb1.Color( "def" ) );
#------ES-----#
symb2.SetDefaultColor(GetColor(1));
symb2.SetDefaultColor(Color.UPTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb2.SetDefaultColor(Color.DOWNTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb2.DefineColor( "up", Color.UPTICK );
symb2.DefineColor( "dn", Color.DOWNTICK );
symb2.DefineColor( "def", Color.PLUM);

symb2.AssignValueColor(
if symb2 > symb2[1] then symb2.Color( "up" )
else if symb2 < symb2[1] then symb2.Color( "dn" )
else symb2.Color( "def" ) );
#------YM-----#
symb3.SetDefaultColor(GetColor(1));
symb3.SetDefaultColor(Color.UPTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb3.SetDefaultColor(Color.DOWNTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb3.DefineColor( "up", Color.UPTICK );
symb3.DefineColor( "dn", Color.DOWNTICK );
symb3.DefineColor( "def", Color.PLUM);

symb3.AssignValueColor(
if symb3 > symb3[1] then symb3.Color( "up" )
else if symb3 < symb3[1] then symb3.Color( "dn" )
else symb3.Color( "def" ) );
#------VXX-----#
symb4.SetDefaultColor(GetColor(1));
symb4.SetDefaultColor(Color.UPTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb4.SetDefaultColor(Color.DOWNTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb4.DefineColor( "up", Color.UPTICK );
symb4.DefineColor( "dn", Color.DOWNTICK );
symb4.DefineColor( "def", Color.PLUM);

symb4.AssignValueColor(
if symb4 > symb4[1] then symb4.Color( "up" )
else if symb4 < symb4[1] then symb4.Color( "dn" )
else symb4.Color( "def" ) );

#AssignBackgroundColor(if symb1 > symb1[1] then if symb2 > symb2[1] then symb3 > symb3[1] color.green else if
#symb1 < symb1[1] then if symb2 < symb2[1] then symb3 < symb3[1] color.red else Color( "current" ));
#----End Code-----#
#prsiMA.AssignValueColor(if prsiMA >= 50 then if prsiMA > prsiMA[1] then prsiMA.Color("Positive and Up") else #prsiMA.Color("Positive and Down") else if RSI < prsiMA[1] then prsiMA.Color("Negative and Down") else prsiMA.Color("Negative and Up"));
 
Here is MTF selected RSI label, colored white for each of the 4 symbols in your script.

The image is a AAPL 15min chart with Weekly agg RSI selected for the 4 symbols.
@SleepyZ I have one more request if you could make it happen. Based on the same 3 products NQ ES and YM. You blended the 3 products and RSI levels together. In this request can you blend the 3 products and this upper divergence study together? I attempted a crude label script which is probably incorrect and an alert script, also incorrect as I am still learning here. I was able to make the divergence script MTF so small victory there. Thank you again!

Code:
# Compare Symbols
# Mobius
 
input symb_1 = "/NQ";
input symb_2 = "/ES";
input symb_3 = "/YM";
input symb_4 = "VXX";

script Scale {
    input c = close;
    def Min = LowestAll(close);
    def Max = HighestAll(close);
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}
plot symb1 = Scale(close(symb_1));
plot symb2 = Scale(close(symb_2));
plot symb3 = Scale(close(symb_3));
plot symb4 = Scale(close(symb_4));
addLabel(1, symb_1, symb1.TakeValueColor());
addLabel(1, symb_2, symb2.TakeValueColor());
addLabel(1, symb_3, symb3.TakeValueColor());
addLabel(1, symb_4, symb4.TakeValueColor());
#------NQ-----#
symb1.SetDefaultColor(GetColor(1));
symb1.SetDefaultColor(Color.UPTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb1.SetDefaultColor(Color.DOWNTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb1.DefineColor( "up", Color.UPTICK ); 
symb1.DefineColor( "dn", Color.DOWNTICK ); 
symb1.DefineColor( "def", Color.plum); 

symb1.AssignValueColor( 
    if symb1 > symb1[1] then symb1.Color( "up" ) 
    else if symb1 < symb1[1] then symb1.Color( "dn" )
    else symb1.Color( "def" ) ); 
#------ES-----#
symb2.SetDefaultColor(GetColor(1));
symb2.SetDefaultColor(Color.UPTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb2.SetDefaultColor(Color.DOWNTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb2.DefineColor( "up", Color.UPTICK ); 
symb2.DefineColor( "dn", Color.DOWNTICK ); 
symb2.DefineColor( "def", Color.plum); 

symb2.AssignValueColor( 
    if symb2 > symb2[1] then symb2.Color( "up" ) 
    else if symb2 < symb2[1] then symb2.Color( "dn" )
    else symb2.Color( "def" ) ); 
#------YM-----#
symb3.SetDefaultColor(GetColor(1));
symb3.SetDefaultColor(Color.UPTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb3.SetDefaultColor(Color.DOWNTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb3.DefineColor( "up", Color.UPTICK ); 
symb3.DefineColor( "dn", Color.DOWNTICK ); 
symb3.DefineColor( "def", Color.plum); 

symb3.AssignValueColor( 
    if symb3 > symb3[1] then symb3.Color( "up" ) 
    else if symb3 < symb3[1] then symb3.Color( "dn" )
    else symb3.Color( "def" ) ); 
#------VXX-----#
symb4.SetDefaultColor(GetColor(1));
symb4.SetDefaultColor(Color.UPTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb4.SetDefaultColor(Color.DOWNTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb4.DefineColor( "up", Color.UPTICK ); 
symb4.DefineColor( "dn", Color.DOWNTICK ); 
symb4.DefineColor( "def", Color.plum); 

symb4.AssignValueColor( 
    if symb4 > symb4[1] then symb4.Color( "up" ) 
    else if symb4 < symb4[1] then symb4.Color( "dn" )
    else symb4.Color( "def" ) ); 

#AssignBackgroundColor(if symb1 > symb1[1] then if  symb2 > symb2[1] then symb3 > symb3[1] color.green else if
#symb1 < symb1[1] then if  symb2 < symb2[1] then symb3 < symb3[1] color.red else Color( "current" ));  
#----End Code-----#
#prsiMA.AssignValueColor(if prsiMA >= 50 then if prsiMA > prsiMA[1] then prsiMA.Color("Positive and Up") else #prsiMA.Color("Positive and Down") else if RSI < prsiMA[1] then prsiMA.Color("Negative and Down") else prsiMA.Color("Negative and Up"));

#------End Compare script-------#

#-------Upper Divergence-------#
#Upper Divergence
# RSI Divergence Upper Study Plots
# Mobius
# V01
# Note: Peak and trough points will always be painted on last 2 RSI low values and on last 2 RSI high values. The bridge will only plot when there is divergence.
input agg = AggregationPeriod.hour;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input averageType = AverageType.exponential;

def h = high(period = agg);
def l = low(period = agg);
def c = close(period = agg);

#def h = high;
#def l = low;
#def c = close;
def bar = barNumber();
def NetChgAvg = MovingAverage(averageType, c - c[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(c - c[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;
# Divergence Sub-Routine
def indicator = RSI;   # indicator to diverge
def upper = OverBought;# crossing above begins routine on the rising side.
def lower = OverSold;  # crossing below begins routine on the falling side.
def h_ind_val = if indicator < upper
            then h_ind_val[1]
            else if indicator crosses above upper
                 then indicator
                 else if indicator > upper and indicator > h_ind_val[1]
                      then indicator
            else h_ind_val[1];
def h_ind_bar = if indicator == h_ind_val
                then bar
                else h_ind_bar[1];
def h_ind_price = if bar == h_ind_bar
                  then h
                  else h_ind_price[1];
def prev_h_ind_bar = if indicator crosses above upper
                     then h_ind_bar[1]
                     else prev_h_ind_bar[1];
def prev_h_ind_val = if bar == highestAll(prev_h_ind_bar)
                 then indicator
                 else prev_h_ind_val[1];
def prev_h_price = if bar == highestAll(prev_h_ind_bar)
                   then h
                   else prev_h_price[1];
def high_div_true =  h_ind_val < prev_h_ind_val and
                     h_ind_price > prev_h_price;
plot high_div_line = if high_div_true and bar == highestAll(h_ind_bar)
                          then h_ind_price
                          else if bar == highestAll(prev_h_ind_bar)
                          then prev_h_price
                          else double.nan;                   
     high_div_line.EnableApproximation();
     high_div_line.HideBubble();
     high_div_line.HideTitle();
plot h_point = if bar == highestAll(h_ind_bar)
                then h_ind_price
                else double.nan;
     h_point.SetStyle(Curve.Points);
     h_point.SetLineWeight(2);
     h_point.SetDefaultColor(Color.yellow);
     h_point.HideBubble();
     h_point.HideTitle();
plot prev_h_point = if bar == highestAll(prev_h_ind_bar)
                then prev_h_price
                else double.nan;
     prev_h_point.SetStyle(Curve.Points);
     prev_h_point.SetLineWeight(2);
     prev_h_point.SetDefaultColor(Color.yellow);
     prev_h_point.HideBubble();
     prev_h_point.HideTitle();
addLabel(0, "bar = " + bar +
          "  h_ind_bar = " + highestAll(h_ind_bar) +
          "  h_ind_value = " + h_ind_val +
          "  h_ind_price = " + h_ind_price +
          "  prev_h_ind_bar = " + highestAll(prev_h_ind_bar) +
          "  prev_h_ind = " + prev_h_ind_val +
          "  prev_h_price = " + prev_h_price);

def l_ind_val = if indicator > lower
            then l_ind_val[1]
            else if indicator crosses below lower
                 then indicator
                 else if indicator < lower and indicator < l_ind_val[1]
                      then indicator
            else l_ind_val[1];
def l_ind_bar = if indicator == l_ind_val
                then bar
                else l_ind_bar[1];
def l_ind_price = if bar == l_ind_bar
                  then l
                  else l_ind_price[1];
def prev_l_ind_bar = if indicator crosses below lower
                     then l_ind_bar[1]
                     else prev_l_ind_bar[1];
def prev_l_ind_val = if bar == highestAll(prev_l_ind_bar)
                 then indicator
                 else prev_l_ind_val[1];
def prev_l_price = if bar == highestAll(prev_l_ind_bar)
                   then l
                   else prev_l_price[1];
def low_div_true =  l_ind_val > prev_l_ind_val and
                     l_ind_price < prev_l_price;
plot low_div_line = if low_div_true and bar == highestAll(l_ind_bar)
                          then l_ind_price
                          else if bar == highestAll(prev_l_ind_bar)
                          then prev_l_price
                          else double.nan;                   
     low_div_line.EnableApproximation();
     low_div_line.HideBubble();
     low_div_line.HideTitle();
plot l_point = if bar == highestAll(l_ind_bar)
                then l_ind_price
                else double.nan;
     l_point.SetStyle(Curve.Points);
     l_point.SetLineWeight(2);
     l_point.SetDefaultColor(Color.yellow);

#---End Divergence---#
 
Last edited by a moderator:
@SleepyZ I have one more request if you could make it happen. Based on the same 3 products NQ ES and YM. You blended the 3 products and RSI levels together. In this request can you blend the 3 products and this upper divergence study together? I attempted a crude label script which is probably incorrect and an alert script, also incorrect as I am still learning here. I was able to make the divergence script MTF so small victory there. Thank you again!

Code:
# Compare Symbols
# Mobius
 
input symb_1 = "/NQ";
input symb_2 = "/ES";
input symb_3 = "/YM";
input symb_4 = "VXX";

script Scale {
    input c = close;
    def Min = LowestAll(close);
    def Max = HighestAll(close);
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}
plot symb1 = Scale(close(symb_1));
plot symb2 = Scale(close(symb_2));
plot symb3 = Scale(close(symb_3));
plot symb4 = Scale(close(symb_4));
addLabel(1, symb_1, symb1.TakeValueColor());
addLabel(1, symb_2, symb2.TakeValueColor());
addLabel(1, symb_3, symb3.TakeValueColor());
addLabel(1, symb_4, symb4.TakeValueColor());
#------NQ-----#
symb1.SetDefaultColor(GetColor(1));
symb1.SetDefaultColor(Color.UPTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb1.SetDefaultColor(Color.DOWNTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb1.DefineColor( "up", Color.UPTICK );
symb1.DefineColor( "dn", Color.DOWNTICK );
symb1.DefineColor( "def", Color.plum);

symb1.AssignValueColor(
    if symb1 > symb1[1] then symb1.Color( "up" )
    else if symb1 < symb1[1] then symb1.Color( "dn" )
    else symb1.Color( "def" ) );
#------ES-----#
symb2.SetDefaultColor(GetColor(1));
symb2.SetDefaultColor(Color.UPTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb2.SetDefaultColor(Color.DOWNTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb2.DefineColor( "up", Color.UPTICK );
symb2.DefineColor( "dn", Color.DOWNTICK );
symb2.DefineColor( "def", Color.plum);

symb2.AssignValueColor(
    if symb2 > symb2[1] then symb2.Color( "up" )
    else if symb2 < symb2[1] then symb2.Color( "dn" )
    else symb2.Color( "def" ) );
#------YM-----#
symb3.SetDefaultColor(GetColor(1));
symb3.SetDefaultColor(Color.UPTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb3.SetDefaultColor(Color.DOWNTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb3.DefineColor( "up", Color.UPTICK );
symb3.DefineColor( "dn", Color.DOWNTICK );
symb3.DefineColor( "def", Color.plum);

symb3.AssignValueColor(
    if symb3 > symb3[1] then symb3.Color( "up" )
    else if symb3 < symb3[1] then symb3.Color( "dn" )
    else symb3.Color( "def" ) );
#------VXX-----#
symb4.SetDefaultColor(GetColor(1));
symb4.SetDefaultColor(Color.UPTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb4.SetDefaultColor(Color.DOWNTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb4.DefineColor( "up", Color.UPTICK );
symb4.DefineColor( "dn", Color.DOWNTICK );
symb4.DefineColor( "def", Color.plum);

symb4.AssignValueColor(
    if symb4 > symb4[1] then symb4.Color( "up" )
    else if symb4 < symb4[1] then symb4.Color( "dn" )
    else symb4.Color( "def" ) );

#AssignBackgroundColor(if symb1 > symb1[1] then if  symb2 > symb2[1] then symb3 > symb3[1] color.green else if
#symb1 < symb1[1] then if  symb2 < symb2[1] then symb3 < symb3[1] color.red else Color( "current" )); 
#----End Code-----#
#prsiMA.AssignValueColor(if prsiMA >= 50 then if prsiMA > prsiMA[1] then prsiMA.Color("Positive and Up") else #prsiMA.Color("Positive and Down") else if RSI < prsiMA[1] then prsiMA.Color("Negative and Down") else prsiMA.Color("Negative and Up"));

#------End Compare script-------#

#-------Upper Divergence-------#
#Upper Divergence
# RSI Divergence Upper Study Plots
# Mobius
# V01
# Note: Peak and trough points will always be painted on last 2 RSI low values and on last 2 RSI high values. The bridge will only plot when there is divergence.
input agg = AggregationPeriod.hour;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input averageType = AverageType.exponential;

def h = high(period = agg);
def l = low(period = agg);
def c = close(period = agg);

#def h = high;
#def l = low;
#def c = close;
def bar = barNumber();
def NetChgAvg = MovingAverage(averageType, c - c[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(c - c[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;
# Divergence Sub-Routine
def indicator = RSI;   # indicator to diverge
def upper = OverBought;# crossing above begins routine on the rising side.
def lower = OverSold;  # crossing below begins routine on the falling side.
def h_ind_val = if indicator < upper
            then h_ind_val[1]
            else if indicator crosses above upper
                 then indicator
                 else if indicator > upper and indicator > h_ind_val[1]
                      then indicator
            else h_ind_val[1];
def h_ind_bar = if indicator == h_ind_val
                then bar
                else h_ind_bar[1];
def h_ind_price = if bar == h_ind_bar
                  then h
                  else h_ind_price[1];
def prev_h_ind_bar = if indicator crosses above upper
                     then h_ind_bar[1]
                     else prev_h_ind_bar[1];
def prev_h_ind_val = if bar == highestAll(prev_h_ind_bar)
                 then indicator
                 else prev_h_ind_val[1];
def prev_h_price = if bar == highestAll(prev_h_ind_bar)
                   then h
                   else prev_h_price[1];
def high_div_true =  h_ind_val < prev_h_ind_val and
                     h_ind_price > prev_h_price;
plot high_div_line = if high_div_true and bar == highestAll(h_ind_bar)
                          then h_ind_price
                          else if bar == highestAll(prev_h_ind_bar)
                          then prev_h_price
                          else double.nan;                  
     high_div_line.EnableApproximation();
     high_div_line.HideBubble();
     high_div_line.HideTitle();
plot h_point = if bar == highestAll(h_ind_bar)
                then h_ind_price
                else double.nan;
     h_point.SetStyle(Curve.Points);
     h_point.SetLineWeight(2);
     h_point.SetDefaultColor(Color.yellow);
     h_point.HideBubble();
     h_point.HideTitle();
plot prev_h_point = if bar == highestAll(prev_h_ind_bar)
                then prev_h_price
                else double.nan;
     prev_h_point.SetStyle(Curve.Points);
     prev_h_point.SetLineWeight(2);
     prev_h_point.SetDefaultColor(Color.yellow);
     prev_h_point.HideBubble();
     prev_h_point.HideTitle();
addLabel(0, "bar = " + bar +
          "  h_ind_bar = " + highestAll(h_ind_bar) +
          "  h_ind_value = " + h_ind_val +
          "  h_ind_price = " + h_ind_price +
          "  prev_h_ind_bar = " + highestAll(prev_h_ind_bar) +
          "  prev_h_ind = " + prev_h_ind_val +
          "  prev_h_price = " + prev_h_price);

def l_ind_val = if indicator > lower
            then l_ind_val[1]
            else if indicator crosses below lower
                 then indicator
                 else if indicator < lower and indicator < l_ind_val[1]
                      then indicator
            else l_ind_val[1];
def l_ind_bar = if indicator == l_ind_val
                then bar
                else l_ind_bar[1];
def l_ind_price = if bar == l_ind_bar
                  then l
                  else l_ind_price[1];
def prev_l_ind_bar = if indicator crosses below lower
                     then l_ind_bar[1]
                     else prev_l_ind_bar[1];
def prev_l_ind_val = if bar == highestAll(prev_l_ind_bar)
                 then indicator
                 else prev_l_ind_val[1];
def prev_l_price = if bar == highestAll(prev_l_ind_bar)
                   then l
                   else prev_l_price[1];
def low_div_true =  l_ind_val > prev_l_ind_val and
                     l_ind_price < prev_l_price;
plot low_div_line = if low_div_true and bar == highestAll(l_ind_bar)
                          then l_ind_price
                          else if bar == highestAll(prev_l_ind_bar)
                          then prev_l_price
                          else double.nan;                  
     low_div_line.EnableApproximation();
     low_div_line.HideBubble();
     low_div_line.HideTitle();
plot l_point = if bar == highestAll(l_ind_bar)
                then l_ind_price
                else double.nan;
     l_point.SetStyle(Curve.Points);
     l_point.SetLineWeight(2);
     l_point.SetDefaultColor(Color.yellow);

#---End Divergence---#

I am not sure what you want. If you want what is in the label in the divergence code, it relies on bar numbers and highestall, which will not work when I tested it viewing other symbols like what was done for the RSI for you.
 
I am not sure what you want. If you want what is in the label in the divergence code, it relies on bar numbers and highestall, which will not work when I tested it viewing other symbols like what was done for the RSI for you.
Yes, I was hoping there was someway when divergence is occurring the label would appear. The divergence script doesn't need the the MTF piece as I watch the HTF's anyway for the product I am trading which is mostly the NASDAQ. On the highline the word divergence would appear with a red background color for bearish divergence and vice versa. Can you share what you have so far?
 
Yes, I was hoping there was someway when divergence is occurring the label would appear. The divergence script doesn't need the the MTF piece as I watch the HTF's anyway for the product I am trading which is mostly the NASDAQ. On the highline the word divergence would appear with a red background color for bearish divergence and vice versa. Can you share what you have so far?

Sure. As noted above, this code does not currently work properly.

The labels have everything displayed that was in the label from the divergence code. Spacers where included to try to align the labels.

Screenshot-2023-03-16-071921.png
Code:
# Compare Symbols
# Mobius
 
input symb_1 = "/NQ";
input symb_2 = "/ES";
input symb_3 = "/YM";
input symb_4 = "VXX";

script Scale {
    input c = close;
    def Min = LowestAll(close);
    def Max = HighestAll(close);
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}

script RD {
#AssignBackgroundColor(if symb1 > symb1[1] then if  symb2 > symb2[1] then symb3 > symb3[1] color.green else if
#symb1 < symb1[1] then if  symb2 < symb2[1] then symb3 < symb3[1] color.red else Color( "current" )); 
#----End Code-----#
#prsiMA.AssignValueColor(if prsiMA >= 50 then if prsiMA > prsiMA[1] then prsiMA.Color("Positive and Up") else #prsiMA.Color("Positive and Down") else if RSI < prsiMA[1] then prsiMA.Color("Negative and Down") else prsiMA.Color("Negative and Up"));

#------End Compare script-------#

#-------Upper Divergence-------#
#Upper Divergence
# RSI Divergence Upper Study Plots
# Mobius
# V01
# Note: Peak and trough points will always be painted on last 2 RSI low values and on last 2 RSI high values. The bridge will only plot when there is divergence.
    input sym = "/NQ";
    input agg = AggregationPeriod.HOUR;
    input length = 14;
    input over_Bought = 70;
    input over_Sold = 30;
    input averageType = AverageType.EXPONENTIAL;

    def h = high(sym, period = agg);
    def l = low(sym, period = agg);
    def c = close(sym, period = agg);

#def h = high;
#def l = low;
#def c = close;
    def bar = BarNumber();
    def NetChgAvg = MovingAverage(averageType, c - c[1], length);
    def TotChgAvg = MovingAverage(averageType, AbsValue(c - c[1]), length);
    def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
    def RSI = 50 * (ChgRatio + 1);
    def OverSold = over_Sold;
    def OverBought = over_Bought;
# Divergence Sub-Routine
    def indicator = RSI;   # indicator to diverge
    def upper = OverBought;# crossing above begins routine on the rising side.
    def lower = OverSold;  # crossing below begins routine on the falling side.
    def h_ind_val = if indicator < upper
            then h_ind_val[1]
            else if Crosses(RSI, upper, CrossingDirection.ABOVE)
                 then indicator
                 else if indicator > upper and indicator > h_ind_val[1]
                      then indicator
            else h_ind_val[1];
    def h_ind_bar = if indicator == h_ind_val
                then bar
                else h_ind_bar[1];
    def h_ind_price = if bar == h_ind_bar
                  then h
                  else h_ind_price[1];
    def prev_h_ind_bar = if Crosses(indicator, upper, CrossingDirection.ABOVE)
                     then h_ind_bar[1]
                     else prev_h_ind_bar[1];
    def prev_h_ind_val = if bar == HighestAll(prev_h_ind_bar)
                 then indicator
                 else prev_h_ind_val[1];
    def prev_h_price = if bar == HighestAll(prev_h_ind_bar)
                   then h
                   else prev_h_price[1];
    def high_div_true =  h_ind_val < prev_h_ind_val and
                     h_ind_price > prev_h_price;
    plot high_div_line = if high_div_true and bar == HighestAll(h_ind_bar)
                          then h_ind_price
                          else if bar == HighestAll(prev_h_ind_bar)
                          then prev_h_price
                          else Double.NaN;
    high_div_line.EnableApproximation();
    high_div_line.HideBubble();
    high_div_line.HideTitle();
    plot h_point = if bar == HighestAll(h_ind_bar)
                then h_ind_price
                else Double.NaN;
    h_point.SetStyle(Curve.POINTS);
    h_point.SetLineWeight(2);
    h_point.SetDefaultColor(Color.YELLOW);
    h_point.HideBubble();
    h_point.HideTitle();
    plot prev_h_point = if bar == HighestAll(prev_h_ind_bar)
                then prev_h_price
                else Double.NaN;
    prev_h_point.SetStyle(Curve.POINTS);
    prev_h_point.SetLineWeight(2);
    prev_h_point.SetDefaultColor(Color.YELLOW);
    prev_h_point.HideBubble();
    prev_h_point.HideTitle();
    AddLabel(0, "bar = " + bar +
          "  h_ind_bar = " + HighestAll(h_ind_bar) +
          "  h_ind_value = " + h_ind_val +
          "  h_ind_price = " + h_ind_price +
          "  prev_h_ind_bar = " + HighestAll(prev_h_ind_bar) +
          "  prev_h_ind = " + prev_h_ind_val +
          "  prev_h_price = " + prev_h_price);

    def l_ind_val = if indicator > lower
            then l_ind_val[1]
            else if Crosses(indicator, lower, CrossingDirection.BELOW)
                 then indicator
                 else if indicator < lower and indicator < l_ind_val[1]
                      then indicator
            else l_ind_val[1];
    def l_ind_bar = if indicator == l_ind_val
                then bar
                else l_ind_bar[1];
    def l_ind_price = if bar == l_ind_bar
                  then l
                  else l_ind_price[1];
    def prev_l_ind_bar = if Crosses(indicator, lower, CrossingDirection.BELOW)
                     then l_ind_bar[1]
                     else prev_l_ind_bar[1];
    def prev_l_ind_val = if bar == HighestAll(prev_l_ind_bar)
                 then indicator
                 else prev_l_ind_val[1];
    def prev_l_price = if bar == HighestAll(prev_l_ind_bar)
                   then l
                   else prev_l_price[1];
    def low_div_true =  l_ind_val > prev_l_ind_val and
                     l_ind_price < prev_l_price;
    plot low_div_line = if low_div_true and bar == HighestAll(l_ind_bar)
                          then l_ind_price
                          else if bar == HighestAll(prev_l_ind_bar)
                          then prev_l_price
                          else Double.NaN;
    low_div_line.EnableApproximation();
    low_div_line.HideBubble();
    low_div_line.HideTitle();
    plot l_point = if bar == HighestAll(l_ind_bar)
                then l_ind_price
                else Double.NaN;
    l_point.SetStyle(Curve.POINTS);
    l_point.SetLineWeight(2);
    l_point.SetDefaultColor(Color.YELLOW);

#---End Divergence---#
}

plot symb1 = Scale(close(symb_1));
plot symb2 = Scale(close(symb_2));
plot symb3 = Scale(close(symb_3));
plot symb4 = Scale(close(symb_4));

#######################################################
input agg = AggregationPeriod.HOUR;
AddLabel(1, symb_1, symb1.TakeValueColor());
AddLabel(1, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")     
+ "bar = " + RD(symb_1, agg).bar +
          "  h_ind_bar = " + HighestAll(RD(symb_1, agg).h_ind_bar) +
          "  h_ind_value = " + RD(symb_1, agg).h_ind_val +
          "  h_ind_price = " + RD(symb_1, agg).h_ind_price +
          "  prev_h_ind_bar = " + HighestAll(RD(symb_1, agg).prev_h_ind_bar) +
          "  prev_h_ind = " + RD(symb_1, agg).prev_h_ind_val +
          "  prev_h_price = " + RD(symb_1, agg).prev_h_price);

Addlabel(1,"         ", color.black);#spacer

AddLabel(1, symb_2, symb2.TakeValueColor());
AddLabel(1, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")     
+ "bar = " + RD(symb_1, agg).bar +
          "  h_ind_bar = " + HighestAll(RD(symb_2, agg).h_ind_bar) +
          "  h_ind_value = " + RD(symb_2, agg).h_ind_val +
          "  h_ind_price = " + RD(symb_2, agg).h_ind_price +
          "  prev_h_ind_bar = " + HighestAll(RD(symb_2, agg).prev_h_ind_bar) +
          "  prev_h_ind = " + RD(symb_2, agg).prev_h_ind_val +
          "  prev_h_price = " + RD(symb_2, agg).prev_h_price);

Addlabel(1,"                                  ", color.black);#spacer


AddLabel(1, symb_3, symb3.TakeValueColor());
AddLabel(1, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")     
+ "bar = " + RD(symb_3, agg).bar +
          "  h_ind_bar = " + HighestAll(RD(symb_3, agg).h_ind_bar) +
          "  h_ind_value = " + RD(symb_3, agg).h_ind_val +
          "  h_ind_price = " + RD(symb_3, agg).h_ind_price +
          "  prev_h_ind_bar = " + HighestAll(RD(symb_3, agg).prev_h_ind_bar) +
          "  prev_h_ind = " + RD(symb_3, agg).prev_h_ind_val +
          "  prev_h_price = " + RD(symb_3, agg).prev_h_price);

Addlabel(1,"                              ", color.black);#spacer

AddLabel(1, symb_4, symb4.TakeValueColor());
AddLabel(1, ( if agg == AggregationPeriod.MONTH
              then "M: "
              else if agg == AggregationPeriod.WEEK
              then "W: "
              else if  agg >= AggregationPeriod.DAY
              then agg / 0000 / 1440 + "D: "
              else if agg >= AggregationPeriod.HOUR
              then agg / 60000 / 60 + "H: "
              else agg / 60000 + "m: ")     
+ "bar = " + RD(symb_1, agg).bar +
          "  h_ind_bar = " + HighestAll(RD(symb_4, agg).h_ind_bar) +
          "  h_ind_value = " + RD(symb_4, agg).h_ind_val +
          "  h_ind_price = " + RD(symb_4, agg).h_ind_price +
          "  prev_h_ind_bar = " + HighestAll(RD(symb_4, agg).prev_h_ind_bar) +
          "  prev_h_ind = " + RD(symb_4, agg).prev_h_ind_val +
          "  prev_h_price = " + RD(symb_4, agg).prev_h_price);
#------NQ-----#
##############################################

symb1.SetDefaultColor(GetColor(1));
symb1.SetDefaultColor(Color.UPTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb1.SetDefaultColor(Color.DOWNTICK);
symb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb1.DefineColor( "up", Color.UPTICK );
symb1.DefineColor( "dn", Color.DOWNTICK );
symb1.DefineColor( "def", Color.PLUM);

symb1.AssignValueColor(
    if symb1 > symb1[1] then symb1.Color( "up" )
    else if symb1 < symb1[1] then symb1.Color( "dn" )
    else symb1.Color( "def" ) );
#------ES-----#
symb2.SetDefaultColor(GetColor(1));
symb2.SetDefaultColor(Color.UPTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb2.SetDefaultColor(Color.DOWNTICK);
symb2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb2.DefineColor( "up", Color.UPTICK );
symb2.DefineColor( "dn", Color.DOWNTICK );
symb2.DefineColor( "def", Color.PLUM);

symb2.AssignValueColor(
    if symb2 > symb2[1] then symb2.Color( "up" )
    else if symb2 < symb2[1] then symb2.Color( "dn" )
    else symb2.Color( "def" ) );
#------YM-----#
symb3.SetDefaultColor(GetColor(1));
symb3.SetDefaultColor(Color.UPTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb3.SetDefaultColor(Color.DOWNTICK);
symb3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb3.DefineColor( "up", Color.UPTICK );
symb3.DefineColor( "dn", Color.DOWNTICK );
symb3.DefineColor( "def", Color.PLUM);

symb3.AssignValueColor(
    if symb3 > symb3[1] then symb3.Color( "up" )
    else if symb3 < symb3[1] then symb3.Color( "dn" )
    else symb3.Color( "def" ) );
#------VXX-----#
symb4.SetDefaultColor(GetColor(1));
symb4.SetDefaultColor(Color.UPTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
symb4.SetDefaultColor(Color.DOWNTICK);
symb4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

symb4.DefineColor( "up", Color.UPTICK );
symb4.DefineColor( "dn", Color.DOWNTICK );
symb4.DefineColor( "def", Color.PLUM);

symb4.AssignValueColor(
    if symb4 > symb4[1] then symb4.Color( "up" )
    else if symb4 < symb4[1] then symb4.Color( "dn" )
    else symb4.Color( "def" ) );
 
Sure. As noted above, this code does not currently work properly.

The labels have everything displayed that was in the label from the divergence code. Spacers where included to try to align the labels.
@Sleepy
Sure. As noted above, this code does not currently work properly.

The labels have everything displayed that was in the label from the divergence code. Spacers where included to try to align the labels.
I don't know if this will matter, and I do apologize but this is the correct upper divergence script. I sent you the one I corrupted with the aggregation and the label script I wrote. But here is correct version.

# RSI Divergence Upper Study Plots
# Mobius
# V01
# Note: Peak and trough points will always be painted on last 2 RSI low values and on last 2 RSI high values. The bridge will only plot when there is divergence.

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input averageType = AverageType.WILDERS;

def h = high;
def l = low;
def c = close;
def bar = barNumber();
def NetChgAvg = MovingAverage(averageType, c - c[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(c - c[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;
# Divergence Sub-Routine
def indicator = RSI; # indicator to diverge
def upper = OverBought;# crossing above begins routine on the rising side.
def lower = OverSold; # crossing below begins routine on the falling side.
def h_ind_val = if indicator < upper
then h_ind_val[1]
else if indicator crosses above upper
then indicator
else if indicator > upper and indicator > h_ind_val[1]
then indicator
else h_ind_val[1];
def h_ind_bar = if indicator == h_ind_val
then bar
else h_ind_bar[1];
def h_ind_price = if bar == h_ind_bar
then h
else h_ind_price[1];
def prev_h_ind_bar = if indicator crosses above upper
then h_ind_bar[1]
else prev_h_ind_bar[1];
def prev_h_ind_val = if bar == highestAll(prev_h_ind_bar)
then indicator
else prev_h_ind_val[1];
def prev_h_price = if bar == highestAll(prev_h_ind_bar)
then h
else prev_h_price[1];
def high_div_true = h_ind_val < prev_h_ind_val and
h_ind_price > prev_h_price;
plot high_div_line = if high_div_true and bar == highestAll(h_ind_bar)
then h_ind_price
else if bar == highestAll(prev_h_ind_bar)
then prev_h_price
else double.nan;
high_div_line.EnableApproximation();
high_div_line.HideBubble();
high_div_line.HideTitle();
plot h_point = if bar == highestAll(h_ind_bar)
then h_ind_price
else double.nan;
h_point.SetStyle(Curve.Points);
h_point.SetLineWeight(2);
h_point.SetDefaultColor(Color.yellow);
h_point.HideBubble();
h_point.HideTitle();
plot prev_h_point = if bar == highestAll(prev_h_ind_bar)
then prev_h_price
else double.nan;
prev_h_point.SetStyle(Curve.Points);
prev_h_point.SetLineWeight(2);
prev_h_point.SetDefaultColor(Color.yellow);
prev_h_point.HideBubble();
prev_h_point.HideTitle();
addLabel(0, "bar = " + bar +
" h_ind_bar = " + highestAll(h_ind_bar) +
" h_ind_value = " + h_ind_val +
" h_ind_price = " + h_ind_price +
" prev_h_ind_bar = " + highestAll(prev_h_ind_bar) +
" prev_h_ind = " + prev_h_ind_val +
" prev_h_price = " + prev_h_price);

def l_ind_val = if indicator > lower
then l_ind_val[1]
else if indicator crosses below lower
then indicator
else if indicator < lower and indicator < l_ind_val[1]
then indicator
else l_ind_val[1];
def l_ind_bar = if indicator == l_ind_val
then bar
else l_ind_bar[1];
def l_ind_price = if bar == l_ind_bar
then l
else l_ind_price[1];
def prev_l_ind_bar = if indicator crosses below lower
then l_ind_bar[1]
else prev_l_ind_bar[1];
def prev_l_ind_val = if bar == highestAll(prev_l_ind_bar)
then indicator
else prev_l_ind_val[1];
def prev_l_price = if bar == highestAll(prev_l_ind_bar)
then l
else prev_l_price[1];
def low_div_true = l_ind_val > prev_l_ind_val and
l_ind_price < prev_l_price;
plot low_div_line = if low_div_true and bar == highestAll(l_ind_bar)
then l_ind_price
else if bar == highestAll(prev_l_ind_bar)
then prev_l_price
else double.nan;
low_div_line.EnableApproximation();
low_div_line.HideBubble();
low_div_line.HideTitle();
plot l_point = if bar == highestAll(l_ind_bar)
then l_ind_price
else double.nan;
l_point.SetStyle(Curve.Points);
l_point.SetLineWeight(2);
l_point.SetDefaultColor(Color.yellow);
l_point.HideBubble();
l_point.HideTitle();
plot prev_l_point = if bar == highestAll(prev_l_ind_bar)
then prev_l_Price
else double.nan;
prev_l_point.SetStyle(Curve.Points);
prev_l_point.SetLineWeight(2);
prev_l_point.SetDefaultColor(Color.yellow);
prev_l_point.HideBubble();
prev_l_point.HideTitle();
addLabel(0, "bar = " + bar +
" l_ind_bar = " + highestAll(l_ind_bar) +
" l_ind_value = " + l_ind_val +
" l_ind_price = " + l_ind_price +
" prev_l_ind_bar = " + highestAll(prev_l_ind_bar) +
" prev_l_ind = " + prev_l_ind_val +
" prev_l_price = " + prev_l_price);
# End Code
 
@Sleepy

I don't know if this will matter, and I do apologize but this is the correct upper divergence script. I sent you the one I corrupted with the aggregation and the label script I wrote. But here is correct version.

# RSI Divergence Upper Study Plots
# Mobius
# V01
# Note: Peak and trough points will always be painted on last 2 RSI low values and on last 2 RSI high values. The bridge will only plot when there is divergence.

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input averageType = AverageType.WILDERS;

def h = high;
def l = low;
def c = close;
def bar = barNumber();
def NetChgAvg = MovingAverage(averageType, c - c[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(c - c[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;
# Divergence Sub-Routine
def indicator = RSI; # indicator to diverge
def upper = OverBought;# crossing above begins routine on the rising side.
def lower = OverSold; # crossing below begins routine on the falling side.
def h_ind_val = if indicator < upper
then h_ind_val[1]
else if indicator crosses above upper
then indicator
else if indicator > upper and indicator > h_ind_val[1]
then indicator
else h_ind_val[1];
def h_ind_bar = if indicator == h_ind_val
then bar
else h_ind_bar[1];
def h_ind_price = if bar == h_ind_bar
then h
else h_ind_price[1];
def prev_h_ind_bar = if indicator crosses above upper
then h_ind_bar[1]
else prev_h_ind_bar[1];
def prev_h_ind_val = if bar == highestAll(prev_h_ind_bar)
then indicator
else prev_h_ind_val[1];
def prev_h_price = if bar == highestAll(prev_h_ind_bar)
then h
else prev_h_price[1];
def high_div_true = h_ind_val < prev_h_ind_val and
h_ind_price > prev_h_price;
plot high_div_line = if high_div_true and bar == highestAll(h_ind_bar)
then h_ind_price
else if bar == highestAll(prev_h_ind_bar)
then prev_h_price
else double.nan;
high_div_line.EnableApproximation();
high_div_line.HideBubble();
high_div_line.HideTitle();
plot h_point = if bar == highestAll(h_ind_bar)
then h_ind_price
else double.nan;
h_point.SetStyle(Curve.Points);
h_point.SetLineWeight(2);
h_point.SetDefaultColor(Color.yellow);
h_point.HideBubble();
h_point.HideTitle();
plot prev_h_point = if bar == highestAll(prev_h_ind_bar)
then prev_h_price
else double.nan;
prev_h_point.SetStyle(Curve.Points);
prev_h_point.SetLineWeight(2);
prev_h_point.SetDefaultColor(Color.yellow);
prev_h_point.HideBubble();
prev_h_point.HideTitle();
addLabel(0, "bar = " + bar +
" h_ind_bar = " + highestAll(h_ind_bar) +
" h_ind_value = " + h_ind_val +
" h_ind_price = " + h_ind_price +
" prev_h_ind_bar = " + highestAll(prev_h_ind_bar) +
" prev_h_ind = " + prev_h_ind_val +
" prev_h_price = " + prev_h_price);

def l_ind_val = if indicator > lower
then l_ind_val[1]
else if indicator crosses below lower
then indicator
else if indicator < lower and indicator < l_ind_val[1]
then indicator
else l_ind_val[1];
def l_ind_bar = if indicator == l_ind_val
then bar
else l_ind_bar[1];
def l_ind_price = if bar == l_ind_bar
then l
else l_ind_price[1];
def prev_l_ind_bar = if indicator crosses below lower
then l_ind_bar[1]
else prev_l_ind_bar[1];
def prev_l_ind_val = if bar == highestAll(prev_l_ind_bar)
then indicator
else prev_l_ind_val[1];
def prev_l_price = if bar == highestAll(prev_l_ind_bar)
then l
else prev_l_price[1];
def low_div_true = l_ind_val > prev_l_ind_val and
l_ind_price < prev_l_price;
plot low_div_line = if low_div_true and bar == highestAll(l_ind_bar)
then l_ind_price
else if bar == highestAll(prev_l_ind_bar)
then prev_l_price
else double.nan;
low_div_line.EnableApproximation();
low_div_line.HideBubble();
low_div_line.HideTitle();
plot l_point = if bar == highestAll(l_ind_bar)
then l_ind_price
else double.nan;
l_point.SetStyle(Curve.Points);
l_point.SetLineWeight(2);
l_point.SetDefaultColor(Color.yellow);
l_point.HideBubble();
l_point.HideTitle();
plot prev_l_point = if bar == highestAll(prev_l_ind_bar)
then prev_l_Price
else double.nan;
prev_l_point.SetStyle(Curve.Points);
prev_l_point.SetLineWeight(2);
prev_l_point.SetDefaultColor(Color.yellow);
prev_l_point.HideBubble();
prev_l_point.HideTitle();
addLabel(0, "bar = " + bar +
" l_ind_bar = " + highestAll(l_ind_bar) +
" l_ind_value = " + l_ind_val +
" l_ind_price = " + l_ind_price +
" prev_l_ind_bar = " + highestAll(prev_l_ind_bar) +
" prev_l_ind = " + prev_l_ind_val +
" prev_l_price = " + prev_l_price);
# End Code

Thanks, but it will likely not work either for the reasons I stated above
 
Quick code. See if it works.

Code:
# RSI_With_Divergence
# Mobius
# V01.01.2013
# 4.15.2019
#hint:<b>RSI with Divergence</b>
# Note: Install this as a new study. Save this study using the name above (the first line of code RSI_With_Divergence).
# To use this study as a scan; DO NOT TRY TO LOAD IT DIRECTLY IN THE SCANNER, IT WILL THROW AN ERROR MESSAGE. Go to the scan tab. Delete any existing scan criteria. Click Add Study Filter. Click the window under Criteria. In that drop down menu click Custom. Delete the existing study. Click Add Condition. Click the down arrow in the Select A Condition window. Click Study. Scroll down the List till you find RSI_With_Divergence and click it. Click on the Plot window and you can choose Dhigh or Dlow in addition to the default plot RSI. If you choose either of the divergence siganls choose is True from the center column. Click on the aggregation period at the top left and set the aggregation period you want scaned. Then click Save and when the popup window shows the warning that this is a custom scan chose OK. Now put the list of stocks you wish to scan in the Scan In box and chose any list you want that to intersect with. If you wish to make this a Dynamic WatchList, save this scan with a name such as RSI_With_Div_WL then in your Gadgets box click the little gear icon, locate the name of the scan you just saved and click it. As equities match the scan criteria they will populate the list.

declare lower;

input n = 14;        #hint nRSI: Periods or length for RSI
input Over_Bought = 70; #hint Over_Bought: Over Bought line
input Over_Sold = 30;   #hint Over_Sold: Over Sold line

def o = open;
def h = high;
def l = low;

def x = BarNumber();


input agg = AggregationPeriod.DAY;
def c = close(period = agg);


def MidLine = 50;
def NetChgAvg = ExpAverage(c - c[1], n);
def TotChgAvg = ExpAverage(AbsValue(c - c[1]), n);
def ChgRatio = if TotChgAvg != 0
                  then NetChgAvg / TotChgAvg
                  else 0;
plot RSI = 50 * (ChgRatio + 1);
RSI.AssignValueColor(if RSI < Over_Sold
                     then color.yellow
                     else if RSI > Over_Bought
                     then color.yellow
                     else createColor(25, 75, 250));
plot OverSold = Over_Sold;
plot OverBought = Over_Bought;
def bar = BarNumber();
def Currh = if RSI > OverBought
                then fold i = 1 to Floor(n / 2)
                with p = 1
                while p
                do RSI > getValue(RSI, -i)
                else 0;
def CurrPivotH = if (bar > n and
                         RSI == highest(RSI, Floor(n/2)) and
                         Currh)
                     then RSI
                     else double.NaN;
def Currl = if RSI < OverSold
                then fold j = 1 to Floor(n / 2)
                with q = 1
                while q
                do RSI < getValue(RSI, -j)
                else 0;
def CurrPivotL = if (bar > n and
                         RSI == lowest(RSI, Floor(n/2)) and
                         Currl)
                     then RSI
                     else double.NaN;
def CurrPHBar = if !isNaN(CurrPivotH)
                then bar
                else CurrPHBar[1];
def CurrPLBar = if !isNaN(CurrPivotL)
                then bar
                else CurrPLBar[1];
def PHpoint = if !isNaN(CurrPivotH)
              then CurrPivotH
              else PHpoint[1];
def priorPHBar = if PHpoint != PHpoint[1]
                 then CurrPHBar[1]
                 else priorPHBar[1];
def PLpoint = if !isNaN(CurrPivotL)
              then CurrPivotL
              else PLpoint[1];
def priorPLBar = if PLpoint != PLpoint[1]
                 then CurrPLBar[1]
                 else priorPLBar[1];
def HighPivots = bar >= highestAll(priorPHBar);
def LowPivots = bar >= highestAll(priorPLBar);
def pivotHigh = if HighPivots
                then CurrPivotH
                else double.NaN;
plot PlotHline = pivotHigh;
    PlotHline.enableApproximation();
    PlotHline.SetDefaultColor(GetColor(7));
    PlotHline.SetStyle(Curve.Short_DASH);
plot pivotLow = if LowPivots
                then CurrPivotL
                else double.NaN;
    pivotLow.enableApproximation();
    pivotLow.SetDefaultColor(GetColor(7));
    pivotLow.SetStyle(Curve.Short_DASH);
plot PivotDot = if !isNaN(pivotHigh)
                then pivotHigh
                else if !isNaN(pivotLow)
                     then pivotLow
                     else double.NaN;
    pivotDot.SetDefaultColor(GetColor(7));
    pivotDot.SetPaintingStrategy(PaintingStrategy.POINTS);
    pivotDot.SetLineWeight(3);

# End Code RSI with Divergence
How can I change the blue line on the RSI to black? It is hard to see on my chart
 
Chart time frame plus choice of 2 additional time frames RSI. Cloud between chart time frame RSI and next highest time frame RSI. User can input two higher time frames. Make sure higher time frames are higher than chart time frame.

Code:
#MTF RSI Three standard ToS RSI studies with a choice of time frame for second and third RSI. Cloud between chart and second RSI.
# RSI with agg periods by Horserider. 5/12/2019

declare lower;
#RSI
input length = 14;
input over_Bought = 80;
input over_Sold = 20;
input price = close;
input averageType = AverageType.WILDERS;



def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

plot RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;
plot lline = 50;


RSI.DefineColor("Positive and Up", Color.GREEN);
RSI.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI.DefineColor("Negative and Down", Color.RED);
RSI.DefineColor("Negative and Up", Color.DARK_RED);
RSI.AssignValueColor(if RSI >= 50 then if RSI > RSI[1] then RSI.Color("Positive and Up") else RSI.Color("Positive and Down") else if RSI < RSI[1] then RSI.Color("Negative and Down") else RSI.Color("Negative and Up"));

OverSold.SetDefaultColor(GetColor(7));
OverBought.SetDefaultColor(GetColor(7));

# RSI 2
input length2 = 14;
input price2 = close;
input averageType2 = AverageType.WILDERS;
input agg = AggregationPeriod.DAY;


def c = close(period = agg);

def NetChgAvg2 = MovingAverage(averageType2, c - c[1], length2);
def TotChgAvg2 = MovingAverage(averageType2, AbsValue(c - c[1]),length2);
def ChgRatio2 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;

plot RSI2 = 50 * (ChgRatio2 + 1);


RSI2.DefineColor("Positive and Up", Color.GREEN);
RSI2.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI2.DefineColor("Negative and Down", Color.RED);
RSI2.DefineColor("Negative and Up", Color.DARK_RED);
RSI2.AssignValueColor(if RSI2 >= 50 then if RSI2 > RSI2[1] then RSI2.Color("Positive and Up") else RSI2.Color("Positive and Down") else if RSI2 < RSI2[1] then RSI2.Color("Negative and Down") else RSI2.Color("Negative and Up"));
RSI2.setLineWeight(3);

# RSI 3
input length3 = 14;
input price3 = close;
input averageType3 = AverageType.WILDERS;
input agg3 = AggregationPeriod.WEEK;


def c3 = close(period = agg3);

def NetChgAvg3 = MovingAverage(averageType3, c3 - c3[1], length3);
def TotChgAvg3 = MovingAverage(averageType3, AbsValue(c3 - c3[1]),length3);
def ChgRatio3 = if TotChgAvg3 != 0 then NetChgAvg3 / TotChgAvg3 else 0;

plot RSI3 = 50 * (ChgRatio3 + 1);


RSI3.DefineColor("Positive and Up", Color.GREEN);
RSI3.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI3.DefineColor("Negative and Down", Color.RED);
RSI3.DefineColor("Negative and Up", Color.DARK_RED);
RSI3.AssignValueColor(if RSI3 >= 50 then if RSI3 > RSI3[1] then RSI3.Color("Positive and Up") else RSI3.Color("Positive and Down") else if RSI3 < RSI3[1] then RSI3.Color("Negative and Down") else RSI3.Color("Negative and Up"));
RSI3.setLineWeight(5);

#addCloud(RSI, RSI2, color.green, color.red);

AyUEam2.png
How can I make my chart exactly look like this? What code I need to use?
Can somebody please help me here?
 
Here is MTF selected RSI label, colored white for each of the 4 symbols in your script.

The image is a AAPL 15min chart with Weekly agg RSI selected for the 4 symbols.

This will display labels showing the RSI value for various timeframes. If over_bought then the color will be red, oversold will be green, and white otherwise.
Hi SleepyZ, Could you make a script that puts these RSI timeframes into a watchlist for a set of stocks?
 
Is there a way to have a MTF RSI label for the upper chart? I would like a label that displays the 5M and 15M RSI on one label. TIA
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
390 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