STARC Bands on RSI For ThinkOrSwim

hashy

Member
I'm having trouble creating a "STARC Bands ON RSI" indicator and was hoping maybe someone will be willing to help. Instead of having STARC Bands (default ToS study) up on price, I want it combined with RSI on a lower study.
 
Last edited by a moderator:
I'm having trouble creating a "STARC Bands ON RSI" indicator and was hoping maybe someone will be willing to help. Instead of having STARC Bands (default ToS study) up on price, I want it combined with RSI on a lower study. I've tried various things to no avail, such as modifying Mobius' Bollinger Bands on RSI scrip (below). I found a TradingView version (also below), but I'm not good enough to convert it (I have tried and tried, but can't get it right). ANY help is greatly appreciated.

Mobius RSI with Standard Dev bands
Code:
# Mobius©: # RSI with Standard Deviation bands

declare lower;

# Inputs:

input Price = Close;

input RSIPeriod = 14;

input BBLength = 50;

input SD = 2.1;

 

# vars:

plot UpperBand;

plot LowerBand;

plot PctBrsia;

plot rsia;

rsia = reference RSI(length = RSIPeriod, Price = Price);

UpperBand = reference BollingerBands(price = rsia,

displace = 0,

length = BBLength,

Num_Dev_Dn = -SD,

Num_Dev_up = SD).UpperBand;

LowerBand = reference BollingerBands(price = rsia,

displace = 0,

length = BBLength,

Num_Dev_Dn = -SD,

Num_Dev_up = SD).LowerBand;

PctBrsia = (rsia - LowerBand) / (UpperBand - LowerBand);

plot Plot1 = PctBrsia;

plot Plot2 = 0;

plot Plot3 = 1;

#09:32 Mobius©: you can get rid of the Plot2 and Plot3 and put the PctBrsia into a label.

TradingView script: https://www.tradingview.com/script/7h99DbXp-Volatitity-Bands-STARC-on-RSI-for-reversal-warning-beta/
Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dep0tyoxxx

//@version=4
study("STARC on RSI",overlay = false) //Volatilty bands, modified for RSI by Constance Brown, formualrs according to
                                      //the book "Technical Analysis for the Trading Professional", 2nd edition, by Constance Brown; slightl modified; see below.
fctup = input (defval=2.3, type=input.float,title="factorUp", step=0.1)
fctdwn = input (defval=2.1, type=input.float,title="factorDown", step=0.1 )
float trRSI = abs(rsi(close,14)-rsi(close[1],14))   // In the original here an atr with 3times rsi,14 is mentioned, instead of high, low and close[-1]
float atrRSI = sma(trRSI,15)                        //The idea to create high, low and close for RSI with intraday doesnt work,
                                                   //because the length of the rsi refers to the new horizon then and differs from Daily RSI.
float Rup = sma(rsi(close,14),6)+(fctup*atrRSI)
float Rdwn = sma(rsi(close,14),6)-(fctdwn*atrRSI)
float Rrsi = rsi(close,14)

float alert = na
float alertup = na
float alertdwn = na
alertup:= crossover(Rrsi,Rup)?Rrsi:na
float countu =0
countu:=alertup>0?0:countu[1]+1
alertdwn:= crossunder(Rrsi,Rdwn)?Rrsi:na
float countd = 0
countd:=alertdwn>0?0:countd[1]+1
plot (Rup,color=color.lime)
plot (Rdwn,color=color.fuchsia)
plot (Rrsi,color=color.aqua)
//plotchar(alertup, location=location.absolute,size=size.tiny,color=color.green)
//plotchar(alertdwn, location=location.absolute,size=size.tiny,color=color.red)

float pivrup=pivothigh(Rup,5,1)
float pivrdwn=pivotlow(Rdwn,5,1)
float revup =na//means reversal from up; new direction:down
float revdwn =na
revup:=Rup[1]==pivrup?Rup[1]:na
revdwn:=Rdwn[1]==pivrdwn?Rdwn[1]:na
//plotchar(revup, location=location.absolute,size=size.tiny,color=color.purple,offset=-1)

float trigru =na
trigru:=revup>0 and countu<15 and (Rrsi*0.98)<Rup?Rup:na
plotshape(trigru, style=shape.triangledown,location=location.absolute,size=size.tiny,color=color.orange,offset=-1)

float trigrdn =na
trigrdn:=revdwn>0 and countd<15 and (Rrsi*0.98)>Rdwn?Rdwn:na
plotshape(trigrdn, style=shape.triangleup,location=location.absolute, size=size.tiny,color=color.green,offset=-1)

See if this helps. It may or may not be correct or useful as I have no basis to test it against.

The main problem in the code you provided from TradingView was with the ATR portion of the code as I did also. I used a different method than in that code by the use of the definitions of h, l, and c;

Higher agg charts seem to be more interesting.

Capture.jpg
Ruby:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2022
#
declare lower;
declare weak_volume_dependency;

def h = reference rsi(price=high);
def l = reference rsi(price=low);
def c = reference rsi(price=close);

input ATR_length = 15;
input SMA_length = 6;
input displace = 0;
input multiplier_factor = 2.0;

def val = Average(c, sma_length);

def average_true_range = Average(TrueRange(h, c, l), length = atr_length);

plot rsi = reference rsi();
rsi.setdefaultColor(color.white);
rsi.setpaintingStrategy(paintingStrategy.LINE_VS_TRIANGLES);

plot Upper_Band = val[-displace] + multiplier_factor * average_true_range[-displace];
Upper_Band.SetDefaultColor(GetColor(0));

plot Middle_Band = val[-displace];
Middle_Band.SetDefaultColor(GetColor(1));

plot Lower_Band = val[-displace] - multiplier_factor * average_true_range[-displace];
Lower_Band.SetDefaultColor(GetColor(0));
 
See if this helps. It may or may not be correct or useful as I have no basis to test it against.

The main problem in the code you provided from TradingView was with the ATR portion of the code as I did also. I used a different method than in that code by the use of the definitions of h, l, and c;

Higher agg charts seem to be more interesting.
I really really appreciate the help! Thank you so much
 

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