Ultimate RSI [LuxAlgo] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
60XRl0E.png


Author Message : - With Diversions

The Ultimate RSI indicator is a new oscillator based on the calculation of the Relative Strength Index that aims to put more emphasis on the trend, thus having a less noisy output. Opposite to the regular RSI, this oscillator is designed for a trend trading approach instead of a contrarian one.

CODE:
CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
#// © LuxAlgo
#indicator("Ultimate RSI [LuxAlgo]", "LuxAlgo - Ultimate RSI")
# Converted and mod by Sam4Cok@Samer800    - 09/2023

declare lower;

input length = 14;
input method = {EMA, SMA, default RMA, TMA};    # 'Method'
input Source = close;                           # 'Source'
input smooth = 14;                              # 'Signal Line'
input smoothingType = {default EMA, SMA,  RMA, TMA}; # 'Signal Line'
input Overbought = 80;        # 'Overbought'
input Oversold   = 20;        # 'Oversold    '

def na = Double.NaN;
def last = isNaN(close);
#//Functions
script ma {
    input x = close;
    input len = 14;
    input maType = "TMA";
    def ma = if maType == "EMA" then ExpAverage(x, len) else
             if maType == "SMA" then Average(x, len) else
             if maType == "RMA" then WildersAverage(x, len) else
             if maType == "TMA" then Average(Average(x, len), len) else ma[1];
    plot out = ma;
}
#//Augmented RSI
def upper = Highest(Source, length);
def lower = Lowest(Source, length);
def r = upper - lower;

def d = Source - Source[1];
def diff = if upper > upper[1] then r else
           if lower < lower[1] then -r else d;
def absDiff = AbsValue(diff);
def num = ma(diff, length, method);
def den = ma(absDiff, length, method);
def arsi = num / den * 50 + 50;

def signal = ma(arsi, smooth, smoothingType);

def css = if arsi > Overbought then 1 else
          if arsi < Oversold then -1 else 0;

def max = max(signal,Overbought);
def min = min(signal,Oversold);

#//Plots
plot plot_rsi = arsi;#, 'Ultimate RSI'
plot_rsi.AssignValueColor(if css > 0 then Color.GREEN else
                          if css < 0 then Color.RED else Color.GRAY);

plot SigLine = signal;#, 'Signal Line'
SigLine.SetDefaultColor(GetColor(2));
#//Levels
plot plot_up = if last then na else Overbought;
plot plot_avg = if last then na else 50;
plot plot_dn = if last then na else Oversold;

plot_up.SetDefaultColor(Color.DARK_GRAY);
plot_avg.SetDefaultColor(Color.DARK_GRAY);
plot_dn.SetDefaultColor(Color.DARK_GRAY);
plot_up.SetStyle(Curve.SHORT_DASH);
plot_avg.SetStyle(Curve.SHORT_DASH);
plot_dn.SetStyle(Curve.SHORT_DASH);
#//OB-OS
AddCloud(if css > 0 then plot_rsi else na, plot_up, Color.DARK_GREEN);
AddCloud(if css < 0 then plot_dn else na, plot_rsi, Color.DARK_RED);

AddCloud(if css > 0 then plot_rsi else na, max, Color.GREEN);
AddCloud(if css < 0 then min else na, plot_rsi, Color.RED);

#----Div-----------
input ShowLastDivLines = yes;
input ShowLastHiddenDivLines = no;
input DivBull = no;      # "Plot Bullish"
input DivBear = no;      # "Plot Bearish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
input LookBackRight  = 5; # "Pivot Lookback Right"
input LookBackLeft  = 5;  # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"

def divSrc = signal;

def h = high;
def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL + 1 and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL + 1 and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
        def bars = if cond then 0 else bars[1] + 1;
        def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
