Code for DMI with previous price broken

Please help me to code below requirements

A buy is generated when two conditions satisfy –
Current Price is greater than the previous price.
When the previous price was at DI+ > 25

A sell is generated when two conditions satisfy –
Current Price is lower than the previous price.
When the previous price was at DI- > 25

Please help me.