@horserider I have tried several ways but keep getting errors by extracting just the midline and using in an upper study. Suggestions?
Thanks
Thanks
@chillc15 Not sure what you are trying to accomplish making it an upper study. The midline is moving average of the RSI. The midline thus cannot be extracted as it requires the RSI for calculation of the midline values. I do not believe it can be done. Maybe someone has the solution. Sorry I do not.
# Ultimate RSI stripped down to plot the midline of the average of the RSI.
# Make sure Left Axis is checked in study settings.
# Horserider 1/7/2019 On request from chillc15 after learning use of left axis.
#RSI
input length = 5;
input price = close;
input averageType = AverageType.WILDERS;
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 RSI avg;
input AverageTypeBB = {default SMA, EMA, HMA};
input displaceBB = 0;
input lengthBB = 5;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
plot midline ;
switch (AverageTypeBB) {
case SMA:
midline = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up).Midline;
case EMA:
midline = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).Midline;
case HMA:
midline = reference BollingerBands(RSI, displaceBB, lengthBB, Num_Dev_Dn, Num_Dev_up, averageType = AverageType.EXPONENTIAL).Midline;
}
midline.setdefaultColor(getColor(3));
Not sure why this got moved to the thread above? Any admin able to assist?Hi there, new to the forum and have spent a chunk of time searching for a solution but haven't been able to find anything. —
I'm trying to add a 2 Standard deviation channel to an RSI indicator (or really any indicator) in Thinkorswim that has a 2 day look back period on a 5 min chart.
I also have a 5 period exponential moving average based on the RSI tool plotted. All I need now is to add a the linear regression channel with 1 and 2 standard deviations. Easy right? lol
any help will be greatly appreciated, thank you!
declare lower;
#RSI
input length = 5;
input price = close;
input averageType = AverageType.WILDERS;
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;
plot RSI = 50 * (ChgRatio + 1);
#
RSI.DefineColor("Positive and Up", Color.GREEN);
RSI.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI.DefineColor("Negative and Down", Color.RED);
RSI.DefineColor("Negative and Up", Color.DARK_RED);
RSI.AssignValueColor(if RSI >= 50 then if RSI > RSI[1] then RSI.Color("Positive and Up") else RSI.Color("Positive and Down") else if RSI < RSI[1] then RSI.Color("Negative and Down") else RSI.Color("Negative and Up"));
#plot 5;
input AverageTypeBB = {default SMA};
input displaceBB = 0;
input lengthBB = 5;
plot midline ;
midline = reference BollingerBands(RSI, displaceBB, lengthBB, averageType = AverageType.SIMPLE).Midline;
midline.SetDefaultColor(GetColor(3));
plot MiddleLR = InertiaAll(midline );
def dist = HighestAll(AbsValue(MiddleLR - midline )) * 0.6;
plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;
MiddleLR.SetDefaultColor(GetColor(1));
UpperLR.SetDefaultColor(GetColor(1));
LowerLR.SetDefaultColor(GetColor(1));
# RSI with Linear Regression_Channels
# Horserider 2/5/2020
declare lower;
#RSI
input length = 5;
input price = close;
input averageType = AverageType.WILDERS;
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;
plot RSI = 50 * (ChgRatio + 1);
#
RSI.DefineColor("Positive and Up", Color.GREEN);
RSI.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI.DefineColor("Negative and Down", Color.RED);
RSI.DefineColor("Negative and Up", Color.DARK_RED);
RSI.AssignValueColor(if RSI >= 50 then if RSI > RSI[1] then RSI.Color("Positive and Up") else RSI.Color("Positive and Down") else if RSI < RSI[1] then RSI.Color("Negative and Down") else RSI.Color("Negative and Up"));
# LRC
input multi1 = .3;
input multi2 = .6;
plot MiddleLR = InertiaAll(RSI);
def dist = HighestAll(AbsValue(MiddleLR - RSI )) * multi1;
def dist2 = HighestAll(AbsValue(MiddleLR - RSI )) * multi2;
plot UpperLR = MiddleLR + dist;
plot LowerLR = MiddleLR - dist;
plot UpperLR2 = MiddleLR + dist2;
plot LowerLR2 = MiddleLR - dist2;
MiddleLR.SetDefaultColor(GetColor(1));
UpperLR.SetDefaultColor(GetColor(1));
LowerLR.SetDefaultColor(GetColor(1));
UpperLR2.SetDefaultColor(GetColor(2));
LowerLR2.SetDefaultColor(GetColor(2));
# RSI with Standard Deviation_Channels
# Horserider 2/5/2020
declare lower;
#RSI
input length = 5;
input price = close;
input averageType = AverageType.WILDERS;
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;
plot RSI = 50 * (ChgRatio + 1);
#
RSI.DefineColor("Positive and Up", Color.GREEN);
RSI.DefineColor("Positive and Down", Color.DARK_GREEN);
RSI.DefineColor("Negative and Down", Color.RED);
RSI.DefineColor("Negative and Up", Color.DARK_RED);
RSI.AssignValueColor(if RSI >= 50 then if RSI > RSI[1] then RSI.Color("Positive and Up") else RSI.Color("Positive and Down") else if RSI < RSI[1] then RSI.Color("Negative and Down") else RSI.Color("Negative and Up"));
####################################
input deviations1 = 1.0;
input deviations2 = 2.0;
def regression;
def stdDeviation;
regression = InertiaAll(RSI);
stdDeviation = StDevAll(RSI);
plot UpperLine = regression + deviations1 * stdDeviation;
plot MiddleLine = regression;
plot LowerLine = regression - deviations1 * stdDeviation;
plot UpperLine2 = regression + deviations2 * stdDeviation;
plot LowerLine2 = regression - deviations2 * stdDeviation;
#########################################
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Ultimate RSI [LuxAlgo] for ThinkOrSwim | Indicators | 12 | ||
The Ultimate Buy and Sell Indicator for ThinkOrSwim | Indicators | 5 | ||
P | Ultimate MACD For ThinkOrSwim | Indicators | 16 | |
Ultimate Bullish Cross using Price Momentum and Volume For SwingTrading | Indicators | 26 | ||
YungTrader's Ultimate Indicator | Indicators | 685 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.