Coding your first expert advisor – Principles

5

The first step to creating an EA is to think of the strategy.

Step two is to write the code and step three involves testing and debugging that code.

Guest post by FXTM

Best practice

When coding an EA, there are some principles of best practice that you should keep in mind whilst you go through the steps mentioned above.

Design like a programmer

Clearly, if you have no background in coding, creating your first expert advisor will require a fair amount of time and hard work. But even if you are not a programmer it is important to work like one.

That means being organised and precise in your approach to coding. Your EA will require rules and these need to be well planned out in order to avoid problems in the future.

It also means analysing your strategy first hand and being able to anticipate potential areas of inaccuracies with your system logic.

Prepare for the unexpected

One area of coding that doesn’t require any specialist knowledge is in the planning stage. Financial markets are never completely predictable which means there needs to be some margin of safety applied when you build your strategy.

The obvious answer to this is that you should never create a system that is leveraged to it’s full potential. Far better to reduce risk by a certain percentage or even one half. This will allow your code to withstand the volatility when unforeseen events strike.

Take it slow

As mentioned above, building an EA from scratch requires working like a programmer does and that means writing out the code in stages, one step at a time.

In MQL (MetaQuotes Language), you can start with the header first. Then initialise your special function, then start the special function and then de-initialise.

Taking this approach means that debugging the code at a later date will cause fewer headaches.

Keep it simple

Like most things in life, it pays to keep things simple and with system design this is something the experts nearly always espouse. Trading systems can be complex but with each complexity added to a system the harder it becomes to confirm it statistically. In other words, systems with too many levels may not replicate their back-test results in future trading and even if they do, confirming this with statistical analysis will require a lot more work and uncertainty.

It is much better to create a simple strategy that conforms to your trading philosophies and can be tested thoroughly. That way you will have much more confidence to follow it in real time.

Get the 5 most predictable currency pairs

About Author

Read previous post:
EUR/USD March 11 – Little Movement Ahead of US Employment Data

EUR/USD is steady in Tuesday trade, as the pair remains at high levels. In the European session, the euro is trading in the mid-1.38 range. German...

Close