Trader4TOS
Member
New Release Version 1.3! 08-08-23 https://usethinkscript.com/threads/rsi-levels-for-thinkorswim.15867/post-129692
I hope you enjoy this one. The changes aren't dramatic but still very helpful. I look forward to everyone's feedback.
I hope you enjoy this one. The changes aren't dramatic but still very helpful. I look forward to everyone's feedback.
- Customizable Inputs: The indicator allows users to customize the RSI length, SMA length, overbought level, and oversold level. This flexibility enables users to adapt the indicator to different trading strategies and market conditions.
- RSI and SMA Plotting: The indicator plots the RSI line and the lagging 9-period Simple Moving Average (SMA) line. The RSI line represents the calculated RSI values, while the SMA line provides a smoothed version of the RSI.
- Overbought and Oversold Levels: The indicator plots the overbought and oversold levels as horizontal lines. These levels indicate potential reversal points or extreme market conditions. The default levels are set at 85 for overbought and 15 for oversold, but they can be customized.
- Enhanced Overbought/Oversold Levels: The indicator also includes additional enhanced overbought/oversold levels to provide more nuanced information. These levels include moderately overbought/oversold levels (70 and 30), heavily overbought/oversold levels (85 and 15), and extremely overbought/oversold levels (100 and 1).
- Visual Customization: The indicator allows for the customization of colors and line weights for the plotted lines, making it visually adaptable to individual preferences.
Ruby:
# RSI Levels Indicator version 1.0 created by Trader4TOS 06/21/2023
# In this slightly enhanced version of RSI. Then 9 SMA has been added in conjunction with the RSI line to give you foresight of trend changes upon crossing each other. Also added three levels of oversold and overbought graded color codes. I added a customization menu for all the features.
input price = close;
input rsiLength = 14;
input smaLength = 9;
input overboughtLevel = 85;
input oversoldLevel = 15;
# Customizable Inputs
def enableCustomInputs = yes;
def customRsiLength = if enableCustomInputs then 14 else rsiLength;
def customSmaLength = if enableCustomInputs then 9 else smaLength;
def customOverboughtLevel = if enableCustomInputs then 85 else overboughtLevel;
def customOversoldLevel = if enableCustomInputs then 15 else oversoldLevel;
# Calculate RSI
def netChgAvg = MovingAverage(AverageType.WILDERS, price - price[1], customRsiLength);
def totChgAvg = MovingAverage(AverageType.WILDERS, AbsValue(price - price[1]), customRsiLength);
def chgRatio = if totChgAvg != 0 then netChgAvg / totChgAvg else 0;
def rsiValue = Round(50 * (chgRatio + 1), 0);
# Calculate lagging 9-period SMA
def smaValue = reference SimpleMovingAvg(rsiValue, customSmaLength);
# Plot RSI and SMA
plot rsiLine = rsiValue;
rsiLine.SetDefaultColor(Color.YELLOW);
rsiLine.SetLineWeight(2);
plot smaLine = smaValue;
smaLine.SetDefaultColor(Color.BLUE);
smaLine.SetLineWeight(2);
# Plot overbought and oversold levels
plot overbought = customOverboughtLevel;
overbought.SetDefaultColor(Color.RED);
overbought.SetLineWeight(2);
plot oversold = customOversoldLevel;
oversold.SetDefaultColor(Color.GREEN);
oversold.SetLineWeight(2);
# Enhanced Overbought/Oversold Levels
def moderatelyOverboughtLevel = 70;
def moderatelyOversoldLevel = 30;
def heavilyOverboughtLevel = 85;
def heavilyOversoldLevel = 15;
def extremelyOverboughtLevel = 100;
def extremelyOversoldLevel = 1;
# Plot enhanced levels
plot ModeratelyOverbought = moderatelyOverboughtLevel;
ModeratelyOverbought.SetDefaultColor(Color.DARK_ORANGE);
ModeratelyOverbought.SetLineWeight(2);
plot ModeratelyOversold = moderatelyOversoldLevel;
ModeratelyOversold.SetDefaultColor(Color.LIGHT_GREEN);
ModeratelyOversold.SetLineWeight(2);
plot HeavilyOverbought = heavilyOverboughtLevel;
HeavilyOverbought.SetDefaultColor(Color.RED);
HeavilyOverbought.SetLineWeight(2);
plot HeavilyOversold = heavilyOversoldLevel;
HeavilyOversold.SetDefaultColor(Color.GREEN);
HeavilyOversold.SetLineWeight(2);
plot ExtremelyOverbought = extremelyOverboughtLevel;
ExtremelyOverbought.SetDefaultColor(Color.DARK_RED);
ExtremelyOverbought.SetLineWeight(3);
plot ExtremelyOversold = extremelyOversoldLevel;
ExtremelyOversold.SetDefaultColor(Color.DARK_GREEN);
ExtremelyOversold.SetLineWeight(3);
Last edited: