NexusFi: Find Your Edge


Home Menu

 





PRICE_RSI_OSC for TOS


Discussion in ThinkOrSwim

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




 
Search this Thread

PRICE_RSI_OSC for TOS

  #1 (permalink)
alagrande
glendale ca usa
 
Posts: 97 since Sep 2017
Thanks Given: 11
Thanks Received: 88

#PRICE_RSI_OSC
declare lower;


input length30 = 24;

input over_Bought30 = 70;

input over_Sold30 = 30;


input averageType30 = AverageType.WILDERS;

def NetChgAvg30 = MovingAverage(averageType30, close - close[1], length30);
def TotChgAvg30 = MovingAverage(averageType30, AbsValue(close - close[1]), length30);
def ChgRatio30 = if TotChgAvg30 != 0 then NetChgAvg30 / TotChgAvg30 else 0;
plot RSI30 = 50 * (ChgRatio30 + 1);
#plot OverSold30 = over_Sold30;
#plot


RSI30.DefineColor("OverBought", Color.RED);

RSI30.DefineColor("Normal", GetColor(8));

RSI30.DefineColor("OverSold", Color.CYAN);

RSI30.AssignValueColor(if RSI30 > over_Bought30 then RSI30.color("OverBought") else if RSI30 < over_Sold30 then
RSI30.color("OverSold") else RSI30.color("Normal"));
#OverSold30.SetDefaultColor(GetColor(8));
#OverBough30.SetDefaultColor(GetColor(8));

RSI30.SetLineWeight(1);


plot linea = 50;
linea.SetStyle (Curve.LONG_DASH);
linea.SetDefaultColor(Color.GRAY);
#============================================

#declare lower;

input length = 24;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input RSI_smoothing_averageType = AverageType.exponential;
input RSI_smoothing_length = 10;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);
plot OverSold = over_Sold;
plot OverBought = over_Bought;

plot RSI_moving_average = MovingAverage(RSI_smoothing_averageType, RSI, RSI_smoothing_length);

RSI_moving_average.DefineColor("OverBought", GetColor(5));
RSI_moving_average.DefineColor("Normal", GetColor(7));
RSI_moving_average.DefineColor("OverSold", GetColor(1));
RSI_moving_average.AssignValueColor(if RSI > over_Bought then RSI_moving_average.color("OverBought") else if RSI < over_Sold then RSI_moving_average.color("OverSold") else RSI_moving_average.color("Normal"));
OverSold.SetDefaultColor(GetColor(8));
OverBought.SetDefaultColor(GetColor(8));

addcloud(RSI30, RSI_moving_average, color.green, color.red);

#plot UpSignal = if RSI < RSI_moving_average and RSI_moving_average<50 then OverSold else Double.NaN;
#plot DownSignal = if RSI > RSI_moving_average and RSI_moving_average>50 then OverBought else Double.NaN;



##==================================================

#input price = close;
input length2 = 14;
input length3 = 5;
input RSI_smoothing_length2 = 3;
input RSI_smoothing_averageType2 = AverageType.exponential;

def CP = ExpAverage(Sign(price - price[1]) * price, length2);
def TC = ExpAverage(price, length2);

#def PZO = 90 * CP / TC+50;
def PZO = 30 * CP / TC+50;


plot RSI_moving_average2 = MovingAverage(RSI_smoothing_averageType2, PZO, RSI_smoothing_length2);
RSI_moving_average2.setDefaultColor(color.magenta);

plot P = WildersSmoothing(PZO, length3);
P.setDefaultColor(color.white);
addcloud(RSI_moving_average2, P, color.green, color.red);


plot UpSignal = if RSI < RSI_moving_average and RSI_moving_average<50 then 70 else Double.NaN;
plot DownSignal = if RSI > RSI_moving_average and RSI_moving_average>50 then 70 else Double.NaN;


UpSignal.SetDefaultColor(Color.RED);
UpSignal.SetPaintingStrategy(PaintingStrategy.SQUARES);
UpSignal.setLineWeight(2);
DownSignal.SetDefaultColor(Color.DARK_GREEN);
DownSignal.SetPaintingStrategy(PaintingStrategy.SQUARES);
DownSignal.setLineWeight(2);
#=====
#plot UpSignal2 = if RSI_moving_average2 < P then OverSold else Double.NaN;
#plot DownSignal2 = if RSI_moving_average2 > P then OverBought else Double.NaN;
plot UpSignal2 = if RSI_moving_average2 < P then 70 else Double.NaN;
plot DownSignal2 = if RSI_moving_average2 > P then 70 else Double.NaN;


UpSignal2.SetDefaultColor(Color.YELLOW);
UpSignal2.SetPaintingStrategy(PaintingStrategy.SQUARES);
UpSignal2.setLineWeight(4);
DownSignal2.SetDefaultColor(Color.GREEN);
DownSignal2.SetPaintingStrategy(PaintingStrategy.SQUARES);
DownSignal2.setLineWeight(4);



#plot linea2 = 10;
#linea2.SetStyle (Curve.LONG_DASH);
#linea2.SetDefaultColor(Color.GRAY);
#=================================

Reply With Quote
Thanked by:




Last Updated on September 23, 2018


© 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