Strategy on DMI

Dear Traders,

I am trying to set a strategy on DI+ and DI- cross over strategy. Anyone here who is already using it.

@Pratik Hi, Even I was trying to create some code based on ADX and DMI Crossover. Was unable to figureout the mistake i am doing. Still learning, and you could help.

MyADX = Param("ADX_Periods", 13, 2, 200, 1 );
MyPDI = Param("PDI_Periods", 13, 2, 200, 1 );
MyMDI = Param("MDI_Periods", 13, 2, 200, 1 );

ADXRising = MyADX > 25;
PDIRising  = MyPDI > 25;
PDIDecline = MyPDI < 25;

PositiveCross = Cross(MyPDI, MyMDI);
CoverCross = Cross(MyMDI, MyPDI);

Buy = (ADXRising AND  PDIRising AND PositiveCross) ;
Sell = (PDIDecline AND CoverCross) ;

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

Hello @Pratik and @santoshdts,

Welcome to the Forum.

Please read the "How to use this site" and go get your "Verified Badge".

@Pratik, the best way to get help is to show your work.

@santoshdts, good job on showing your work, and properly using the code blocks for you code.

When you both get are Verified owners, help will probably start coming.

1 Like

_SECTION_BEGIN("ADX Crossover");

SetTradeDelays (1,0,1,0);
TimeFrameSet(inDaily);
PDMI=PDI();
NDMI=MDI();
TimeFrameRestore();

Buy = Cross(PDMI,NDMI);
BuyPrice=ValueWhen(Buy,C);
//Sell =C>= BuyPrice *1.01 OR C <= BUYPRICE * 0.995;

Sell = Cross(NDMI,PDMI);
SellPrice=ValueWhen(Sell,C);
//Cover = C<= ShortPrice *0.99 OR C >= ShortPrice * 1.005;

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

//Short = ExRem(Short ,Cover );
//Cover = ExRem(Cover ,Short );

dist =ATR(4);
for ( i=0; i < BarCount; i++)
{
if (Buy[i]) PlotText("Buy \n @ " + BuyPrice[i], i, L [i] - dist[i], colorGreen);
if (Sell[i]) PlotText("Short\n @ " + sellPrice[i], i, H [i] + dist[i], colorRed);
//if (Cover[i]) PlotText("Cover \n @ " + CoverPrice[i], i, L [i] - dist[i], colorGreen);
//if (Sell[i]) PlotText("Sell\n @ " + SellPrice[i], i, H [i] + dist[i], colorRed);

}

PlotShapes( IIf( Sell , shapeSmallCircle, shapeNone ), colorWhite, 0, SellPrice , 0 );
//PlotShapes( IIf( Short, shapeSmallCircle, shapeNone ), colorWhite, 0, ShortPrice, 0 );
PlotShapes( IIf( Buy , shapeSmallCircle, shapeNone ), colorWhite, 0, BuyPrice, 0 );
//PlotShapes( IIf( Cover, shapeSmallCircle, shapeNone ), colorWhite, 0, CoverPrice, 0 );

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);

//PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
//PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
//PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);

Plot(Close, "candle",colorDefault,styleCandle);

range = Param("Periods", 14, 2, 200, 1 );
Plot( ADX(range), _DEFAULT_NAME(), ParamColor( "ADX color", colorBlue ), ParamStyle("ADX style", styleThick ) );
Plot( PDI(range), "+DI", ParamColor( "+DI color", colorGreen ), ParamStyle("+DI style") );
Plot( MDI(range), "-DI", ParamColor( "-DI color", colorRed ), ParamStyle("-DI style") );

_SECTION_END();

@snoopy.pa30 @santoshdts I did this, further I want to add , during cross over DMI, I want to double the quantity.

@Pratik - did you not see this!

Only users with "Verified Badge" are allowed to post on this forum. Search "Verified Badge" for more information on how to get verified.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.