plot retrun = inRange;
}
def pl_ = findpivots(divSrc,-1, LookBackLeft, LookBackRight);
def ph_ = findpivots(divSrc, 1, LookBackLeft, LookBackRight);
def pl = !isNaN(pl_);
def ph = !isNaN(ph_);
def pll = lowest(divSrc,LookBackLeft);
def phh = highest(divSrc,LookBackLeft);
def sll = lowest(l, LookBackLeft);
def shh = highest(h, LookBackLeft);
#-- Pvt Low
def plStart  = if pl then yes else plStart[1];
def plFound  = if (plStart and pl) then 1 else 0;
def vlFound1 = if plFound then divSrc else vlFound1[1];
def vlFound_ = if vlFound1!=vlFound1[1] then vlFound1[1] else vlFound_[1];
def vlFound  = if !vlFound_ then pll else vlFound_;
def plPrice1 = if plFound then l else plPrice1[1];
def plPrice_ = if plPrice1!=plPrice1[1] then plPrice1[1] else plPrice_[1];
def plPrice  = if !plPrice_ then sll else plPrice_;
#-- Pvt High
def phStart = if ph then yes else phStart[1];
def phFound = if (phStart and ph) then 1 else 0;
def vhFound1 = if phFound then divSrc else vhFound1[1];
def vhFound_ = if vhFound1!=vhFound1[1] then vhFound1[1] else vhFound_[1];
def vhFound = if !vhFound_ then phh else vhFound_;
def phPrice1 = if phFound then h else phPrice1[1];
def phPrice_ = if phPrice1!=phPrice1[1] then phPrice1[1] else phPrice_[1];
def phPrice = if !phPrice_ then sll else phPrice_;
#// Regular Bullish
def inRangePl = _inRange(plFound[1],MaxLookback,MinLookback);
def oscHL = divSrc > vlFound and inRangePl;
def priceLL = l < plPrice and divSrc <= 40;
def bullCond = plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and inRangePl;
def priceHL = l > plPrice and divSrc <= 50;
def hiddenBullCond = plFound and oscLL and priceHL;
#// Regular Bearish
def inRangePh = _inRange(phFound[1],MaxLookback,MinLookback);
def oscLH   = divSrc < vhFound and inRangePh;
def priceHH = h > phPrice and divSrc >= 60;;
def bearCond = phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and inRangePh;
def priceLH = h < phPrice and divSrc >= 50;
def hiddenBearCond = phFound and oscHH and priceLH;

#------ Bubbles
def bullBub  = DivBull and bullCond;
def HbullBub = DivHiddenBull and hiddenBullCond;
def bearBub  = DivBear and bearCond;
def HbearBub = DivHiddenBear and hiddenBearCond;

addchartbubble(bullBub, divSrc, "R", color.GREEN, no);
addchartbubble(bearBub, divSrc, "R", CreateColor(156,39,176), yes);
addchartbubble(HbullBub, divSrc, "H", color.DARK_green, no);
addchartbubble(HbearBub, divSrc, "H", color.DARK_red, yes);

##### Lines
def bar = BarNumber();
#-- Bear Line
def lastPhBar = if ph then bar else lastPhBar[1];
def prePhBar = if lastPhBar!=lastPhBar[1] then lastPhBar[1] else prePhBar[1];
def priorPHBar = if bearCond then prePhBar else priorPHBar[1];
#-- Bull Line
def lastPlBar = if pl then bar else lastPlBar[1];
def prePlBar = if lastPlBar!=lastPlBar[1] then lastPlBar[1] else prePlBar[1];
def priorPLBar = if bullCond then prePlBar else priorPLBar[1];


def lastBullBar = if bullCond then bar else lastBullBar[1];
def lastBearBar = if bearCond then bar else lastBearBar[1];

def HighPivots = ph and bar >= HighestAll(priorPHBar) and bar <= HighestAll(lastBearBar);
def LowPivots  = pl and bar >= HighestAll(priorPLBar) and bar <= HighestAll(lastBullBar);

def pivotHigh = if HighPivots then divSrc else na;
def pivotLow  = if LowPivots  then divSrc else na;

plot PlotHline = if ShowLastDivLines then pivotHigh else na;
PlotHline.EnableApproximation();
PlotHline.SetDefaultColor(Color.MAGENTA);

plot PlotLline = if ShowLastDivLines then pivotLow else na;
PlotLline.EnableApproximation();
PlotLline.SetDefaultColor(Color.CYAN);

#--- Hidden Lines
#-- Bear Line
def priorHPHBar = if hiddenBearCond then prePhBar else priorHPHBar[1];
#-- Bull Line
def priorHPLBar = if hiddenBullCond then prePlBar else priorHPLBar[1];

def lastHBullBar = if hiddenBullCond then bar else lastHBullBar[1];
def lastHBearBar = if hiddenBearCond then bar else lastHBearBar[1];

def HighHPivots = ph and bar >= HighestAll(priorHPHBar) and bar <= HighestAll(lastHBearBar);
def LowHPivots  = pl and bar >= HighestAll(priorHPLBar) and bar <= HighestAll(lastHBullBar);

def pivotHidHigh = if HighHPivots then divSrc else na;
def pivotHidLow  = if LowHPivots  then divSrc else na;

plot PlotHBearline = if ShowLastHiddenDivLines then pivotHidHigh else na;
PlotHBearline.EnableApproximation();
PlotHBearline.SetDefaultColor(Color.DARK_RED);

plot PlotHBullline = if ShowLastHiddenDivLines then pivotHidLow else na;
PlotHBullline.EnableApproximation();
PlotHBullline.SetDefaultColor(Color.DARK_GREEN);


#-- END of CODE
 
Just wanted to say thanks for the conversion.
As a W%R guy, this is the first RSI study I use that's easy to read at a glance.

Used this the last couple of months and has kept me both out of trouble and profitable.
Swing trader. Mainly trade EOD using Daily and Weekly charts.

Permanent addition to my charts.
 
Hey @MerryDay @BenTen @samer800

I have a very interesting idea on this indicator here. Is it possible to scan for when the grey line crosses the pink line when this is above the 80 zone and below the 20 zone? Looks like actually a very powerful strategy if it is possible.

Edit: Another scan idea is if the grey line cross below the 80 and above the 20 line.
 
Hey @MerryDay @BenTen @samer800

I have a very interesting idea on this indicator here. Is it possible to scan for when the grey line crosses the pink line when this is above the 80 zone and below the 20 zone? Looks like actually a very powerful strategy if it is possible.

Edit: Another scan idea is if the grey line cross below the 80 and above the 20 line.
see the scan below. select you want long or short signals at the end of the code

CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
#// © LuxAlgo
#indicator("Ultimate RSI [LuxAlgo]", "LuxAlgo - Ultimate RSI")
# scanner by Sam4Cok@Samer800    - 02/2024


input length = 14;
input method = {EMA, SMA, default RMA, TMA};    # 'Method'
input Source = close;                           # 'Source'
input smooth = 14;                              # 'Signal Line'
input smoothingType = {default EMA, SMA,  RMA, TMA}; # 'Signal Line'
input Overbought = 80;        # 'Overbought'
input Oversold   = 20;        # 'Oversold????'

def na = Double.NaN;
def last = isNaN(close);
#//Functions
script ma {
    input x = close;
    input len = 14;
    input maType = "TMA";
    def ma = if maType == "EMA" then ExpAverage(x, len) else
             if maType == "SMA" then Average(x, len) else
             if maType == "RMA" then WildersAverage(x, len) else
             if maType == "TMA" then Average(Average(x, len), len) else ma[1];
    plot out = ma;
}
#//Augmented RSI
def upper = Highest(Source, length);
def lower = Lowest(Source, length);
def r = upper - lower;

def d = Source - Source[1];
def diff = if upper > upper[1] then r else
           if lower < lower[1] then -r else d;
def absDiff = AbsValue(diff);
def num = ma(diff, length, method);
def den = ma(absDiff, length, method);
def arsi = num / den * 50 + 50;

def signal = ma(arsi, smooth, smoothingType);

def css = if arsi > Overbought then 1 else
          if arsi < Oversold then -1 else 0;

def max = max(signal,Overbought);
def min = min(signal,Oversold);
def crossDn = if arsi < signal and arsi > Overbought then crossDn[1] + 1 else 0;
def crossUp = if arsi > signal and arsi < Oversold then crossUp[1] + 1 else 0;

#plot short = crossDn== 2 within 3 bars;
plot long = crossUp==2 within 3 bars;

#-- remove/add # key from above
 
Just wanted to say thanks for the conversion.
As a W%R guy, this is the first RSI study I use that's easy to read at a glance.

Used this the last couple of months and has kept me both out of trouble and profitable.
Swing trader. Mainly trade EOD using Daily and Weekly charts.

Permanent addition to my charts.
How do you use it? can you add examples. Many thanks.
 
60XRl0E.png


Author Message : - With Diversions

The Ultimate RSI indicator is a new oscillator based on the calculation of the Relative Strength Index that aims to put more emphasis on the trend, thus having a less noisy output. Opposite to the regular RSI, this oscillator is designed for a trend trading approach instead of a contrarian one.

CODE:
CSS:
#// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International
#// © LuxAlgo
#indicator("Ultimate RSI [LuxAlgo]", "LuxAlgo - Ultimate RSI")
# Converted and mod by Sam4Cok@Samer800    - 09/2023

declare lower;

input length = 14;
input method = {EMA, SMA, default RMA, TMA};    # 'Method'
input Source = close;                           # 'Source'
input smooth = 14;                              # 'Signal Line'
input smoothingType = {default EMA, SMA,  RMA, TMA}; # 'Signal Line'
input Overbought = 80;        # 'Overbought'
input Oversold   = 20;        # 'Oversold    '

def na = Double.NaN;
def last = isNaN(close);
#//Functions
script ma {
    input x = close;
    input len = 14;
    input maType = "TMA";
    def ma = if maType == "EMA" then ExpAverage(x, len) else
             if maType == "SMA" then Average(x, len) else
             if maType == "RMA" then WildersAverage(x, len) else
             if maType == "TMA" then Average(Average(x, len), len) else ma[1];
    plot out = ma;
}
#//Augmented RSI
def upper = Highest(Source, length);
def lower = Lowest(Source, length);
def r = upper - lower;

def d = Source - Source[1];
def diff = if upper > upper[1] then r else
           if lower < lower[1] then -r else d;
def absDiff = AbsValue(diff);
def num = ma(diff, length, method);
def den = ma(absDiff, length, method);
def arsi = num / den * 50 + 50;

def signal = ma(arsi, smooth, smoothingType);

def css = if arsi > Overbought then 1 else
          if arsi < Oversold then -1 else 0;

def max = max(signal,Overbought);
def min = min(signal,Oversold);

#//Plots
plot plot_rsi = arsi;#, 'Ultimate RSI'
plot_rsi.AssignValueColor(if css > 0 then Color.GREEN else
                          if css < 0 then Color.RED else Color.GRAY);

plot SigLine = signal;#, 'Signal Line'
SigLine.SetDefaultColor(GetColor(2));
#//Levels
plot plot_up = if last then na else Overbought;
plot plot_avg = if last then na else 50;
plot plot_dn = if last then na else Oversold;

plot_up.SetDefaultColor(Color.DARK_GRAY);
plot_avg.SetDefaultColor(Color.DARK_GRAY);
plot_dn.SetDefaultColor(Color.DARK_GRAY);
plot_up.SetStyle(Curve.SHORT_DASH);
plot_avg.SetStyle(Curve.SHORT_DASH);
plot_dn.SetStyle(Curve.SHORT_DASH);
#//OB-OS
AddCloud(if css > 0 then plot_rsi else na, plot_up, Color.DARK_GREEN);
AddCloud(if css < 0 then plot_dn else na, plot_rsi, Color.DARK_RED);

AddCloud(if css > 0 then plot_rsi else na, max, Color.GREEN);
AddCloud(if css < 0 then min else na, plot_rsi, Color.RED);

#----Div-----------
input ShowLastDivLines = yes;
input ShowLastHiddenDivLines = no;
input DivBull = no;      # "Plot Bullish"
input DivBear = no;      # "Plot Bearish"
input DivHiddenBull = no; # "Plot Hidden Bullish"
input DivHiddenBear = no; # "Plot Hidden Bearish"
input LookBackRight  = 5; # "Pivot Lookback Right"
input LookBackLeft  = 5;  # "Pivot Lookback Left"
input MaxLookback = 60;   # "Max of Lookback Range"
input MinLookback = 5;    # "Min of Lookback Range"

