Creating a Simple Trading Expert Advisor


 
Before starting to program a trading Expert Advisor, it is necessary to define general principles of a future program. There are no strict program creating rules. However, once having created a program, a programmer usually continues to improve it. To be able to easily understand the program in future, it must be created in accordance with a well-thought and easy-to-understand scheme (it is especially important if a program will be further improved by another programmer). The most convenient program is the one that consists of functional blocks, each of which is responsible for its part of calculations. To create an algorithm of a trading Expert Advisor, let’s analyze what an operating program should do.

One of the most important data in the formation of trade orders is the information about orders that already exist in a client terminal. Some of trading strategies allow only one unidirectional order. Generally, if a trading strategy allows, several orders can be open in a terminal at the same time, though their number should be reasonably limited. When using any strategy, trade decisions should be made taking into account the current situation. Before a trade decision is made in a program, it is necessary to know what trading orders have already been opened or placed. First of all a program must contain a block of orders accounting which is among the first to be executed.

During an EA execution trading decisions should be made, the implementation of which leads to the execution of trade operations. Code part responsible for trade orders formation is better written in a separate block. An Expert Advisor can form a trade request to open a new pending or market order, close or modify any of existing orders or perform no actions at all. An EA must also calculate order prices depending on a user’s desire.


Trade decisions should be made in a program on the bases of trade criteria. The success of the whole program depends on the correctness of detecting trade criteria in the program. When calculating trade criteria a program can (and must) take into account all information that can be useful. For example, an Expert Advisor can analyze combination of technical indicator values, time of important news releases, current time, values of some price levels, etc. For convenience, the program part responsible for the calculation of trading criteria should be written in a separate block.

A trading Expert Advisor must necessarily contain error processing block. Analyzing errors that may occur in the execution of trade operation allows, on the one side, to repeat a trade request and, on the other hand, to inform a user about a possible conflict situation.



Comments

Popular posts from this blog

Forex Secrets Income-A Simple, Beginning Trading Strategy

The Best Mobile Phone App for Forex Traders!

Using The Ichimoku Cloud

 Home