OBV_RSI_MA Indicator For ThinkOrSwim

barbaros

Well-known member
OBV_RSI_MA Indicator For ThinkOrSwim
Requested by @AnimalMother. Here is the first attempt.

8GbIdAf.png


Code:
# OBV_RSI_MA
# 20211121 - barbaros
#

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input src = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = yes;

#net volume of positive and negative volume
def obv = if (src - src[1]) > 0 then volume else
if (src - src[1]) < 0 then -volume else 0 * volume;
def cnv = TotalSum(obv); #cumulative net volume
def price = cnv;

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.SetDefaultColor(GetColor(8));

#Moving Averages
input MALength = 8;
input AverageType1 = AverageType.SIMPLE;
input MALength2 = 26;
input AverageType2 = AverageType.SIMPLE;
input MALength3 = 57;
input AverageType3 = AverageType.SIMPLE;
input MALength4 = 180;
input AverageType4 = AverageType.SIMPLE;

# plot the Moving Averages
def MA = MovingAverage(AverageType1, RSI, MALength);
plot pMA = MA;
def MA2 = MovingAverage(AverageType2, RSI, MALength2);
plot pMA2 = MA2;
def MA3 = MovingAverage (AverageType3, RSI, MALength3);
plot pMA3 = MA3;
def MA4 = MovingAverage(AverageType4, RSI, MALength4);
plot pMA4 = MA4;

plot mid = 50;
mid.SetPaintingStrategy(paintingStrategy = PaintingStrategy.DASHES);
mid.AssignValueColor(COLOR.magenta);

plot OverSold = over_Sold;
plot OverBought = over_Bought;
OverBought.SetDefaultColor(GetColor(5));
OverSold.SetDefaultColor(GetColor(5));

plot UpSignal = if pMA3 crosses above mid then mid else Double.NaN;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.SetLineWeight(3);
UpSignal.SetHiding(!showBreakoutSignals);
 
Last edited by a moderator:
OBV_RSI_MA Indicator For ThinkOrSwim
Requested by @AnimalMother. Here is the first attempt.

8GbIdAf.png


Code:
# OBV_RSI_MA
# 20211121 - barbaros
#

declare lower;

input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input src = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = yes;

#net volume of positive and negative volume
def obv = if (src - src[1]) > 0 then volume else
if (src - src[1]) < 0 then -volume else 0 * volume;
def cnv = TotalSum(obv); #cumulative net volume
def price = cnv;

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.SetDefaultColor(GetColor(8));

#Moving Averages
input MALength = 8;
input AverageType1 = AverageType.SIMPLE;
input MALength2 = 26;
input AverageType2 = AverageType.SIMPLE;
input MALength3 = 57;
input AverageType3 = AverageType.SIMPLE;
input MALength4 = 180;
input AverageType4 = AverageType.SIMPLE;

# plot the Moving Averages
def MA = MovingAverage(AverageType1, RSI, MALength);
plot pMA = MA;
def MA2 = MovingAverage(AverageType2, RSI, MALength2);
plot pMA2 = MA2;
def MA3 = MovingAverage (AverageType3, RSI, MALength3);
plot pMA3 = MA3;
def MA4 = MovingAverage(AverageType4, RSI, MALength4);
plot pMA4 = MA4;

plot mid = 50;
mid.SetPaintingStrategy(paintingStrategy = PaintingStrategy.DASHES);
mid.AssignValueColor(COLOR.magenta);

plot OverSold = over_Sold;
plot OverBought = over_Bought;
OverBought.SetDefaultColor(GetColor(5));
OverSold.SetDefaultColor(GetColor(5));

plot UpSignal = if pMA3 crosses above mid then mid else Double.NaN;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.SetLineWeight(3);
UpSignal.SetHiding(!showBreakoutSignals);
Would you have this as a shared file?
 
@AnimalMother
and what advantage do i have using this rather than the old rsi 14?
Recommend you put it on your chart. Nothing beats personal experience ;) The only way you will know what works best for you is to play with the settings and see how the indicator compares to the "old rsi 14" and with your other indicators. To determine if this indicator brings value, analyze it over different timeframes, across history and with multiple instruments.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
480 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top