HOW CAN I WRITE CODE FOR ADX crossover for buy/sell and exit

Provide me code for crossover of ADX.Crossover of +DI and -DI, when ADX is above 15 and moving upside

  1. buy if DI+ cross above DI-
    exit buy if DI+ crosses ADX from upside or dip crosses below level 40

  2. sell if DI- cross above DI+
    and
    exit sell when DI- cross ADX from upside or din crosses below level 40

For the above given condition

Buy Script:

CROSSOVER(DIP(14),DIN(14))

Sell Script:

CROSSOVER(DIN(14),DIP(14))

and for cross over of adx and dip /din to exit the postition

sir please help me fr above condition
as this is not giving about exiting position at properlevels

giving wrong signal
why always giving wrong signal, without any crossover