.

Perfect Earning System Modified - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

Perfect Earning System Modified

_SECTION_BEGIN("Price");
Col_1 = IIf(EMA(RSI(5),3) > EMA(RSI(5),34),colorGreen,colorOrange);
Plot( C, "", col_1, styleCandle+styleThick ); 
_SECTION_END();

_SECTION_BEGIN("guppy");
e3 = EMA(Close,3);
e10 = EMA(Close,10);
e45 = EMA(Close,45);
e60 = EMA(Close,60);
Buy_guppy = e10>e60 AND e3 > e45 AND e10 > e45;
Sell_guppy = e60 > e10 AND e3 < e45 AND e10 < e45;


_SECTION_BEGIN("rsi de ema");

Buy_rsi = EMA(RSI(21),3)> EMA(RSI(21),34);
Sell_rsi= EMA(RSI(21),34) >EMA(RSI(21),3); 

_SECTION_END();

_SECTION_BEGIN("pivot cross");
/*
piv4 = (H+L+C+Ref(H,-1)+Ref(L,-1)+Ref(C,-1)+Ref(H,-2)+Ref(L,-2)+Ref(C,-2)+Ref(H,-3)+Ref(L,-3)+Ref(C,-3))/12;
piv10 =(H+L+C+Ref(H,-1)+Ref(L,-1)+Ref(C,-1)+Ref(H,-2)+Ref(L,-2)+Ref(C,-2)+Ref(H,-3)+Ref(L,-3)+Ref(C,-3)+Ref(H,-4)+Ref(L,-4)+Ref(C,-4)+Ref(H,-5)+Ref(L,-5)+Ref(C,-5)  
+Ref(H,-6)+Ref(L,-6)+Ref(C,-6)+Ref(H,-7)+Ref(L,-7)+Ref(C,-7)+Ref(H,-8)+Ref(L,-8)+Ref(C,-8)+Ref(H,-9)+Ref(L,-9)+Ref(C,-9))/30;
*/
P1 = Param("PERIOD FOR PIVOT MA",10,2,50,1);
//piv4 = (MA(C,4)+MA(H,4) + MA(L,4))/3;
piv10 = (MA(C,P1)+MA(H,P1) + MA(L,P1))/3;
//Plot(piv4,"",colorRed,styleThick);
//Plot(piv10,"",colorBlue,styleThick);
_SECTION_END();


_SECTION_BEGIN("Tops and bottom");

pd = Param("Periods",13,5,144,1); 
pds = 2*pd-1;//     (Adjustment for Wilders MA) 
aa = Close-Ref(Close,-1); 
uu = EMA(Max(0,aa),pds); 
dd=  EMA((Max(0,0-aa)),pds); 

rf = IIf(C>2,1000,10000); 

c1 = Param("Upper Level",70,50,90,1); 
qq1 =100/(100-c1)-1; 
ff1 = qq1*dd-uu; 
ff2 = ff1/qq1; 
f1 = Max(ff1,ff2); 
UL = Close + f1*(pds-1)/2; 
UL = IIf(UL>C,floor(UL*rf),ceil(UL*rf))/rf; 

c2 = Param("Equilibrium",50,50,50,0);  
qq2 =100/(100-c2)-1;// [=1] 
ff = dd-uu; 
MM = Close + ff*(pds-1)/2; 
MM = IIf(MM>C,floor(MM*rf),ceil(MM*rf))/rf; 
Plot(mm,"",colorBlue,styleThick);
c3 = Param("Lower Level",30,10,50,1); 
qq3 =100/(100-c3)-1; 
ff1 = qq3*dd-uu; 
ff2 = ff1/qq3; 
f3 = Min(ff1,ff2); 
LL = Close + f3*(pds-1)/2; 
LL = IIf(LL>C,floor(LL*rf),ceil(LL*rf))/rf; 

band = Param("band width",4,0,15,0.25);
mmu = MM+band;
mmd = MM-band;


X=Cross( C,LL);
Y=Cross(UL,C);

Buy1= X ;
Sell1= Y ;

PlotShapes(shapeCircle*Buy1,colorRed,0,L,-15);
PlotShapes(shapeCircle*Sell1,colorGreen,0,H,-15);

Filter=Buy1 OR Sell1 ;
AddTextColumn(FullName(),"Name");
AddColumn(Buy1,"Buy");
AddColumn(Sell1,"sell");


dist = 1.5*ATR(10); 

