Exit an existing traded with EA

 

hi is it possible to close a open order

lets say 0.4 lot eur / usd

i dont want to watch it manually i apply an new EA and say

close this open trade when moving average (10) gets touched ? or CCI value 82 crossed .. whatever .,.. so a simple exit funtion()

and an advanced version with

input 1

0.1 lot

take out 0.1 at MA (5)

input 2

0.1 lot

take out 0.1 at MA (10)

i tried myself and i build some MA cross Sell Exit strategy but i cant write the whole code to work properly