Relative Price Oscillator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Here is a new experimental indicator we've been working on. The idea was to compare two EMA's of period midpoints to the actual closing price. The steps that were taken are listed below:
  1. Calculate an EMA based on each period's midpoint ((High * Low) /2) for the last 9 periods.
  2. Calculate an EMA based on each period's midpoint for the last 100 periods.
  3. Divide the difference of the two EMA's by the closing price. ((EMA1 - EMA2) / Close).
  4. Smooth the value from step #3 with an 18 period EMA . Multiply by 1000 for better scaling/visibility.
Using:
  • Bullish when line is green, bearish when line is red. Buy on first green, then sell on first red.

LzfFkbf.png

ptMLDif.png


thinkScript Code

Code:
#
# RelativePriceOscillator (RPO)
# Assembled by Kory Gill (@korygill) for BenTen at useThinkScript.com
# Original idea: https://www.tradingview.com/script/FxV2WEhX-Relative-Price-Oscillator/
#

declare lower;
declare once_per_bar;

input lenFast = 9; #Hint lenFast: Length of Fast EMA
input lenSlow = 100; #Hint lenSlow: Length of Slow EMA
input lenSmooth = 18; #Hint lenFast: Length of Smoothing EMA
input ColorCandles = no; #Hint ColorCancles: Color cancles based on RPO color
def vHL2 = hl2;
def vClose = close;

def fast = MovingAverage(AverageType.EXPONENTIAL, vHL2, lenFast);
def slow = MovingAverage(AverageType.EXPONENTIAL, vHL2, lenSlow);
def diff = (fast - slow) / vClose;
def smoothedDiff = MovingAverage(AverageType.EXPONENTIAL, diff, lenSmooth);
def bullish = smoothedDiff >= smoothedDiff[1];

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.YELLOW);

plot RPO = smoothedDiff;
RPO.AssignValueColor(if bullish then Color.GREEN else Color.RED);

AssignPriceColor(if ColorCandles then RPO.TakeValueColor() else Color.CURRENT);

# END - RelativePriceOscillator (RPO)
 
@BenTen Does this work on lower time frames also

@Billions - if you are going to use for lower time frames I would add a super smoother to it. Then subtract the indicator from the super smoother and use the difference to confirm your entries. I would not use as a stand alone.

As an example - you could use SLIM Ribbon, Absolute Strength and some type of price moving average to begin your testing with. I have found mid-point moving averages work well as the price MA.
 
Last edited:

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
238 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