How to close an order and Moving Average levels

 

Hello everybody!

I am totally new with the mql4 language, I started about one week ago with the book "Programming in Algorithmic Language" by Sergey Kovalyov, and I thought the best way to learn is even to make some practice, so I opened a demo account and I'm trying to do very simpre stuff!

Ok, after this little introduction I have two main questions:

1) I think I totally didn't understand how to select an order and how to close it. I tried to search on internet for simplier example but I still don't get it!
For understand the dynamics I putted a Moving Average and I'm trying to make the EA close an open order when a bar close under or above it but I still can't do that.
Can somebody do that for me in the right way so I can understand?

2) There is a way to put even the vertical shift of a Moving Avarage? By that I mean the levels you can create on a Moving Average

Thank you for your attention and for your time!
I hope you can help me understand better the mql4 language :)

Reason: