I have recently visited the Market Gauge website to gain some really good insight into the overall market structure. I took interest in their Real Motion indicator as a way to use momentum of price and compare it to price. They provide several formulas and a nice description of how the indicator is supposed to function. I then decided to code my own version of this indicator and see if I could replicate the results. Please take a look at the code submitted and let me know what you think. The only challenge I am facing is applying the standard deviation to the fast average (blue line). It is supposed to be set at 1 SD while the upper chart uses a 20 period 2 SD bollinger band. In order to get it to match the most current RealMotion of SPY, I have it set at 50 length with 2 SD. Other than that, I think it is nearly spot on. Enjoy!
https://marketgauge.com/charts/bv/bv-chart22a-mktwx.jpg
Code:
# RealMotion indicator based off of description from Market Gauge website.
#//RealMotion indicator as explained by Market Gauge
#//"The brown dots are a dot plot of the individual values of the RealMotion variable.
#//Essentially, they divide the equity price by the moving average of that price (here 200 period).
#//We then subtract one and multiply that value by 100.
#//This centers the indicator at zero (when price = moving average then RealMotion will equal zero).
#//Furthermore, by multiplying by 100 we make it so that when RealMotion = 5.0
#//we can say that the price is 5% greater than the reference moving average."
#PrimaryAveragePlot=Average[PrimaryAverage](close)
#RealMotion=(close/PrimaryAveragePlot - 1)*100
declare lower;
input lengthfast = 50;
input lengthslow = 200;
input averageType = AverageType. SIMPLE;
def pAVERAGE = movingaverage(averageType, close, lengthslow);
def rMOTION = (close / pAVERAGE -1) * 100;
def sAVG = movingaverage(averageType,rMOTION, lengthslow);
def fAVG = movingaverage(averageType,rMOTION, lengthfast);
plot RM = rMOTION;
plot AVGs = sAVG;
plot AVGf = fAVG;
plot zeroline = 0;
zeroline.setDefaultColor(color.white);
def price = rMOTION;
input displace = 0;
input length = 50;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
def sDev = StDev(price, length);
plot MidLine = AVGf;
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;
LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
https://marketgauge.com/charts/bv/bv-chart22a-mktwx.jpg
Last edited: