NexusFi: Find Your Edge


Home Menu

 





RSI - Thinkscript question...


Discussion in ThinkOrSwim

Updated
    1. trending_up 6,886 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
netarchitech
NY, NY
 
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19

I'm having trouble trying to programmatically add a custom colored "cloud"
a/k/a fill to an RSI study to highlight overbought and oversold conditions as shown below...

FYI, I have been able to successfully plot the shaded overbought (>95) and oversold(<5)
conditions, but I am unable to remove the the unwanted shading between 95 and 5...

Any help/assistance would be greatly appreciated. Thanks in advance...

declare lower;
declare zerobase;

input RSIlength = 2;
input priceH = high;
input priceL = low;
input priceC = close;
input smoothingType = 1;
input over_bought = 95;
input over_sold = 5;

def sf = 1 / RSIlength;

def NetChgAvg = Ema2(data = priceC - priceC[1], prefetch = RSIlength, "smoothing factor" = sf);
def TotChgAvg = Ema2(data = AbsValue(priceC - priceC[1]), prefetch = RSIlength, "smoothing factor" = Sf);

def ChgRatio = if TotChgAvg != 0 then
NetChgAvg / TotChgAvg
else
0;

plot RSI = 50 * (ChgRatio + 1);
RSI.SetDefaultColor(CreateColor(0, 102, 204));
RSI.SetLineWeight(2);

plot OverBought = over_bought;
#OverBought.SetDefaultColor(GetColor(4));
OverBought.hide();

AddCloud(RSI, over_bought, Color.red, Color.red);

plot OverSold = over_sold;
#OverSold.SetDefaultColor(GetColor(4));
OverSold.hide();

AddCloud(RSI, over_sold, Color.red, Color.red);


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Sundays Verdict: Lebanon Locked at 99.85% as Iran June 7 …
Prediction Markets & Event Contracts
CFTC Workforce Shrinks 24% to 15-Year Low While Predicti …
Traders Hideout
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
30 Sessions
21 thanks
Sober Journey With S&P
21 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
netarchitech
NY, NY
 
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19

Since my previous post was my fourth, I was unable to post an image to go with the code example, which does a much better job of illustrating what I am trying to accomplish. Hopefully, with this, my fifth post, you should be able to view the image...


Reply With Quote
  #3 (permalink)
netarchitech
NY, NY
 
Posts: 68 since Dec 2011
Thanks Given: 27
Thanks Received: 19


I worked it out with a little help from a ThinkScripter. Below is the final script for any/all interested parties to review...

declare lower;
declare zerobase;

input RSIlength = 2;
input KPeriod = 14;
input DPeriod = 3;
input priceH = high;
input priceL = low;
input priceC = close;
input smoothingType = 1;
input over_bought = 95;
input over_sold = 5;


def sf = 1 / RSIlength;

def NetChgAvg = Ema2(data = priceC - priceC[1], prefetch = RSIlength, "smoothing factor" = sf);
def TotChgAvg = Ema2(data = AbsValue(priceC - priceC[1]), prefetch = RSIlength, "smoothing factor" = Sf);

def ChgRatio = if TotChgAvg != 0 then
NetChgAvg / TotChgAvg
else
0;

plot RSI = 50 * (ChgRatio + 1);
RSI.SetDefaultColor(CreateColor(0, 102, 204));
RSI.SetLineWeight(2);

plot OverBought = over_bought;
#OverBought.SetDefaultColor(GetColor(4));
OverBought.hide();

AddCloud(if RSI>=95 then RSI else double.nan, over_bought, Color.yellow, Color.yellow);

plot OverSold = over_sold;
#OverSold.SetDefaultColor(GetColor(4));
OverSold.hide();

AddCloud(if RSI<=5 then RSI else double.nan, over_sold, Color.yellow, Color.yellow);


Reply With Quote
Thanked by:




Last Updated on January 12, 2015


© 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