How to Stoploss change each tick?

 
Hi,
I am try to make a EA with stoploss following the moving average. 
After buy just sell when the price touch the moving average(ema[ ]). 
Using stoploss = ema [0] in trade system, the sl set to the ema of bought. 
I would like to programming stoploss to changing every tick.
It s possible? 
 

Yes, possible. Very easy...

Files:
SL_EMA.mq4  3 kb
 
jrrchagas Chagas:
Hi,
I am try to make a EA with stoploss following the moving average. 
After buy just sell when the price touch the moving average(ema[ ]). 
Using stoploss = ema [0] in trade system, the sl set to the ema of bought. 
I would like to programming stoploss to changing every tick.
It s possible? 

What's the point of constantly moving the SL around, surely you could just say when price crosses EMA(0) then close

Reason: