Need code for this strategy

BUY:

only cover orders allowed

conditions 1. EMA crossover of 9 & 3 2.volumn> Avg volumn

SELL:

same

EXIT BUY:

when Target or SL hits

Target=Buy price + 2rs

SL= Buy price - 0.5rs

EXIT Sell:

same

ADDITIONAL :

Need to Trail STOPLOSS by 0.6rs for a increase/decrease of price by 0.5r

As per the above query you have to place cover order once signal is generated and cover order option is there in alerts->create scripted alerts in pi

Buy Script:

CROSSOVER(EMA(CLOSE,9),EMA(CLOSE,3)) AND VOLUME>SMA(VOLUME,30)

Sell Script:

CROSSOVER(EMA(CLOSE,3),EMA(CLOSE,9)) AND VOLUME<SMA(VOLUME,30)

Exit Buy:

(CROSSOVER(EMA(CLOSE,9),EMA(CLOSE,3)) AND VOLUME>SMA(VOLUME,30))+2

Exit Sell:

(CROSSOVER(EMA(CLOSE,3),EMA(CLOSE,9)) AND VOLUME<SMA(VOLUME,30))-2