This is an Amibroker formula which I use with my trading everyday. Many people use the normal SAR formula or the EMA of past five days. But the accuracy is greater with the formula that I provide here.
_SECTION_BEGIN("Modified Sar formula");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
feb =(LLV(Low,5)*0.764)+(Ref(Low,-1)*0.236);
feb2 =(feb*0.764)+(Low*0.236);
feb1 = MA(feb2,5);
feb10 =MA(feb2,10);
Hig = EMA(High,5);
Lo = EMA(Low,5);
Plot(feb1,"",colorBlue,512 +styleThick );
//Plot(Hig,"",colorBlue,512 +styleThick + styleDashed);
//Plot(Lo,"",colorRed,512 +styleThick + styleDashed);
Buy = Cross(High,feb1) AND MA(V,20)>500000;
Sell =Cross(feb1,Low)AND MA(V,20)>500000;
ExB =Buy;
ExS = Sell;
ExB_status = WriteIf( ExB, "Buy", " " );
ExS_status = WriteIf( ExS, "Sell", " " );
ExB_Color = IIf( ExB, colorDarkGreen , colorWhite );
ExS_Color = IIf( ExS, colorRed, colorWhite );
Filter = ExB OR ExS;
AddColumn( C, "close,", 1.2, IIf( C > Ref( C, -1 ), colorDarkGreen, colorRed ) );
AddColumn(Volume,"volume");
AddColumn(feb1,"MY-SAR");
AddTextColumn( ExB_status, "Buy", 1, colorWhite, ExB_color );
AddTextColumn( ExS_status, "Sell", 1, colorWhite, ExS_color );
GfxSetOverlayMode( mode = 0 );
GfxSelectPen( colorOrange, 2 );
GfxSelectSolidBrush( colorBlack );
GfxRoundRect(5,20, 250,63, 16, 20 );
GfxSetBkMode(1);
GfxSelectFont( "Arial",12, 700, False );
GfxSetTextColor( colorPaleGreen );
GfxSetTextAlign(0);
GfxSetTextColor( colorBlue );
GfxTextOut(WriteIf(feb1, "MY-SAR: "+(feb1),""), 8 ,25 );
GfxSetTextColor( colorRed );
_SECTION_END();
Comments
Post a Comment