EMA Channel Breakout

Hello to everybody!
i’m new in the forum and in the forex markets,i need help with this EA ,that i try to code.
The system is based on the breakout of the hi-lo 21ema channel.
You put a buystop order on the high of a candle that open below and close above the upper line of the ema,
and you put a sellstop order at the low of a candle that open above and close below the lower line of the ema.
If a new entry condition appear the system delete the previous pending order and generate a new one.
For close a position i use the break of the opposite line(example…if you go long you’ll close the position on the brakout of the lower ema line)and a take profit/stop loss method.

I’m not an expert coder as you’ll see in the EA,i had make a copy/paste from other EA and wrote few lines by myself

i have some problems with the EA ,first of all the famous “error 130” and then with the trailing stop loss.
it doesn’t work with the short position,and in the long position does not work as i want(it contiously change the stoploss level ,while i want that once the price goes up for xx pips the sl move up xx pips and if the price go back i dont want that sl to change again)

pleas help me to make the right corrections in the code and give me some input/advice to improve it.
thx to all!

P.S. sorry for my english!

Hi!
i change few things in the code.
this is a screenshot of a backtest from september to october!as you can see the trail stop works only for the buy positions and not perfectly.
i’ve put a break even situation in the EA,but i want that the sl goes up every xx pips…