Skip to main content

suktam pivot based buy-sell for Amibroker (AFL)

navin about 14 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 5)
  • Tags:
    trading system, amibroker, optimize

It is simple last day pivot base buy-sell signle afl-code,optimize it for your selected stock give good result,
author….Navin patel

Indicator / Formula

Copy & Paste Friendly
SetPositionSize( 2000, spsShares ); // 2000 shares by default 
_SECTION_BEGIN("camarilla levels");
//---- pivot points
DayH = TimeFrameGetPrice("H", inDaily, -1);		// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);		//				low
DayC = TimeFrameGetPrice("C", inDaily, -1);		//				close
DayO = TimeFrameGetPrice("O", inDaily,-1);			// current day open
// camarilla pivots
if ( True )
{
A =  Optimize("X",Param("A",0.17,0.1,1,0.01),0.1,1,0.01);

R = DayH - DayL;	  // range
PP = (DayH + DayL +DayC+DayO)/4;
R1 = PP + (R * A);
S1 = PP - (R * A);
BT=R1+4*(R1-PP);
ST=S1-4*(PP-S1);
}

Plot(R1, "",colorGreen,styleStaircase);
Plot(S1, "",colorGreen,styleStaircase);
Plot(PP, "",colorBlue,styleDots+styleNoLine);
Plot(BT, "",colorBlue,styleDots+styleNoLine);
Plot(ST, "",colorBlue,styleDots+styleNoLine);



//----
Title = Name()+" SIMPLE PIVOT & FIBO"+Date()+ EncodeColor(colorRed)+"  Long Breakout above  "+WriteVal(R1,1.2)+"\n"+EncodeColor(colorRed)+"  Short breakout below  "+WriteVal(S1,1.2) 

;


Filter=1;
AddColumn(C,"cmp",1.2);
AddColumn(R1,"R4",1.2);
AddColumn(S1,"S4",1.2);
AddColumn(PP,"UP",1.2);
_SECTION_END();




Buy=Cover=Cross (C, R1);
Sell=Short= Cross (S1 ,C);

// plot arrows

shape = Buy * shapeUpArrow + Short * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );



SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

1 comments

1. jayman
about 14 years ago

very nice work navin,you have done good job,i have tried it, it give excellent result in back test for my stock

Leave Comment

Please login here to leave a comment.