here is AFL designed by me which i think almost suits Raj's 15/25 strategy
Conditions to be satisfied:
1. TF-30 MINS
2.WHILE GOING LONG ENSURE THE PRICE IS ABOVE ATP AND VICE VERSA FOR SHORT
3. ENSURE THE STOCK IS IN O/S AREA ie LOWER END OF BOL. BAND AND VICE VERSA FOR SHORTS.
4.SL-2 consecutive candles closing below ATP for long trades and vice-versa for shorts
5. Profit booking- book profits when price reaches the upper band for longs and vice versa for shorts
RAJ FORGIVE ME IF HAVE DONE ANY ALTERATIONS TO UR STRATEGY bcos i had designed this long before but sharing it now after reading the prev.post and found that it almost matched with my afl..Pls note that i go long or short only when EMA15 close is > EMA15 open and vice versa. HERE GOES THE AFL
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(colorLightGrey);
_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("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( O,15), "15 EMA Open",ParamColor("EMA 15 Color", colorBlue ),ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
_SECTION_END();
_SECTION_BEGIN("EMA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( C,15), "15 EMA Close",ParamColor("EMA 15 Color", colorRed ),ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
_SECTION_END();
_SECTION_BEGIN("EMA4");
P = ParamField("Price field",-1);
Periods = Param("Periods", 25, 2, 300, 1, 10 );
Plot( EMA( H,25), "25 EMA High",ParamColor("EMA 25 Color", colorGold ),styleThick);
_SECTION_END();
_SECTION_BEGIN("EMA5");
P = ParamField("Price field",-1);
Periods = Param("Periods", 25, 2, 300, 1, 10 );
Plot( EMA( L,25), "25 EMA Low",ParamColor("EMA 25 Color", colorGreen ),styleThick);
_SECTION_END();
_SECTION_BEGIN("ATP");
Atp=ParamToggle("ATP","Off|On",1);
if(Atp==1)
{
DayChange = Day() != Ref(Day(), -1);
AvgTradePrice = Null;
CurDayBars = 0;
CurDayCloseSum = 0;
for (i = 0; i < BarCount; i++)
{
if (DayChange)
{
CurDayCloseSum = C;
CurDayBars = 1;
}
else
{
CurDayCloseSum = CurDayCloseSum + C;
CurDayBars++;
}
AvgTradePrice = CurDayCloseSum / CurDayBars;
}
Plot(AvgTradePrice, "AvgTradePrice",colorWhite,styleThick);
ATP=AvgTradePrice;
_SECTION_END();}
_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 2.5, 0, 10, 0.05 );
Color = ParamColor("Color", colorRed );
Style = ParamStyle("Style", styleThick);
Plot( BBandTop( P, 20, 2.5), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, 20, 2.5), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();
_SECTION_BEGIN("Bollinger Bands1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 1, 0, 10, 0.05 );
Color = ParamColor("Color", colorBlue );
Style = ParamStyle("Style",styleThick);
Plot( BBandTop( P, 20, 1 ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, 20, 1 ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();
_SECTION_BEGIN("Sai jagadish babu: AFL Coding");
GfxRectangle( 90, 20,430, 90);
GfxSetTextColor( ColorRGB( 120, 100, 140 ));
GfxTextOut( "Sai Krupa",215, 25 );
GfxTextOut( "Sai S.Jagadish Babu Bangarimath Trading System",100, 45 );
GfxTextOut( "cell 09443532111",100, 65 );
_SECTION_END();
Buy = EMA(C,15)>EMA(O,15)>EMA(H,25);
Sell = EMA(C,15)<EMA(O,15)<EMA(L,25);
Short= EMA(C,15) > EMA(H,25);
Cover= EMA(C,15) < EMA(L,25);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorBlue, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorBlack, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorBlack, 0,High, Offset=-20);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorBlue, 0,Low, Offset=-30);
SENIORS R WELCOME TO TWEAK THIS AFL.