NexusFi: Find Your Edge


Home Menu

 





Multiple Layered RSI


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,699 views
    2. thumb_up 2 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 5 attachments




 
Search this Thread
  #1 (permalink)
scottm
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:


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Irans Answer Due Today: Peace Surges to 33.5%, Invasion …
Prediction Markets & Event Contracts
The 50/50 Paradox: Peace and Invasion Each at 20% -- Ira …
Prediction Markets & Event Contracts
Iran Deal "In Review" at 87% on Deadline Day - …
Prediction Markets & Event Contracts
CFTC Approves First US Bitcoin Perpetual Futures -- Kals …
Traders Hideout
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
devildriver6
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 View Post
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:


Reply With Quote
Thanked by:
  #3 (permalink)
scottm
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


Reply With Quote
  #4 (permalink)
scottm
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));





Reply With Quote
  #5 (permalink)
edvela
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.


Reply With Quote




Last Updated on November 30, 2021


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts