NexusFi: Find Your Edge


Home Menu

 





RSI - Thinkscript question...


Discussion in ThinkOrSwim

Updated
    1. trending_up 6,367 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?
What broker to use for trading palladium futures
Commodities
REcommedations for programming help
Sierra Chart
Cheap historycal L1 data for stocks
Stocks and ETFs
Quantum physics & Trading dynamics
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #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