Get all type of tested and working Amibroker afl for free

Boon C Peak The Super Indicator


Boon C Peak The Super Indicator
Boon C Peak The Super Indicator

//www.aflcode.com
//{BoonC Peak 'n Trough V 1.1} 
//{Buy} 
x1=5; x2=4; x3=3; x4=2; x5=1; x6=.5; 
//{Lowest price stock <5} 
AA=IIf(C<5,Cross(C,ValueWhen(Peak(H,x1,1) !=Ref(Peak(H,x1,1),-1),H,1)), 
//{Price between 5 AND 20} 
IIf(C>5 AND C<20,Cross(C,ValueWhen(Peak(H,x2,1) !=Ref(Peak(H,x2,1),-1),H,1)), 
//{Price between 20 AND 70} 
IIf(C>20 AND C<70,Cross(C,ValueWhen(Peak(H,x3,1) !=Ref(Peak(H,x3,1),-1),H,1)), 
//{Price between 70 AND 150} 
IIf(C>70 AND C<150,Cross(C,ValueWhen(Peak(H,x4,1) !=Ref(Peak(H,x4,1),-1),H,1)), 
//{Price between 150 AND 300} 
IIf(C>150 AND C<300,Cross(C,ValueWhen(Peak(H,x5,1) !=Ref(Peak(H,x5,1),-1),H,1)), 
//{Price over 300} 
Cross(C,ValueWhen(Peak(H,x6,1)!=Ref(Peak(H,x6,1),-1),H,1))))))); 

//{Sell } 
x1=5; x2=4; x3=3; x4=2; x5=1; x6=.5; 
//{Lowest price stock <5} 
BB=IIf(C<5,Cross(ValueWhen(Trough(L,x1,1) !=Ref(Trough(L,x1,1),-1),L,1),C), 
//{Price between 5 AND 20} 
IIf(C>5 AND C<20,Cross(ValueWhen(Trough(L,x2,1) !=Ref(Trough(L,x2,1),-1),L,1),C), 
//{Price between 20 AND 70} 
IIf(C>20 AND C<70,Cross(ValueWhen(Trough(L,x3,1) !=Ref(Trough(L,x3,1),-1),L,1),C), 
//{Price between 70 AND 150} 
IIf(C>70 AND C<150,Cross(ValueWhen(Trough(L,x4,1) !=Ref(Trough(L,x4,1),-1),L,1),C), 
//{Price between 150 AND 300} 
IIf(C>150 AND C<300,Cross(ValueWhen(Trough(L,x5,1) !=Ref(Trough(L,x5,1),-1),L,1),C), 
//{Price over 300} 
Cross(ValueWhen(Trough(L,x6,1)!=Ref(Trough(L,x6,1),-1),L,1),C)))))); 

Color=IIf(BarsSince(AA)>BarsSince(BB),colorRed,IIf(RSI()>70,colorCustom1,colorDarkGreen)); 
Plot(C,"",Color,styleCandle); 
///// Trailing Stop Module ///// 

P6=Param("Trailing Stop Risk",2.5,2,3.5,0.1); 
P7=Param("Trailing Stop LookBack",14,5,25,1); 
P8=Param("Trailing Stop PrevLow Switch",0,0,1,1); 
PrevLow=IIf(P8==1, Ref(C,-TroughBars(C,5,1)) ,Null); 
Plot(PrevLow,"",colorRed); 

//Position sizing// 
MyTotalPort = Param("MyTotalPort",1000000,10000,10000000,100000); 
AcceptableRisk = Param("AcceptableRisk",0.5,0.1,3,0.1); 
BarsFromStart = BarsSince(Cross(AA,BB)AND Ref(Color,-1)==colorRed) ; 
InitialStopLoss =Ref( H - P6*ATR(P7),-BarsFromStart); 
PositionSizing = 0.01*AcceptableRisk*MyTotalPort/( C - InitialStopLoss ); 

Plot(IIf( HHV(H - P6*ATR(P7),BarsFromStart+1) <C ,HHV(H - P6*ATR(P7),BarsFromStart+1),Null) ,"",colorBlue,1); 
PlotShapes(shapeDownArrow*Cross(Ref(HHV(H - P6*ATR(P7),BarsFromStart+1),-1),C),colorCustom1,0,H,Offset=-43); 
Title=Name()+" "+Date()+" "+EncodeColor(colorBrown)+"BoonC Peak 'n Trough V 1.1+atr+position"+EncodeColor(colorBlack)+" Vol="+NumToStr(Volume ,1.2)+" "+EncodeColor(1)+"Position Sizing ( " +AcceptableRisk+ "% Risk ) = " + WriteIf(color==colorDarkGreen,NumToStr(PositionSizing ,1.0),"0")+ 
EncodeColor(colorBlue)+"\nO="+O+EncodeColor(colorBrown)+" Pk-Tgh Exit"+EncodeColor(colorCustom1)+" ATR Trailing Exit"+EncodeColor(colorBlack)+" RSI Exit"+EncodeColor(colorBlack)+" ADX = "+ADX()+EncodeColor(colorBlue)+"\nH="+H+"\nL="+L+"\nClose="+ C+""+"\nchange= "+NumToStr((Ref(C,-1)-Close) ,1.2) + 
" "; 
PlotShapes( AA*shapeSmallUpTriangle,colorCustom12,0,L-0.2); 
PlotShapes( BB*shapeHollowSmallDownTriangle,colorCustom12,0,H+0.2); 
GraphXSpace=3;

Previous
Next Post »