
Code:
# Archive Name: McGinley Dynamic Indicator_Mobius
# Archive Section: Trend
# Suggested Tos Name: McGinleyDynamicIndicator_Mobius
# Archive Date: 5.05.2018
# Archive Notes: Lounge 5.02.2018
# 16:59 Mobius: An oldie but goodie
# 17:01 Mobius: The lag on that is only a few bars and that lag can be mostly removed by detrending it by half the input length
# A More Advanced Adaptive Moving Average
# McGinley Dynamic Indicator
# Mobius
# V03.11.2011
# D = D[1] + (I - D[1]) / ( N * (I/D[1])^4)
# where D[1] = yesterday's Dynamic, I = today's price, N = smoothing factor.
input Ih = high;
input Ii = low;
input N = 13;
#High Low Bands added 7/18/2019 by mc01439
#High
def Dh;
Dh = CompoundValue(1, Dh[1] + (Ih - Dh[1]) / (N * Power((Ih / Dh[1]), 4)), Ih);
plot MDIh = Dh;
MDIh.SetPaintingStrategy(PaintingStrategy.LINE);
#MDIh.SetLineWeight(3);
#MDIh.SetDefaultColor(Color.White);
MDIh.DefineColor("Up", CreateColor( 0, 102, 255));
MDIh.DefineColor("Down", CreateColor( 255, 255, 0));
MDIh.SetLineWeight(2);
MDIh.AssignValueColor(if MDIh > MDIh[1] and MDIh[1] > MDIh[2] and MDIh[2] > MDIh[3] and MDIh[3] > MDIh[4] then MDIh.Color("Up") else if MDIh < MDIh[1] and MDIh[1] < MDIh[2] and MDIh[2] < MDIh[3] and MDIh[3] < MDIh[4] then MDIh.Color("Down") else Color.MAGENTA);
#Low
def Di;
Di = CompoundValue(1, Di[1] + (Ii - Di[1]) / (N * Power((Ii / Di[1]), 4)), Ii);
plot MDIi = Di;
MDIi.SetPaintingStrategy(PaintingStrategy.LINE);
#MDIi.SetLineWeight(3);
#MDIi.SetDefaultColor(Color.White);
MDIi.DefineColor("Up", CreateColor( 0, 102, 255));
MDIi.DefineColor("Down", CreateColor( 255, 255, 0));
MDIi.SetLineWeight(2);
MDIi.AssignValueColor(if MDIi > MDIi[1] and MDIi[1] > MDIi[2] and MDIi[2] > MDIi[3] and MDIi[3] > MDIi[4] then MDIi.Color("Up") else if MDIi < MDIi[1] and MDIi[1] < MDIi[2] and MDIi[2] < MDIi[3] and MDIi[3] < MDIi[4] then MDIi.Color("Down") else Color.MAGENTA);
addCloud (MDIh, MDIi, Color.GRAY, Color.GRAY);
# End Code McGinley Dynamic Indicator