_SECTION_BEGIN("KARTHIK_SRI EMA CCI AFL");
// http://www.traderji.com/technical-analysis/83319-karthiks-intraday-trading-using-ema-cci.html
// karthik_sri 2nd March 2013, 09:26 PM
/// AFL by mastermind007
/// Setup
/// 1). Timeframe : 5 minutes chart Only
/// 2). EMA : 110 periods
/// 3). CCI : 14 periods .... {Corrected!!)
/// RULES
/// BUY / GO LONG CONDITION
/// a). The 5 min candle should be above 110 EMA.
/// b). CCI should be > 100. We consider CCI reading only for ENTRY not for EXIT. This CCI will act as a FILTER to avoid false Traps
/// c). A 0.10% filter on the High price
///
/// SELL / GO SHORT CONDITION
/// a). The 5 min candle should be below 110 EMA.
/// b). CCI should be < -100. We consider CCI reading only for ENTRY and not for EXIT. This CCI will act as a FILTER to avoid false Traps
/// c). A 0.10% filter on the Low price
///
/// EXIT : Rs.10/- min
/// SL above in both cases is Rs.10/- (as Karthik wanted to keep RR as 1:1)
/// Recommended Scrips : MARUTI, AXISBANK, LT, TCS, ICICIBANK & SBI
/// Karthik
/// Additional Filter:
/// This filter was recommended by docfij333 added that the Crossover Candle should be from the 10th candle onwards.
SetChartOptions(0,chartShowArrows|chartShowDates);
if (Interval() == in5Minute)
{
FilterPercent = Param("Filter Percent %", 0.1, 0.1, 2, 0.1) / 100;
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 )
+" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
//========================================================================
EMA110 = EMA(C,110);
CCI14 = CCI(14);
if (ParamToggle("Show EMA and CCI", "Show|Hide", 1) == 0)
{
Plot(EMA110,"EMA110",colorBlue,styleLine);
Plot(CCI14,"CCI(14)",colorBlue, styleOwnScale | styleNoLine);
}
bullish = C > EMA110 AND CCI14 > 100;
bearish = C < EMA110 AND CCI14 < -100;
LEP = (1 + FilterPercent) * H;
SEP = (1 - FilterPercent) * L;
CandleColor=IIf(bullish,colorGreen,IIf(bearish,colorRed,colorBlack));
Plot( C, "Close", CandleColor , styleNoTitle | styleCandle );
//========================================================================
BuyMode = Flip(bullish, bearish);
SellMode = Flip(bearish, bullish);
//========================================================================
LongEntryPrice = ValueWhen(BuyMode == 1 AND Ref(BuyMode,-1) == 0, LEP);
LongTargetPrice = LongEntryPrice + 10;
LongSLPrice = LongEntryPrice - 10;
Buy = (BuyMode == 1) AND bullish AND Cross(C,LongEntryPrice);
Sell= (( ( Ref (BuyMode,-1) == 1) AND (BuyMode == 0) )
OR Cross(H,LongTargetPrice)
OR Cross(LongSLPrice,L));
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
//========================================================================
ShortEntryPrice = ValueWhen(SellMode == 1 AND Ref(SellMode,-1) == 0, SEP);
ShortTargetPrice = ShortEntryPrice - 10;
ShortSLPrice = ShortEntryPrice + 10;
Short = (SellMode == 1) AND Cross(ShortEntryPrice, C);
Cover = ( ((Ref(SellMode,-1) == 1) AND (SellMode == 0))
OR (ShortTargetPrice >= L)
OR (H >= ShortSLPrice));
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
//========================================================================
PlotShapes(IIf(Buy , shapeUpArrow,shapeNone),colorGreen,0,L,Offset=-10);
PlotShapes(IIf(Sell, shapeDownArrow,shapeNone),colorRed,0,H,Offset=-10);
PlotShapes(IIf(Cover, shapeUpTriangle, shapeNone), colorGreen,0,L,Offset=-10);
PlotShapes(IIf(Short, shapeDownTriangle, shapeNone), colorRed,0,H,Offset=-10);
//========================================================================
if ( (SelectedValue(BuyMode) == 1) AND ((SelectedValue(BarsSince(Sell)) == 0) OR (SelectedValue(BarsSince(Sell)) >= SelectedValue(BarsSince(Buy)))))
{
endingBar = SelectedValue(BarIndex()) + 25;
startingBar = SelectedValue(BarIndex()) - 5;
Plot(LineArray(startingBar, SelectedValue(LongEntryPrice), endingBar, SelectedValue(LongEntryPrice), 0, True), "Long Entry", colorGreen, styleNoTitle| styleThick | styleDashed | styleNoLabel, Null, Null);
Plot(LineArray(startingBar, SelectedValue(LongTargetPrice), endingBar, SelectedValue(LongTargetPrice), 0, True), "Long Target", colorGreen, styleNoTitle | styleDots | styleNoLabel, Null, Null);
Plot(LineArray(startingBar, SelectedValue(LongSLPrice), endingBar, SelectedValue(LongSLPrice), 0, True), "Stop Loss", colorRed, styleNoTitle | styleDots | styleNoLabel, Null, Null);
Plot(LongEntryPrice,"\nLong Entry Price",colorGreen, styleOwnScale | styleDashed | styleNoLine);
Plot(LongTargetPrice,"Long Target Price",colorGreen, styleOwnScale | styleDashed | styleNoLine);
Plot(LongSLPrice,"Long Stop Loss Price",colorRed, styleOwnScale | styleDashed | styleNoLine);
} else if ( ( SelectedValue(SellMode) == 1) AND ((SelectedValue(BarsSince(Cover)) == 0) OR (SelectedValue(BarsSince(Cover)) >= SelectedValue(BarsSince(Short)))))
{
endingBar = SelectedValue(BarIndex()) + 25;
startingBar = SelectedValue(BarIndex()) - 5;
Plot(LineArray(startingBar, SelectedValue(ShortEntryPrice), endingBar, SelectedValue(ShortEntryPrice), 0, True), "Short Entry", colorGreen, styleNoTitle| styleThick | styleDashed | styleNoLabel, Null, Null);
Plot(LineArray(startingBar, SelectedValue(ShortTargetPrice), endingBar, SelectedValue(ShortTargetPrice), 0, True), "Short Target", colorGreen, styleNoTitle | styleDots | styleNoLabel, Null, Null);
Plot(LineArray(startingBar, SelectedValue(ShortSLPrice), endingBar, SelectedValue(ShortSLPrice), 0, True), "Stop Loss", colorRed, styleNoTitle | styleDots | styleNoLabel, Null, Null);
Plot(ShortEntryPrice,"\nShort Entry Price",colorGreen, styleOwnScale | styleDashed | styleNoLine);
Plot(ShortTargetPrice,"Short Target Price",colorGreen, styleOwnScale | styleDashed | styleNoLine);
Plot(ShortSLPrice,"Short Stop Loss Price",colorRed, styleOwnScale | styleDashed | styleNoLine);
}
//========================================================================
segments = IIf( Interval() < inDaily, Day(), Month() );
segments = segments != Ref( segments , -1 );
Plot(segments, "", colorRed, styleHistogram | styleOwnScale );
//========================================================================
} else
{
_N(Title = "\n\n\n\n\n\n\n\nSORRY, BUT THIS AFL IS MEANT TO WORK ON INTERVAL OF 5 MINUTES ONLY");
}
_SECTION_END();