Rank: Advanced Member
Groups: Moderators, Registered, Registered Users, Subscribers Joined: 10/8/2010(UTC) Posts: 1,960
Thanks: 92 times Was thanked: 155 time(s) in 150 post(s)
|
Johnny Dough’s article, “Reversing MACD” describes how to
make to all-in-one indicators for AmiBroker and how to use them.
- Tools menu, select New to open the Indicator Editor
for a new indicator.
-
t1:= Input("fast periods", 5, 24, 12);
t2:= Input("slow periods", 10, 52, 26);
pick:= Input("plot: <1=MACDeq 2=MACDeq0 3=HLC
4=BBands>",1,4,1);
a1:= 2/(t1+1);
a2:= 2/(t2+1);
CMACDeq:=(Ref(Mov(C,t1,E)*a1,-1)-Ref(Mov(C,t2,E)*a2,-1))/(a1-a2);
HMACDeq:=(Ref(Mov(H,t1,E)*a1,-1)-Ref(Mov(H,t2,E)*a2,-1))/(a1-a2);
LMACDeq:=(Ref(Mov(L,t1,E)*a1,-1)-Ref(Mov(L,t2,E)*a2,-1))/(a1-a2);
MACDeq0:= Ref(Mov(C,t2,E)*(1-a2) -
Mov(C,t1,E)*(1-a1),-1)/(a1-a2);
z:= LastValue(If(pick > 2, 0, Cum(1)+1));
plot1:= If(pick=3, HMACDeq, BBandTop(CMACDeq,10,S,1));
plot2:= If(pick=2, MACDeq0, CMACDeq);
plot3:= If(pick=3, LMACDeq, BBandBot(CMACDeq,10,S,1));
plot1 + Ref(0,+z);
plot2;
plot3 + Ref(0,+z);
- Ok to close the Indicator Editor.
- New to open the Indicator Editor
for the second indicator.
-
t1:= Input("fast periods", 5, 24, 12);
t2:= Input("slow periods", 10, 52, 26);
t3:= Input("signal periods", 3, 18, 9);
pick:= Input("plot: <1=MACD 2=MACD_HLC
3=MACD_MTF>",1,4,1);
MACDH:=Mov(H,t1,E)-Mov(H,t2,E);
MACDL:=Mov(L,t1,E)-Mov(L,t2,E);
MACDC:=OscP(12,26,E,$);
MTFw:=OscP(12*5,26*5,E,$);
MTFM:=OscP(12*21,26*21,E,$);
y:= LastValue(If(pick <>2, 0, Cum(1)+1));
z:= LastValue(If(pick > 1, 0, Cum(1)+1));
plot1:= MACDC;
plot2:= If(pick=2, MACDH, MTFw);
plot3:= If(pick=2, MACDL, MTFm);
plot4:= Mov(MACDC,t3,E);
plot1;
plot2 + Ref(0,+z);
plot3 + Ref(0,+z);
plot4 + Ref(0,+y);
- Ok to close the Indicator Editor.
- Ok to close the Indicator Builder.
|