i'm just going to throw this in here since it relates to the other McGinley thread. the code comes from mobius. i haven't seen the indicator talked about anywhere else.
Mobius: when McGinley PercentB crosses above 0 set at 3 St Deviations and it's ATR set at 2 and the Zero Lag MACD set at 5,13,3 crosses above 0 it's a very high percentage positive trade
oh, and here's the zero lag MACD that mobius refers to:
Mobius: when McGinley PercentB crosses above 0 set at 3 St Deviations and it's ATR set at 2 and the Zero Lag MACD set at 5,13,3 crosses above 0 it's a very high percentage positive trade
Code:
# McGinley PercentB
#it's price relative to an upper and lower standard deviation band. 100 top of bands 0 bottom of bands.
#Make it 3 standard deviations and 2 ATR's and you effectively capture 99% of the data maintaining the better squeeze signals
#and giving pretty clear buy signals on lower aggregations such as 5 min
# Mobius
# A better PercentB
# V01.2014
declare lower;
input I = close;
input N = 20;
input SDmult = 2.0;
input KCmult = 1.5;
def o;
def h;
def l;
def c;
def D;
def SD;
def ATR;
def MidLine;
def UpperBB;
def UpperKC;
def LowerBB;
def lowerKC;
o = open;
h = high;
l = low;
c =close;
plot PercentB;
D = CompoundValue(1, D[1] + (I - D[1]) / N * (Power((I / D[1]), 4)), I);
SD = StDev(I, N);
ATR = Average(TrueRange(h, c, l), N);
MidLine = D;
UpperBB = D + (SDmult * SD);
UpperKC = D + (KCmult * ATR);
LowerBB = D + (-SDmult * SD);
LowerKC = D + (-KCmult * ATR);
PercentB = 100 * ((I - LowerBB) / (UpperBB - LowerBB));
PercentB.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
PercentB.SetLineWeight(2);
PercentB.AssignValueColor(if PercentB Crosses above 0
then Color.Yellow
else if UpperBB < UpperKC
then Color.Blue
else if PercentB < 0
then Color.Red
else Color.Cyan);
AddLabel(D crosses above 0, "Crossing Above 0", Color.Yellow);
AddLabel(UpperBB < UpperKC, "Squeeze", Color.Blue);
AddLabel(D < 0, "Less Than 0", Color.Red);
# End Code McGinley PercentB
#end
##################
oh, and here's the zero lag MACD that mobius refers to:
Code:
# Super Zero Lag MACD
# Mobius
declare lower;
input Fast_Length = 5;
input Slow_Length = 13;
input MACD_Length = 3;
plot MACD5 = (MACD("fast length" = Fast_Length,
"slow length" = Slow_Length,
"macd length" = MACD_Length).Avg /
StDev(MACD("fast length" = Fast_Length,
"slow length" = Slow_Length,
"macd length" = MACD_Length).Diff, Slow_Length));
MACD5.SetDefaultColor(Color.CYAN);
plot Squeeze = if BollingerBandsSMA().UpperBand < KeltnerChannels().Upper_Band
then 0
else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
Squeeze.SetLineWeight(3);
Squeeze.SetDefaultColor(Color.GREEN);
plot zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;
zero.SetPaintingStrategy(PaintingStrategy.POINTS);
zero.SetLineWeight(2);
zero.SetDefaultColor(Color.BLUE);
AddCloud(zero, MACD5, Color.RED, Color.GREEN);
AddCloud(Squeeze, MACD5, Color.RED, Color.GREEN);
AddLabel(!IsNaN(Squeeze), "Squeeze", if MACD5 > MACD5[1] and
MACD5 < 0
then Color.GREEN
else Color.RED);
def day = GetValue(GetYYYYMMDD(), 1);
def trend = if close > (Highest(high, 21) + Lowest(low, 21)) / 2
then 1
else 0;
AddLabel(1, if trend == 1
then "Trend Up"
else "Trend Dn",
if trend == 1
then Color.Green
else Color.Red);
Last edited by a moderator: