Need AFL for EMA crossover strategy

#1
Dear Seniors / Programmers ...

I need AFL for below strategy ..

Indicators are :

* 1st is Exponential moving average Period of 13 and apply to close of candle
* 2nd is Exponential moving average Period of 5 and apply to close of candle

Conditions :

AFL should give signal when EMA 5 Crosses and spreads EMA 13 ..

Help me plz

Thanks
 
#2
Dear Seniors / Programmers ...

I need AFL for below strategy ..

Indicators are :

* 1st is Exponential moving average Period of 13 and apply to close of candle
* 2nd is Exponential moving average Period of 5 and apply to close of candle

Conditions :

AFL should give signal when EMA 5 Crosses and spreads EMA 13 ..

Help me plz

Thanks

Somebody help me yaar ..
 

jahan

Well-Known Member
#3
Somebody help me yaar ..
Hello


here u go......

regards,

_SECTION_BEGIN("BACK COLR");

GfxSetOverlayMode(1);

GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/20 ); /* Up down name*/
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 42, 42, 42 ) ));
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/7);
GfxSelectFont("Tahoma", Status("pxheight")/30 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/5 ); /* Up Down Sector*/

GfxSelectFont("Tahoma", Status("pxheight")/40 );
GfxTextOut( "Golden Cross - BY -conquest1453 istanbul- @ACARLAR33", Status("pxwidth")/2, Status("pxheight")/4);
GfxSelectFont("Tahoma", Status("pxheight")/20 );
GfxTextOut( " Borsayorumla.com ", Status("pxwidth")/2, Status("pxheight")/15 );

_SECTION_BEGIN("Price");
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() );
_SECTION_END();

_SECTION_BEGIN("MA");


P = ParamField("Price field",-1);
Periods1 = Param("Periods1", 5, 1, 500, 1, 10 );
Periods2 = Param("Periods2", 13, 1, 500, 1, 10 );
Plot( EMA( P, Periods1 ), StrFormat(_SECTION_NAME()+"(%g)", Periods1), ParamColor( "Color1", colorRed ), ParamStyle("Style") );
Plot( EMA( P, Periods2 ), StrFormat(_SECTION_NAME()+"(%g)", Periods2), ParamColor( "Color2", colorBlue ), ParamStyle("Style") );
Buy = Cross(EMA( P, Periods1 ),EMA( P, Periods2 ) );
Sell = Cross(EMA( P,Periods2 ), EMA( P, Periods1 ) );

PlotShapes(IIf(Buy==1, shapeHollowUpArrow , shapeNone), colorGreen, 0,Low, Offset=-15);
PlotShapes(IIf(Sell==1, shapeHollowDownArrow, shapeNone), colorRed, 0,High, Offset=-15);

PlotOHLC( Null,EMA( P, Periods1 ),EMA( P, Periods2 ),Null, "", IIf(EMA( P, Periods1 )>EMA( P, Periods2 ) ,colorLime,colorRose), styleCloud);

Color = IIf( EMA(p,periods1) > EMA(p,periods2) , colorLime, IIf( EMA(p,periods2) > EMA(p,periods1), colorPink, colorGrey50 ));
Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 30 );

_SECTION_END();
 
#4
Thanks .. i just added few code to make it 15 min optimized ...


_SECTION_BEGIN("Price");
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() );
_SECTION_END();



_SECTION_BEGIN("EMA");

Range1=Optimize("range1",14,1,20,1);
Range2=Optimize("range2",206,1,125,1);

Buy = Cross((EMA(Close,range1)),(EMA(Close,range2)));
Sell = Cross(EMA(Close,range2),(EMA(Close,range1)));
Short = Sell;
Cover = Buy;

// plot expanded average

Plot(EMA( Close,range1), "70min-ema", colorRed );
Plot(EMA( Close,range2), "1030min-ema", colorGreen );

// plot arrows
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );

_SECTION_END();
_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );

Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );

_SECTION_END();

_SECTION_BEGIN("BACK COLR");

GfxSetOverlayMode(1);

GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/20 ); /* Up down name*/
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ParamColor("Text Color", ColorHSB( 42, 42, 42 ) ));
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/7);
GfxSelectFont("Tahoma", Status("pxheight")/30 );
GfxTextOut( IndustryID(1), Status("pxwidth")/2, Status("pxheight")/5 ); /* Up Down Sector*/

GfxSelectFont("Tahoma", Status("pxheight")/40 );
GfxTextOut( "Golden Cross - BY -conquest1453 istanbul- @ACARLAR33", Status("pxwidth")/2, Status("pxheight")/4);
GfxSelectFont("Tahoma", Status("pxheight")/20 );
GfxTextOut( " Borsayorumla.com ", Status("pxwidth")/2, Status("pxheight")/15 );

_SECTION_BEGIN("Price");
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() );
_SECTION_END();

_SECTION_BEGIN("MA");


P = ParamField("Price field",-1);
Periods1 = Param("Periods1", 5, 1, 500, 1, 10 );
Periods2 = Param("Periods2", 13, 1, 500, 1, 10 );
Plot( EMA( P, Periods1 ), StrFormat(_SECTION_NAME()+"(%g)", Periods1), ParamColor( "Color1", colorRed ), ParamStyle("Style") );
Plot( EMA( P, Periods2 ), StrFormat(_SECTION_NAME()+"(%g)", Periods2), ParamColor( "Color2", colorBlue ), ParamStyle("Style") );
Buy = Cross(EMA( P, Periods1 ),EMA( P, Periods2 ) );
Sell = Cross(EMA( P,Periods2 ), EMA( P, Periods1 ) );

PlotShapes(IIf(Buy==1, shapeHollowUpArrow , shapeNone), colorGreen, 0,Low, Offset=-15);
PlotShapes(IIf(Sell==1, shapeHollowDownArrow, shapeNone), colorRed, 0,High, Offset=-15);

PlotOHLC( Null,EMA( P, Periods1 ),EMA( P, Periods2 ),Null, "", IIf(EMA( P, Periods1 )>EMA( P, Periods2 ) ,colorLime,colorRose), styleCloud);

Color = IIf( EMA(p,periods1) > EMA(p,periods2) , colorLime, IIf( EMA(p,periods2) > EMA(p,periods1), colorPink, colorGrey50 ));
Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 30 );

_SECTION_END();


_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();
 

Similar threads