Karthik's Intraday Trading using EMA & CCI

karthik_sri

Well-Known Member
Thanks for the clarification Karthik,

I was just following Nifty future today and have doubt.
Even all the conditions were in place, the afl did not gave any Sell signal at 12,24 bar and 13,59 bar. Is there any reason

[/url][/IMG]

Raju
Yes they are valid signal but don't know why your AFL not generated any setup:confused: Pls take help from seniors who can review the AFL as I dont use AFL. BTW you use Black candle color for UP!
 
Attached please find the AFL that correctly implements Karthik_sri's strategy.

Whenever a trade is active, it will show lines segments that identify Target and S/L.

S/L is red dotted line whereas Target is Green-Dots. Entry is shown by dashed line in between. Line segments will continue to slide right until trade has hit a Target or S/L.

There are few exceptions.

1). Once a Buy Signal is generated and its target is achieved. it will not generate another buy signal until price goes below EMA110 and comes up again. This is partly due to how Amibroker manage's state and to reliably generate a signal

2) I've had to add two more criteris so in this AFL, trade can exit either at
(a) target, (b) Stop loss. (c) CCI jumps over to the other direction. (d) EMA110 gets crossed over by price.

(c) and (d) conditions are added by me and the reasoning for that is as follows. If a new signal is to be generated, old trade MUST be closed. If I allow a trade to exist beyond generation of following signal. I am allowing a bad trade to spoil a good one that is emerging. It makes lot more sense to terminate a trade even before it reaches S/L so that a counter signal can emerge.

Code:
_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();

Dear Mr.Karthik

I use the afl posted by Mastermind in #135.
Is there any updated one available
Pls help

Raju
 
Dear Mr.Karthik

I use the afl posted by Mastermind in #135.
Is there any updated one available
Pls help

Raju
Read the text above the AFL in post 135; I've clearly mentioned

There are few exceptions.

1). Once a Buy Signal is generated and its target is achieved. it will not generate another buy signal until price goes below EMA110 and comes up again. This is partly due to how Amibroker manage's state and to reliably generate a signal
The same rule applies for Short
1a). Once a short Signal is generated and its target is achieved. it will not generate another short signal until price goes above EMA110 and comes down again. This is partly due to how Amibroker manage's state and to reliably generate a signal


The way I see it, Karthik_sri's EMA CCI logic is good for a weak trending or sideways market but not so good for a mild to strong market which is what last Friday was.

The whole motive behind pre-fixed exits is is to avoid getting trapped in and to be in & out as quickly as you can.

It will generate only one trade on days when price stays on one side of CCI.
 
Dear Mr.Karthik

I use the afl posted by Mastermind in #135.
Is there any updated one available
Pls help

Raju
Read the text above the AFL in post 135; I've clearly mentioned

There are few exceptions.

1). Once a Buy Signal is generated and its target is achieved. it will not generate another buy signal until price goes below EMA110 and comes up again. This is partly due to how Amibroker manage's state and to reliably generate a signal
The same rule applies for Short
1a). Once a short Signal is generated and its target is achieved. it will not generate another short signal until price goes above EMA110 and comes down again. This is partly due to how Amibroker manage's state and to reliably generate a signal


The way I see it, Karthik_sri's EMA CCI logic is good for a weak trending or sideways market but not so good for a mild to strong market which is what last Friday was.

The whole motive behind pre-fixed exits is is to avoid getting trapped in and to be in & out as quickly as you can.

It will generate only one trade on days when price stays on one side of CCI.
 

Similar threads