MT4 Programming – Creating an EA in 10 minutes

There are some common patterns in MT4 programming and learning to use those effectively can make writing indicators and experts much easier.

In this short introduction I will show you how to create a function to loop through your open trades, use that loop to apply a trailing stop, and use all of that to create a complete working expert advisor.

This is a basic introduction and if you are serious about programming for MT4 then there are a number of improvements we can make but this will be a good starting point.

Please leave comments if you would like a follow up article to answer questions or to go into possible improvements or similar topics.


  1. hello sir,
    can you assist me I have an EA running, but when I’m going to apply the codes you have here for the purpose for protecting my EA code, i cannot compile it. errors occur. can you help me sir to debug the errors.. for your kind consideration, thank you.

    1. You give no information about the errors you receive. I cannot help with that. You should also reconsider distributing your code if you cannot perform basic debugging yet.

Leave a Reply