Karthik's EOD Strategy...

asnavale

Well-Known Member
#21
Hi Karthik,
I guess you have to update your rules to correct this typo :) ( adding are not to your original post)

BTW, I am trying to write the AFL for this strategy for ease of use. Let me see how much I can progress. I am learning to code strategies. Pl. let me know if you have already done it.

Thanks
hi ,
Karthik has explained his EOD strategy,it would be helpfull if someone can code it to afl,
Thank You


***************

Friends,

Here is the AFL. Copy and save in your "AmiBroker/Formulas/Custom" folder.

Please note that this version does not contain Exit rules as the rules are not spelt out for Selling (Shorting). Once the rules are available, I will revise the AFL and post.

This AFL also contains Exploration. You can list the stocks which have generated a Buy or a Sell trigger. The Entry price and Stop Loss are also listed with the Triggers.

Hope this helps.

The AFL is here:

Code:
SetChartOptions(0, chartShowDates | chartWrapTitle);
SetChartBkColor(colorBlack);

_SECTION_BEGIN("Karthik_EOD");

P1 = Param("Shorter EMA Period", 3, 2, 100, 1);
P2 = Param("Longer EMA Period", 10, 3, 200, 1);
P3 = Param("ADX Period", 14, 3, 100, 1);

E1 = EMA(C, P1);
E2 = EMA(C, P2);
DPLUS = PDI(P3);
DMINUS = MDI(P3);

Buy = E1 > E2 AND DPLUS > DMINUS;
Sell = E2 > E1 AND DMINUS > DPLUS;

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

_N(Title = EncodeColor(colorTurquoise) + "KARTHIK's EOD Strategy;"
				+ EncodeColor(colorYellow) + "  AFL by ANANT NAVALE, Version 1.00\n\n"
				+ EncodeColor(colorWhite) + StrFormat("{{NAME}} ({{INTERVAL}}, {{DATE}}; {{OHLCX}}; {{VALUES}}\n")
				+ EncodeColor(colorBrightGreen) + WriteIf(Buy, "Buy Above : " + H + ";     SL = " + L, "") 
				+ EncodeColor(colorPink) + WriteIf(Sell, "Sell Below : " + L + ",     SL = " + H, ""));
if(Status("action") == actionIndicator)
	{
		Plot(C, "", colorLightGrey, styleCandle);
		Plot(E1, "EMA(" + P1 + ")=", colorBrightGreen, styleLine | styleThick);
		Plot(E2, "EMA(" + P2 + ")=", colorRed, styleLine | styleThick);
		PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20);
		PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30); 
		PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25); 
		PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
		PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30); 
		PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
	}

if(Status("action") == actionExplore)
	{
		Filter = Buy OR Sell;

		SetOption("NoDefaultColumns", True);
		AddTextColumn(Name(), "SYMBOL");
		AddColumn(DateTime(), "DATE", formatDateTime);
		AddColumn(IIf(Buy, 66, 83), "TRIG", formatChar, colorYellow, IIf(Buy, colorGreen, colorRed));
		AddColumn(IIf(Buy, H, Null), "BUY ABOVE", 1.2);
		AddColumn(IIf(Sell, L, Null), "SELL BELOW", 1.2);
		AddColumn(IIf(Buy, L, H), "STOP LOSS", 1.2);
	}


_SECTION_END();

-Anant
 

anup

Well-Known Member
#23
First trade on EOD method:
nifty short triggered.If anybody want to sell, can sell tomorrow morning and nifty SL5890...
Also keep in mind expiry is on the way just 3 more days..So can buy nifty put of jan series..
Please follow strict SL..All the best
 

karthik_sri

Well-Known Member
#24
***************

Friends,

Here is the AFL. Copy and save in your "AmiBroker/Formulas/Custom" folder.

Please note that this version does not contain Exit rules as the rules are not spelt out for Selling (Shorting). Once the rules are available, I will revise the AFL and post.

This AFL also contains Exploration. You can list the stocks which have generated a Buy or a Sell trigger. The Entry price and Stop Loss are also listed with the Triggers.

Hope this helps.


Code:
SetChartOptions(0, chartShowDates | chartWrapTitle);
SetChartBkColor(colorBlack);

_SECTION_BEGIN("Karthik_EOD");

P1 = Param("Shorter EMA Period", 3, 2, 100, 1);
P2 = Param("Longer EMA Period", 10, 3, 200, 1);
P3 = Param("ADX Period", 14, 3, 100, 1);

E1 = EMA(C, P1);
E2 = EMA(C, P2);
DPLUS = PDI(P3);
DMINUS = MDI(P3);

Buy = E1 > E2 AND DPLUS > DMINUS;
Sell = E2 > E1 AND DMINUS > DPLUS;

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

_N(Title = EncodeColor(colorTurquoise) + "KARTHIK's EOD Strategy;"
				+ EncodeColor(colorYellow) + "  AFL by ANANT NAVALE, Version 1.00\n\n"
				+ EncodeColor(colorWhite) + StrFormat("{{NAME}} ({{INTERVAL}}, {{DATE}}; {{OHLCX}}; {{VALUES}}\n")
				+ EncodeColor(colorBrightGreen) + WriteIf(Buy, "Buy Above : " + H + ";     SL = " + L, "") 
				+ EncodeColor(colorPink) + WriteIf(Sell, "Sell Below : " + L + ",     SL = " + H, ""));
if(Status("action") == actionIndicator)
	{
		Plot(C, "", colorLightGrey, styleCandle);
		Plot(E1, "EMA(" + P1 + ")=", colorBrightGreen, styleLine | styleThick);
		Plot(E2, "EMA(" + P2 + ")=", colorRed, styleLine | styleThick);
		PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20);
		PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30); 
		PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25); 
		PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
		PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30); 
		PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
	}

if(Status("action") == actionExplore)
	{
		Filter = Buy OR Sell;

		SetOption("NoDefaultColumns", True);
		AddTextColumn(Name(), "SYMBOL");
		AddColumn(DateTime(), "DATE", formatDateTime);
		AddColumn(IIf(Buy, 66, 83), "TRIG", formatChar, colorYellow, IIf(Buy, colorGreen, colorRed));
		AddColumn(IIf(Buy, H, Null), "BUY ABOVE", 1.2);
		AddColumn(IIf(Sell, L, Null), "SELL BELOW", 1.2);
		AddColumn(IIf(Buy, L, H), "STOP LOSS", 1.2);
	}


_SECTION_END();

-Anant
Anant Bro,
Thanks a lot for coding...:)

Let me check and get back to u

Karthik
The AFL is here:
 

karthik_sri

Well-Known Member
#25
Hi Anant,
Exit : Both on Buy/Sell the rule remains the same as the price don't touch 3EMA. Please check if you can able to code the exit strategy in AFL. Alternatively you can show if the price has reached 2% from the high/low there also we can exit.

Thanks for the coding!:clapping:

Karthik
 

anilnegi

Well-Known Member
#26
Hi Anant,
Exit : Both on Buy/Sell the rule remains the same as the price don't touch 3EMA. Please check if you can able to code the exit strategy in AFL. Alternatively you can show if the price has reached 2% from the high/low there also we can exit.

Thanks for the coding!:clapping:

Karthik
Karthik

One or two things just to clarify,

1. You choose EMA 3 / 10, apart from 315 which is very famous till now, hope you have paper trade with both the strategy and found this one better, although it does have ADX filter.
2. kindly also suggest Reentry for buy/ sell
3. Can we settle a buy entry at the time of ADX crossover?

thks
anil negi
 

asnavale

Well-Known Member
#30
We Agree to Disagree.
Trade whichever is advantageous to us.
The difference is probably due to the data range used for the chart. In RR's chart the data is for about 60 days while the other chart has more data. However, as pointed out by RR, caution is necessary because the the required conditions are satisfied to the extent that we can take them as a trigger but future data can distort the chart, the cross-over and ADX can show opposite direction.

-Anant
 

Similar threads