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:
Using:
- Calculate an EMA based on each period's midpoint ((High * Low) /2) for the last 9 periods.
- Calculate an EMA based on each period's midpoint for the last 100 periods.
- Divide the difference of the two EMA's by the closing price. ((EMA1 - EMA2) / Close).
- Smooth the value from step #3 with an 18 period EMA . Multiply by 1000 for better scaling/visibility.
- 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)