Very Effective Delta afl for Amibroker
// asfatul.alam@yahoo.com
_SECTION_BEGIN("Chart Display");
GraphXSpace = 10;
SetBarsRequired( 1,1);
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(colorLightGrey);
SetBarFillColor( IIf( C>O, colorWhite, colorBlack ) );
Plot( C, "Close", ParamColor("Candle Color", colorBlack), styleCandle|styleNoTitle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_SECTION_END();
_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorGrey50), ParamStyle( "Style", styleHistogram | styleOwnScale, maskHistogram), 2 );
_SECTION_END();
_SECTION_BEGIN("Trading System");
x=Param("Short EMA",14,1,200,1);
y=Param("Long EMA", 21,1,200,1);
EMA1= EMA(C,x);
EMA2=EMA(C,y);
goldencross= Cross(EMA1, EMA2)AND C>EMA2 ;
deadcross= Cross(EMA2, EMA1);
_SECTION_END();
BuyCondition = goldencross ;
SellCondition = deadcross;
Buy = BuyCondition;
Short = SellCondition;
_SECTION_END();
_SECTION_BEGIN("Exploration");
PlotShapes(IIf(Short,shapeSmallUpTriangle,shapeNone),colorOrange,0,L,-20);
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone),colorBlue,0,L,-25);
SetOption("NoDefaultColumns",True);
bkColour = IIf(BuyCondition ,colorGreen,colorRed);
txtColour = colorWhite;
AddTextColumn(Name() ," Ticker ",1.2,txtColour,bkColour,75);
AddTextColumn(FullName() ," Full Name ",1.2,txtColour,bkColour,100);
AddColumn(DateTime()," Date / Time ",formatDateTime,txtColour,bkColour,125);
AddColumn(C," Close ",1.2,txtColour,bkColour,75);
AddColumn(ROC( C,1)," % Change ",1.2,txtColour,bkColour,50);
AddColumn(V," Volume ",1.0,txtColour,bkColour,100);
Filter = Buy OR Short;
AddColumn( IIf( BuyCondition, 66, 83 ), "Buy/Sell?", formatChar,txtColour,bkColour,40);
Var = WriteIf(goldencross,"GoldenCross",WriteIf(deadcross,"DeadCross",""));
AddTextColumn( Var , "Remark", 1.2 , colorBlack, IIf( goldencross, colorLime,IIf(deadcross,colorOrange,colorWhite)),60);
_SECTION_END();
_SECTION_BEGIN("EMA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 50, 1, 300, 0, 0 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("EMA4");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 1, 300, 0,0 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
function Delta(price,periods)
{
s = 0.84;
e1=EMA(price,periods);
e2=EMA(e1,Periods);
e3=EMA(e2,Periods);
e4=EMA(e3,Periods);
e5=EMA(e4,Periods);
e6=EMA(e5,Periods);
c1=-s*s*s;
c2=3*s*s+3*s*s*s;
c3=-6*s*s-3*s-3*s*s*s;
c4=1+3*s+s*s*s+3*s*s;
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;
return ti3;
}
Plot(C,"",4,64);
Plot(Delta(C,50),"Delta",colorYellow,1);
Plot(Delta(C,20),"Delta",colorGreen,1);
// asfatul.alam@yahoo.com
_SECTION_BEGIN("Chart Display");
GraphXSpace = 10;
SetBarsRequired( 1,1);
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(colorLightGrey);
SetBarFillColor( IIf( C>O, colorWhite, colorBlack ) );
Plot( C, "Close", ParamColor("Candle Color", colorBlack), styleCandle|styleNoTitle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_SECTION_END();
_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorGrey50), ParamStyle( "Style", styleHistogram | styleOwnScale, maskHistogram), 2 );
_SECTION_END();
_SECTION_BEGIN("Trading System");
x=Param("Short EMA",14,1,200,1);
y=Param("Long EMA", 21,1,200,1);
EMA1= EMA(C,x);
EMA2=EMA(C,y);
goldencross= Cross(EMA1, EMA2)AND C>EMA2 ;
deadcross= Cross(EMA2, EMA1);
_SECTION_END();
BuyCondition = goldencross ;
SellCondition = deadcross;
Buy = BuyCondition;
Short = SellCondition;
_SECTION_END();
_SECTION_BEGIN("Exploration");
PlotShapes(IIf(Short,shapeSmallUpTriangle,shapeNone),colorOrange,0,L,-20);
PlotShapes(IIf(Buy,shapeSmallUpTriangle,shapeNone),colorBlue,0,L,-25);
SetOption("NoDefaultColumns",True);
bkColour = IIf(BuyCondition ,colorGreen,colorRed);
txtColour = colorWhite;
AddTextColumn(Name() ," Ticker ",1.2,txtColour,bkColour,75);
AddTextColumn(FullName() ," Full Name ",1.2,txtColour,bkColour,100);
AddColumn(DateTime()," Date / Time ",formatDateTime,txtColour,bkColour,125);
AddColumn(C," Close ",1.2,txtColour,bkColour,75);
AddColumn(ROC( C,1)," % Change ",1.2,txtColour,bkColour,50);
AddColumn(V," Volume ",1.0,txtColour,bkColour,100);
Filter = Buy OR Short;
AddColumn( IIf( BuyCondition, 66, 83 ), "Buy/Sell?", formatChar,txtColour,bkColour,40);
Var = WriteIf(goldencross,"GoldenCross",WriteIf(deadcross,"DeadCross",""));
AddTextColumn( Var , "Remark", 1.2 , colorBlack, IIf( goldencross, colorLime,IIf(deadcross,colorOrange,colorWhite)),60);
_SECTION_END();
_SECTION_BEGIN("EMA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 50, 1, 300, 0, 0 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
_SECTION_BEGIN("EMA4");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 1, 300, 0,0 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
function Delta(price,periods)
{
s = 0.84;
e1=EMA(price,periods);
e2=EMA(e1,Periods);
e3=EMA(e2,Periods);
e4=EMA(e3,Periods);
e5=EMA(e4,Periods);
e6=EMA(e5,Periods);
c1=-s*s*s;
c2=3*s*s+3*s*s*s;
c3=-6*s*s-3*s-3*s*s*s;
c4=1+3*s+s*s*s+3*s*s;
Ti3=c1*e6+c2*e5+c3*e4+c4*e3;
return ti3;
}
Plot(C,"",4,64);
Plot(Delta(C,50),"Delta",colorYellow,1);
Plot(Delta(C,20),"Delta",colorGreen,1);
No comments:
Post a Comment
Thanks