def divSrc = signal;

def h = high;
def l = low;

script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !isNaN(dat) and lbr > 0 and lbl > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat,-a) else dat < GetValue(dat,-a) else _nan;
   if (HL > 0) {
        _V = if _BN > lbL + 1 and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL + 1 and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}
#_inRange(cond) =>
script _inRange {
    input cond = yes;
    input rangeUpper = 60;
    input rangeLower = 5;
        def bars = if cond then 0 else bars[1] + 1;
        def inrange =  (rangeLower <= bars) and (bars <= rangeUpper);
plot retrun = inRange;
}
def pl_ = findpivots(divSrc,-1, LookBackLeft, LookBackRight);
def ph_ = findpivots(divSrc, 1, LookBackLeft, LookBackRight);
def pl = !isNaN(pl_);
def ph = !isNaN(ph_);
def pll = lowest(divSrc,LookBackLeft);
def phh = highest(divSrc,LookBackLeft);
def sll = lowest(l, LookBackLeft);
def shh = highest(h, LookBackLeft);
#-- Pvt Low
def plStart  = if pl then yes else plStart[1];
def plFound  = if (plStart and pl) then 1 else 0;
def vlFound1 = if plFound then divSrc else vlFound1[1];
def vlFound_ = if vlFound1!=vlFound1[1] then vlFound1[1] else vlFound_[1];
def vlFound  = if !vlFound_ then pll else vlFound_;
def plPrice1 = if plFound then l else plPrice1[1];
def plPrice_ = if plPrice1!=plPrice1[1] then plPrice1[1] else plPrice_[1];
def plPrice  = if !plPrice_ then sll else plPrice_;
#-- Pvt High
def phStart = if ph then yes else phStart[1];
def phFound = if (phStart and ph) then 1 else 0;
def vhFound1 = if phFound then divSrc else vhFound1[1];
def vhFound_ = if vhFound1!=vhFound1[1] then vhFound1[1] else vhFound_[1];
def vhFound = if !vhFound_ then phh else vhFound_;
def phPrice1 = if phFound then h else phPrice1[1];
def phPrice_ = if phPrice1!=phPrice1[1] then phPrice1[1] else phPrice_[1];
def phPrice = if !phPrice_ then sll else phPrice_;
#// Regular Bullish
def inRangePl = _inRange(plFound[1],MaxLookback,MinLookback);
def oscHL = divSrc > vlFound and inRangePl;
def priceLL = l < plPrice and divSrc <= 40;
def bullCond = plFound and oscHL and priceLL;
#// Hidden Bullish
def oscLL = divSrc < vlFound and inRangePl;
def priceHL = l > plPrice and divSrc <= 50;
def hiddenBullCond = plFound and oscLL and priceHL;
#// Regular Bearish
def inRangePh = _inRange(phFound[1],MaxLookback,MinLookback);
def oscLH   = divSrc < vhFound and inRangePh;
def priceHH = h > phPrice and divSrc >= 60;;
def bearCond = phFound and oscLH and priceHH;
#// Hidden Bearish
def oscHH = divSrc > vhFound and inRangePh;
def priceLH = h < phPrice and divSrc >= 50;
def hiddenBearCond = phFound and oscHH and priceLH;

#------ Bubbles
def bullBub  = DivBull and bullCond;
def HbullBub = DivHiddenBull and hiddenBullCond;
def bearBub  = DivBear and bearCond;
def HbearBub = DivHiddenBear and hiddenBearCond;

addchartbubble(bullBub, divSrc, "R", color.GREEN, no);
addchartbubble(bearBub, divSrc, "R", CreateColor(156,39,176), yes);
addchartbubble(HbullBub, divSrc, "H", color.DARK_green, no);
addchartbubble(HbearBub, divSrc, "H", color.DARK_red, yes);

