Relative Price Oscillator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
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.



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)
 
Billions

Billions

Active member
2019 Donor
VIP
@BenTen Does this work on lower time frames also
 
mc01439

mc01439

Well-known member
2019 Donor
VIP
@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:

Similar threads

Top