/*-Indicators: EMA9 and EMA26 and DMI (Directional Movement Indicator with ADX)
Conditions:
GO LONG WHEN:
- EMA9 has crossed over EMA26
- DI+ >= 25
- ADX >= should be 20 to 35
- ADX is in between DI+ and DI-
EXIT LONG WHEN:
- EMA26 has crossed EMA9 AND
- DI- is higher than DI+
Also Reentering position also need
GO SHORT WHEN:
- EMA26 has crossed EMA9
- DI- >= 25
- ADX >= should be 20 to 35
- ADX is in between DI- and DI+
EXIT SHORT WHEN:
- EMA9 has crossed EMA26 AND
- DI+ is higher than DI-
Reentering position also need
WHAT TO IGNORE:
- While in Long Position: DI+ and DI- Cross-overs while the EMA9 is still on top of EMA26
- While in Short Position: DI+ and DI- Cross-overs while the EMA26 is still on top of EMA9
Buy, Sell arrow need and different symbols need for exit positions, if possible add message board.
*/
_SECTION_BEGIN("Price");
GraphXSpace=5;
SetChartOptions(0,chartShowArrows|chartShowDates);
_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 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
AvgFast=EMA( Close, 9 );
AvgSlow=EMA( Close, 26 );
myPDI=PDI (14); //Plus Directional Movement Indicator
myMDI=MDI (14); //Minus Directional Movement Indicator
myADX=ADX (14);
Plot(AvgFast,"AvgFast",colorBlack, styleLine|styleDashed | styleThick);
Plot(AvgSlow,"AvgFast",colorGreen, styleLine|styleDashed | styleThick);
Plot(myPDI,"myPDI",colorBlue, styleLine|styleLine|styleOwnScale);
Plot(myMDI,"myMDI",colorRed, styleLine|styleLine|styleOwnScale);
Plot(myADX,"myADX",colorBlue, styleLine|styleDashed | styleThick|styleOwnScale);
//entry Criteria Long
//CrLo1=Cross( AvgFast, AvgSlow); //EMA9 has crossed over EMA26
CrLo1= AvgFast> AvgSlow; //EMA9 has crossed over EMA26
CrLo2=myPDI >= 25; //DI+ >= 25
CrLo3=myADX >= 20 AND myADX <=35; //ADX >= should be 20 to 35
CrLo4=myADX > myMDI AND myADX < myPDI; //ADX is in between DI+ and DI-
//ShortCriteria Long
//CrLo5=Cross( AvgSlow, AvgFast); //EMA26 has crossed over EMA9
CrLo5= AvgSlow> AvgFast; //EMA26 has crossed over EMA9
CrLo6=myMDI >= 25; //DI- >= 25
CrLo7=myADX >= 20 AND myADX <=35; //ADX >= should be 20 to 35
CrLo8=myADX > myPDI AND myADX < myMDI; //ADX is in between DI+ and DI-
Buy=CrLo1 AND CrLo2 AND CrLo3 AND CrLo4;
Sell=0;
Short=CrLo5 AND CrLo6 AND CrLo7 AND CrLo8;
Cover=0;
Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);
PlotShapes( Buy * shapeUpTriangle, colorBrightGreen, 0);
PlotShapes( Short * shapeDownTriangle, colorRed, 0);