##### Lines
def bar = BarNumber();
#-- Bear Line
def lastPhBar = if ph then bar else lastPhBar[1];
def prePhBar = if lastPhBar!=lastPhBar[1] then lastPhBar[1] else prePhBar[1];
def priorPHBar = if bearCond then prePhBar else priorPHBar[1];
#-- Bull Line
def lastPlBar = if pl then bar else lastPlBar[1];
def prePlBar = if lastPlBar!=lastPlBar[1] then lastPlBar[1] else prePlBar[1];
def priorPLBar = if bullCond then prePlBar else priorPLBar[1];


def lastBullBar = if bullCond then bar else lastBullBar[1];
def lastBearBar = if bearCond then bar else lastBearBar[1];

def HighPivots = ph and bar >= HighestAll(priorPHBar) and bar <= HighestAll(lastBearBar);
def LowPivots  = pl and bar >= HighestAll(priorPLBar) and bar <= HighestAll(lastBullBar);

def pivotHigh = if HighPivots then divSrc else na;
def pivotLow  = if LowPivots  then divSrc else na;

plot PlotHline = if ShowLastDivLines then pivotHigh else na;
PlotHline.EnableApproximation();
PlotHline.SetDefaultColor(Color.MAGENTA);

plot PlotLline = if ShowLastDivLines then pivotLow else na;
PlotLline.EnableApproximation();
PlotLline.SetDefaultColor(Color.CYAN);

#--- Hidden Lines
#-- Bear Line
def priorHPHBar = if hiddenBearCond then prePhBar else priorHPHBar[1];
#-- Bull Line
def priorHPLBar = if hiddenBullCond then prePlBar else priorHPLBar[1];

def lastHBullBar = if hiddenBullCond then bar else lastHBullBar[1];
def lastHBearBar = if hiddenBearCond then bar else lastHBearBar[1];

def HighHPivots = ph and bar >= HighestAll(priorHPHBar) and bar <= HighestAll(lastHBearBar);
def LowHPivots  = pl and bar >= HighestAll(priorHPLBar) and bar <= HighestAll(lastHBullBar);

def pivotHidHigh = if HighHPivots then divSrc else na;
def pivotHidLow  = if LowHPivots  then divSrc else na;

plot PlotHBearline = if ShowLastHiddenDivLines then pivotHidHigh else na;
PlotHBearline.EnableApproximation();
PlotHBearline.SetDefaultColor(Color.DARK_RED);

plot PlotHBullline = if ShowLastHiddenDivLines then pivotHidLow else na;
PlotHBullline.EnableApproximation();
PlotHBullline.SetDefaultColor(Color.DARK_GREEN);


#-- END of CODE
Thank you for this interesting indicator. Can you clarify what is the meaning of the bubbles R ad H in the different colors? how should we use them?
 
@samer800, Thank you for posting this code!!! (y)(y)(y)
It has worked great to keep me on the right side of trades!

For anyone interested, I have added the following code to the indicator for my trading:

# Add this at the bottom of samer800’s code if you want an alert to sound when RSI crosses above or below the midline:

Def UpSignal = if arsi crosses above 50 then 1 else Double.NaN;
Def DownSignal = if arsi crosses below 50 then 1 else Double.NaN;

