NexusFi: Find Your Edge


Home Menu

 





RSI - Thinkscript question...


Discussion in ThinkOrSwim

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




 
Search this Thread

RSI - Thinkscript question...

  #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?
Exit Strategy
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Futures True Range Report
The Elite Circle
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts