Help Required in triple ema crossover strategy

#1
hai seniors and experts ,
help required in generating buy and sell signals in triple moving average crossover.
say , ema 34 , ema 55 and ema 89 are three moving averages ,
firstly buy signal is generated when ema34 > ema55 > ema89 .
After certain move ema34 < ema55 > ema89 , at this time we should get exit signal only and
after certain down move again situation becomes like this
ema34 > ema55 > ema89 , at this moment we should get again fresh buying signal .
Reverse of all should be vice versa in case of sell .
I hope i have been able to clear the concept .
Thanks a lot in advance .
 
Last edited:
#2
_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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();


_SECTION_BEGIN("Triple EMA Crossover Rules");

P1 = ParamField("Price field",-1);
Periods1 = Param("Periods1", 34, 2, 300, 1, 10 );
Plot( EMA( P1, Periods1 ), _DEFAULT_NAME(), ParamColor( "Color1", colorCycle ), ParamStyle("Style1") );

P2 = ParamField("Price field",-1);
Periods2 = Param("Periods2", 55, 2, 300, 1, 10 );
Plot( EMA( P2, Periods2 ), _DEFAULT_NAME(), ParamColor( "Color2", colorCycle ), ParamStyle("Style2") );

P3 = ParamField("Price field",-1);
Periods3 = Param("Periods3", 89, 2, 300, 1, 10 );
Plot( EMA( P3, Periods3 ), _DEFAULT_NAME(), ParamColor( "Color3", colorCycle ), ParamStyle("Style3") );



Buy = EMA(P1, Periods1) > EMA(P2, Periods2) AND EMA(P2, Periods2) > EMA(P3, Periods3) AND Cross(High,Ref(H,-1)) ;
Sell = EMA(P1, Periods1) < EMA(P2, Periods2) AND EMA(P2, Periods2) < EMA(P3, Periods3)AND Cross(Ref(L,-1),L);

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


Filter=Buy OR Sell;
SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar );
AddColumn( Close, "Close price", 1.4 );


PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

_SECTION_END();
 

Similar threads

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?