Reverse MACD-Amibroker

#31
ok, here is code for bb with shaded area:
HTML:
_SECTION_BEGIN("Surrogate");
BarLum1 		= Param("Short TF Bar Color Intensity", 0.1, 0, 1, 0.01);
LineColor 		= ColorBlend(colorBlack, colorWhite, BarLum1);
UpBarColor		= ColorBlend(colorBrightGreen, colorWhite, BarLum1);
DnBarColor		= ColorBlend(colorRed, colorWhite, BarLum1);
Surrogate= Param( "Surrogate", 6, 1,30,1 );
Om=MA(O,Surrogate);
hm=MA(H,Surrogate);
lm=MA(L,Surrogate);
Cm=MA(C,Surrogate);
HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );
BarColor	= IIf(HACLOSE> HaOpen , UpBarColor, DnBarColor);
SetBarFillColor(BarColor);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), LineColor, styleCandle | styleNoLabel );

_SECTION_END();

_SECTION_BEGIN("TriggerLines");
Linreg=Param("linreg",25,0,100,1); 
r=LinearReg(C,Linreg);
e=EMA(r,5);
col = IIf(r > e, colorTurquoise , colorYellow);
Plot(r, "TriggerLine 1", col, styleThick|styleNoLabel);
Plot(e, "TriggerLine 2", col, styleThick|styleNoLabel);
_SECTION_END();

_SECTION_BEGIN(" REVERSING MACD");
gxs=Param("GRAPH spaceing",5,-10,40,1); 
GraphXSpace = gxs;
t1 = Param("fast periods", 12,5, 24, 12);
t2 = Param("slow periods", 26,10, 52, 26);
t3 = Param("signal periods", 9,3, 18, 9);
pick = Param("plot: <1=MACDeq 2=MACDeq0 3=HLC 4=BBands>",1,1,4,1);
a1 = 2/(t1+1);
a2 = 2/(t2+1);
CMACDeq = (Ref(EMA(C,t1)*a1,-1)-Ref(EMA(C,t2)*a2,-1))/(a1-a2);
HMACDeq = (Ref(EMA(H,t1)*a1,-1)-Ref(EMA(H,t2)*a2,-1))/(a1-a2);
LMACDeq = (Ref(EMA(L,t1)*a1,-1)-Ref(EMA(L,t2)*a2,-1))/(a1-a2);
MACDeq0 = Ref(EMA(C,t2)*(1-a2) - EMA(C,t1)*(1-a1),-1)/(a1-a2);
z = LastValue(IIf(pick > 2, 0, Cum(1)+1));
plot1 = IIf(pick==3, HMACDeq, BBandTop(CMACDeq,10,1));
plot2 = IIf(pick==2, MACDeq0, CMACDeq);
plot3 = IIf(pick==3, LMACDeq, BBandBot(CMACDeq,10,1));
Plot(plot1+ Ref(0,z),"HMACDeq",colorGreen,styleLine);
Plot(plot3+ Ref(0,z),"LMACDeq",colorRed,styleLine);
Rmacdcolor=IIf(MACDeq0<= C, ParamColor("Rmacdup", colorGreen),ParamColor("Rmacddn", colorRed));
Plot(plot2,"MACDeq0",Rmacdcolor,styleLine);
Colmacdeq=IIf(C>HMACDeq,colorLime,IIf(C<LMACDeq,colorOrange,colorDarkYellow));
Plot(CMACDeq,"CMACDeq ",colmacdeq,8);
PlotOHLC(plot3 ,plot1 ,plot3 ,plot1 ,"fill",ColorRGB(32,36,66),styleCloud);
_SECTION_END();
Thanks a lot sandek and Kelvin for all the hard work, just modified last line to change the colour of BB shaded area (personal choice :)) as below:

PlotOHLC(plot3 ,plot1 ,plot3 ,plot1 ,"fill",colorLavender,styleCloud);
 
#32
Thanks for the AFL. I tried to scan for stock that may come into buy or sell and apparently that exploration /scanning has not been included in the afl. I am new to Amibroker and would appreciate if my request to include scanning /exploration is built into this code structure.

Thanks in advance.
 
#33
Can somebody guide how to trade using this AFL.
How to use the trigger line,
do we trade when the color of the bar changes etc.

reference to any writeup/posts appreciated
 

Similar threads