/*
for( i = 0; i < BarCount; i++ ) 
{ 

if( Buy_guppy[i] ) PlotText( "Buy @ \n"+C[i] , i, L[ i ]-dist[i], colorBlack,colorGreen ); 
if( Sell_guppy[i] ) PlotText( "Sell@ \n"+C[i], i, H[ i ]+dist[i], colorBlack, colorRed ); 
//if( Buy[i] ) PlotText( "B" , i, L[ i ]-dist[i], colorBlack,colorGreen ); 
//if( Sell[i] ) PlotText( "S" , i, H[ i ]+dist[i], colorBlack, colorRed ); 
if( Sell1[i] ) PlotText( "Top" , i, H[ i ]+dist[i], colorGreen, colorBlack ); 
if( Buy1[i] ) PlotText( "Bottom", i, L[ i ]-dist[i], colorRed, colorBlack ); 
 

}  


*/
_SECTION_END();
SellPrice=ValueWhen(Sell_guppy,C,1);
BuyPrice=ValueWhen(Buy_guppy,C,1);
Long=Flip(Buy_guppy,Sell_guppy);
Shrt=Flip(Sell_guppy,Buy_guppy );

_SECTION_BEGIN("Pivot calc");

TimeFrameSet( in15Minute*2 ); 
DH=Ref(H,-1); 
DL=Ref(L,-1);
DC=Ref(C,-1);


pd = ( DH+ DL + DC )/3;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL); 
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);

TimeFrameRestore();

_SECTION_END();


Title = 
EncodeColor(colorWhite)+ "Perfect Earning System" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) 
+ EncodeColor(colorWhite) +  "  - " + Date() +" - "
+"\n" 

+EncodeColor(colorYellow) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+ "Cl-"+C+"  "+ "Vol= "+ WriteVal(V)
//+ WriteIf ((e3>e45) ,EncodeColor(colorLime)+ "      Direction : LONG",EncodeColor(colorRed)+"      Direction : SHORT")
+"\n" 
+ WriteIf (Sell_guppy , " EXIT LONG / Reverse Signal at "+C+"\n","")
+ WriteIf (Buy_guppy , " EXIT SHORT / Reverse Signal at "+C+"\n","")

+WriteIf(Sell_guppy , "Total Profit / Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy_guppy  , "Total Profit / Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy_guppy,EncodeColor(colorLime)+  "Trade : Long - Entry price Rs."+(BuyPrice)+" Tgt : "+UL,"")+
WriteIf(shrt AND NOT Sell_guppy,EncodeColor(colorRed)+ "Trade : Short - Entry price Rs."+(SellPrice)+" Tgt : "+LL,"")+"\n"+ 
WriteIf(Long AND NOT Buy_guppy, "Current Profit / Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell_guppy, "Current Profit / Loss Rs."+(SellPrice-C)+"","")
+ EncodeColor(colorGreen)+   "\n R3 : "+ EncodeColor(colorWhite)+RD3
+ EncodeColor(colorGreen)+   "\n R2 : "+ EncodeColor(colorWhite)+RD2
+ EncodeColor(colorGreen)+   "\n R1 : "+ EncodeColor(colorWhite)+RD1 + EncodeColor(colorGreen)+  "     UP TGT   : "+ EncodeColor(colorWhite)+UL
+ EncodeColor(colorBlue)+   "\n Pivot : "+ EncodeColor(colorWhite)+pd+ EncodeColor(colorBlue)+   "     MIDPOINT : "+ EncodeColor(colorWhite)+MM
+ EncodeColor(colorRed)+   "\n S1 : "+ EncodeColor(colorWhite)+SD1   + EncodeColor(colorRed)+    "     BOT TGT  : "+ EncodeColor(colorWhite)+LL
+ EncodeColor(colorRed)+   "\n S2 : "+ EncodeColor(colorWhite)+SD2
+ EncodeColor(colorRed)+   "\n S3 : "+ EncodeColor(colorWhite)+SD3
;

_SECTION_BEGIN("KPL");
//AFL by Kamalesh Langote. Email:kpl@vfmdirect.com
no=Param( "Swing", 5, 1, 55 );
tsl_col=colorViolet;

res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase);

Buy=Cross(C,tsl);
Sell=Cross(tsl,C);
shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,tsl_col,tsl_col),0,IIf(Buy,Low,High));
_SECTION_END();

_SECTION_BEGIN("TSKPAutoStop");
Plot( E_TSKPAUTOSTOP(High,Low,Close) , _DEFAULT_NAME(), ParamColor( "Color", colorYellow ), ParamStyle("Style",style=styleNoLabel, mask=maskDefault)); 
_SECTION_END();
Previous Post Next Post