Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Multiple Layered RSI
Updated December 1, 2021
trending_up
2,898 views
thumb_up
2 thanks given
group
3 followers
forum
4 posts
attach_file
5 attachments
Multiple Layered RSI
February 10th, 2018, 01:31 AM
Clemmons
Posts: 7 since Feb 2018
Thanks Given: 1
Thanks Received: 0
I use 3 FastRSI and 1 SlowRIS layered.
How can I program this into a single ToS Study? No changes from stock studies, just add them into one study.
It works the way I am using it, but it is cumbersome, and value scales do not seem to always align, so a lower value may plot above a higher value. I am hoping that if they are all plotted from the same study, they will correlate values.
Any help would be much appreciated. Thx! Scott
Looks like this:
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
February 13th, 2018, 08:24 AM
Dallas, Texas
Posts: 43 since Jun 2015
Thanks Given: 2
Thanks Received: 32
So it's all the same RSI calculation, just different lengths?
If so, that's easy to accomplish...
declare lower;
input length1 = 14;
input length2 = 9;
input length3 = 5;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
plot OverSold = over_Sold;
plot OverBought = over_Bought;
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));
## Length 1 RSI ##
def NetChgAvg1 = MovingAverage(averageType, price - price[1], length1);
def TotChgAvg1 = MovingAverage(averageType, AbsValue(price - price[1]), length1);
def ChgRatio1 = if TotChgAvg1 != 0 then NetChgAvg1 / TotChgAvg1 else 0;
plot RSI1 = 50 * (ChgRatio1 + 1);
RSI1.DefineColor("OverBought", GetColor(5));
RSI1.DefineColor("Normal", GetColor(7));
RSI1.DefineColor("OverSold", GetColor(1));
RSI1.AssignValueColor(
if RSI1 > over_Bought
then RSI1.color("OverBought")
else if RSI1 < over_Sold
then RSI1.color("OverSold")
else RSI1.color("Normal"));
## Length 2 RSI ##
def NetChgAvg2 = MovingAverage(averageType, price - price[1], length2);
def TotChgAvg2 = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatio2 = if TotChgAvg2 != 0 then NetChgAvg1 / TotChgAvg2 else 0;
plot RSI2 = 50 * (ChgRatio2 + 1);
RSI2.DefineColor("OverBought", GetColor(5));
RSI2.DefineColor("Normal", GetColor(7));
RSI2.DefineColor("OverSold", GetColor(1));
RSI2.AssignValueColor(
if RSI2 > over_Bought
then RSI2.color("OverBought")
else if RSI2 < over_Sold
then RSI2.color("OverSold")
else RSI2.color("Normal"));
## Length 3 RSI ##
def NetChgAvg3 = MovingAverage(averageType, price - price[1], length3);
def TotChgAvg3 = MovingAverage(averageType, AbsValue(price - price[1]), length3);
def ChgRatio3 = if TotChgAvg3 != 0 then NetChgAvg3 / TotChgAvg3 else 0;
plot RSI3 = 50 * (ChgRatio3 + 1);
RSI3.DefineColor("OverBought", GetColor(5));
RSI3.DefineColor("Normal", GetColor(7));
RSI3.DefineColor("OverSold", GetColor(1));
RSI3.AssignValueColor(
if RSI3 > over_Bought
then RSI3.color("OverBought")
else if RSI3 < over_Sold
then RSI3.color("OverSold")
else RSI3.color("Normal"));
scottm
I use 3 FastRSI and 1 SlowRIS layered.
How can I program this into a single
ToS Study? No changes from stock studies, just add them into one study.
It works the way I am using it, but it is cumbersome, and value scales do not seem to always align, so a lower value may plot above a higher value. I am hoping that if they are all plotted from the same study, they will correlate values.
Any help would be much appreciated. Thx! Scott
Looks like this:
February 17th, 2018, 04:45 PM
Clemmons
Posts: 7 since Feb 2018
Thanks Given: 1
Thanks Received: 0
Thanks for the help and guidance! Now I see how to get under the hood and tweek around, and with a little rusty recall of logic and Basic from about a hundred years ago, this is getting fun!
But I've hit a snag: I have a working version in Win10 and Adroid (code and screenshots below), but in Android, colors are not displaying correctly. I've now created a few other custom versions of standard studies that allow me to preset my colors/settings and port it to android, and those are also not displaying correctly.
Are there limits to which "CreateColor(R,G,B)" colors will work on the platform(s)?
Here are screenshots of the RSI4 in use on Win10 and Android, displaying the colors that come up when using the code below. Note that on each of the 3 FastRSI calculations, I have the option to change colors when it is overbought or oversold, but I am only using it on the first FastRSI. I am using CreateColor(r,g,b) for color settings.
##RSI4##
declare lower;
input length1 = 6;
input length2 = 13;
input length3 = 26;
input price = ohlc4;
input averageType = AverageType.WILDERS;
input emaLength = 6;
input rsiLength = 13;
input over_bought = 80;
input over_sold = 20;
##Slow RSI##
def ema = ExpAverage(ohlc4, emaLength);
def netChgAvg = WildersAverage(ohlc4 - ema, rsiLength);
def totChgAvg = WildersAverage(AbsValue(ohlc4 - ema), rsiLength);
def chgRatio = if totChgAvg != 0 then netChgAvg / totChgAvg else 0;
plot SlowRSI = 50 * (chgRatio + 1);
plot OverBought = over_bought;
plot MiddleLine = 50;
plot OverSold = over_sold;
SlowRSI.SetDefaultColor(CreateColor(255,153,0));
SlowRSI.SetStyle(Curve.LONG_DASH);
SlowRSI.SetLineWeight(2);
OverBought.SetDefaultColor(CreateColor(255,0,0));
MiddleLine.SetDefaultColor(CreateColor(255,204,0));
MiddleLine.SetStyle(Curve.SHORT_DASH);
OverSold.SetDefaultColor(CreateColor(153,0,255));
#####
## Length 1 RSI ##
def NetChgAvg1 = MovingAverage(averageType, price - price[1], length1);
def TotChgAvg1 = MovingAverage(averageType, AbsValue(price - price[1]), length1);
def ChgRatio1 = if TotChgAvg1 != 0 then NetChgAvg1 / TotChgAvg1 else 0;
plot RSI1 = 50 * (ChgRatio1 + 1);
RSI1.DefineColor("OverBought1",(CreateColor(255,255,0)));
RSI1.SetLineWeight(2);
RSI1.DefineColor("Normal1", (CreateColor(0,255,0)));
RSI1.DefineColor("OverSold1", (CreateColor(255,255,0)));
RSI1.AssignValueColor(
if RSI1 > over_Bought
then RSI1.color("OverBought1")
else if RSI1 < over_Sold
then RSI1.color("OverSold1")
else RSI1.color("Normal1"));
## Length 2 RSI ##
def NetChgAvg2 = MovingAverage(averageType, price - price[1], length2);
def TotChgAvg2 = MovingAverage(averageType, AbsValue(price - price[1]), length2);
def ChgRatio2 = if TotChgAvg2 != 0 then NetChgAvg2 / TotChgAvg2 else 0;
plot RSI2 = 50 * (ChgRatio2 + 1);
RSI2.DefineColor("OverBought2", (CreateColor(0,255,255)));
RSI2.DefineColor("Normal2", (CreateColor(0,255,255)));
RSI2.DefineColor("OverSold2", (CreateColor(0,255,255)));
RSI2.AssignValueColor(
if RSI2 > over_Bought
then RSI2.color("OverBought2")
else if RSI2 < over_Sold
then RSI2.color("OverSold2")
else RSI2.color("Normal2"));
## Length 3 RSI ##
def NetChgAvg3 = MovingAverage(averageType, price - price[1], length3);
def TotChgAvg3 = MovingAverage(averageType, AbsValue(price - price[1]), length3);
def ChgRatio3 = if TotChgAvg3 != 0 then NetChgAvg3 / TotChgAvg3 else 0;
plot RSI3 = 50 * (ChgRatio3 + 1);
RSI3.DefineColor("OverBought3", (CreateColor(255,0,255)));
RSI3.DefineColor("Normal3", (CreateColor(255,0,255)));
RSI3.DefineColor("OverSold3", (CreateColor(255,0,255)));
RSI3.AssignValueColor(
if RSI3 > over_Bought
then RSI3.color("OverBought3")
else if RSI3 < over_Sold
then RSI3.color("OverSold3")
else RSI3.color("Normal3"));
#####
Win10 with correct colors
Android with incorrect colors
February 17th, 2018, 04:59 PM
Clemmons
Posts: 7 since Feb 2018
Thanks Given: 1
Thanks Received: 0
One of my custom studies displays correctly on both Win10 and Android and it is also using the CreateColor(R,G,B) format.
I did restrict it to basic core colors shown below and it does not have if>then color changes for the same plot.
Code Snippet showing colors:
RS1.SetDefaultColor(CreateColor(255, 0, 0));
RS2.SetDefaultColor(CreateColor(255, 255, 0));
RS3.SetDefaultColor(CreateColor(0, 255, 0));
RS4.SetDefaultColor(CreateColor(0, 0, 255));
RS5.SetDefaultColor(CreateColor(255, 0, 204));
November 30th, 2021, 09:57 PM
San Antonio, Texas
Posts: 1 since Aug 2021
Thanks Given: 0
Thanks Received: 0
Hello Scott,
Do you happen to have the TOS code for your Ribbon MA5? Thanks in advance.
Last Updated on November 30, 2021