Alert(UpSignal, "Long RSI”, Alert.BAR, Sound.RING);
Alert(DownSignal, "Short RSI”, Alert.BAR, Sound.RING);

# Add this at the bottom of samer800’s code if you want the lower panel to change colors when RSI crosses above or below the midline (h/t @SleepyZ):

DefineGlobalColor("Positive", CreateColor(0, 153, 0));
DefineGlobalColor("Negative", CreateColor(153, 0, 0));

input colorBackground = yes;
def xcolor=if arsi > avg then 1 else 0;
addcloud(if !colorBackground then double.nan
else if xcolor==1
then double.POSITIVE_INFINITY
else double.NEGATIVE_INFINITY,
if xcolor==1
then double.NEGATIVE_INFINITY
else double.POSITIVE_INFINITY,
globalColor("Positive"), globalcolor("Negative"));

Add both at the bottom of samer800’s code if you want both to occur when RSI crosses above or below the midline.

Hope this helps. Good trading!
 
@samer800, Thank you for posting this code!!! (y)(y)(y)
It has worked great to keep me on the right side of trades!

For anyone interested, I have added the following code to the indicator for my trading:

# Add this at the bottom of samer800’s code if you want an alert to sound when RSI crosses above or below the midline:

Def UpSignal = if arsi crosses above 50 then 1 else Double.NaN;
Def DownSignal = if arsi crosses below 50 then 1 else Double.NaN;

Alert(UpSignal, "Long RSI”, Alert.BAR, Sound.RING);
Alert(DownSignal, "Short RSI”, Alert.BAR, Sound.RING);

# Add this at the bottom of samer800’s code if you want the lower panel to change colors when RSI crosses above or below the midline (h/t @SleepyZ):

DefineGlobalColor("Positive", CreateColor(0, 153, 0));
DefineGlobalColor("Negative", CreateColor(153, 0, 0));

input colorBackground = yes;
def xcolor=if arsi > avg then 1 else 0;
addcloud(if !colorBackground then double.nan
else if xcolor==1
then double.POSITIVE_INFINITY
else double.NEGATIVE_INFINITY,
if xcolor==1
then double.NEGATIVE_INFINITY
else double.POSITIVE_INFINITY,
globalColor("Positive"), globalcolor("Negative"));

Add both at the bottom of samer800’s code if you want both to occur when RSI crosses above or below the midline.

Hope this helps. Good trading!

I like the addition of the lower panel coloring!

Do you know if it is possible to color it so:
  • when arsi crosses above plot_avg, it is colored green UNTIL it crosses back below 80, then it is colored grey
  • when arsi crosses below plot_avg, it is colored red UNTIL it crosses back above 20, then it is colored grey

I think this helps to exit into the first sign of diminishing momentum.

I like the addition of the lower panel coloring!

Do you know if it is possible to color it so:
  • when arsi crosses above plot_avg, it is colored green UNTIL it crosses back below 80, then it is colored grey
  • when arsi crosses below plot_avg, it is colored red UNTIL it crosses back above 20, then it is colored grey

I think this helps to exit into the first sign of diminishing momentum.

A simple adjustment that I made that isn't quite like the above is comparing arsi to the signal line.

DefineGlobalColor("Positive", CreateColor(0, 153, 0));
DefineGlobalColor("Negative", CreateColor(153, 0, 0));

input colorBackground = yes;
def xcolor=if arsi > signal then 1 else 0;
addcloud(if !colorBackground then double.nan
else if xcolor==1
then double.POSITIVE_INFINITY
else double.NEGATIVE_INFINITY,
if xcolor==1
then double.NEGATIVE_INFINITY
else double.POSITIVE_INFINITY,
globalColor("Positive"), globalcolor("Negative"));
 
@adriantran, I think you found the solution yourself. ;)

For myself, I like to look for trades in the direction of the trend AFTER it has crossed the “midline.” Other than in those instances, I tend to look for fades. “Buy the Dip - Sell the Rip.” :cool:
 
I like the addition of the lower panel coloring!

Do you know if it is possible to color it so:
  • when arsi crosses above plot_avg, it is colored green UNTIL it crosses back below 80, then it is colored grey
  • when arsi crosses below plot_avg, it is colored red UNTIL it crosses back above 20, then it is colored grey

I think this helps to exit into the first sign of diminishing momentum.



A simple adjustment that I made that isn't quite like the above is comparing arsi to the signal line.

DefineGlobalColor("Positive", CreateColor(0, 153, 0));
DefineGlobalColor("Negative", CreateColor(153, 0, 0));

input colorBackground = yes;
def xcolor=if arsi > signal then 1 else 0;
addcloud(if !colorBackground then double.nan
else if xcolor==1
then double.POSITIVE_INFINITY
else double.NEGATIVE_INFINITY,
if xcolor==1
then double.NEGATIVE_INFINITY
else double.POSITIVE_INFINITY,
globalColor("Positive"), globalcolor("Negative"));
Hi Adrian,
I do not see a gray color on my chart
 

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
480 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