# McGinley PercentB MACD Setup For ThinkOrSwim

#### floydddd

##### Active member
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

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(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);
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;
then "Trend Up"
else "Trend Dn",
if trend == 1
then Color.Green
else Color.Red);``````

Last edited by a moderator:

87k+ Posts
150 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?