.

# Boon C Peak Accurate Trading System - Amibroker AFL Code

### Click Image To Enlarge. Please Rate And Comment.

```//{BoonC Peak 'n Trough V 1.1}
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))))));

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);