Writing an advisor for MetaTrader 4. Part 1

 

No matter how you talked about the importance of fundamental analysis to evaluate and predict the foreign exchange market, and the opportunity to evaluate the market through technical analysis very, very promising. Ask yourself the question: "And what, in essence, is a fundamental analysis of forex?" Fundamental Analysis is a measure of currency market news, circumstances which are incorporated in its basis, the price range of trading tools.

 

But the advantage of technical analysis in this case consists in the fact that many forex indicators allow very successfully to analyze the data that already exists in the market due to fundamental factors. For this reason, the most important task in this case, the trader is the ability to monitor and analyze the signals which are fed through various technical means. These tools include advisor forex.

 

The set of elements, which include a set of specific indicators, rules of use, the rules of interpretation of signals from these indicators and characteristics of their functioning at different timescales, coupled with a dose of cash to use every sales transaction is called a trading system. Any trading system - is a tangle of interrelated information, the effectiveness of which must be proven in practice. The practice of bygone days. In this case, it is understood that all signals, all interpretations and all the nuances that are inherent in the trading system should be tested on historical data. And here Counselor Forex plays a major role.

 

If you are already trading on the forex market and understand well what is at stake, you must understand that all indicators forex, inlaid into the trading system must be "sharpened" by certain features of the currency market. These features include a time interval of trade, market volatility, liquidity of the currencies that are traded - is only a few factors that influence the behavior of indicators. But to ensure that the indicators give a good return, you must correctly configure advisor forex, ie properly configure and test the functionality of the indicators on historical data. This is done in order to define optimal values for the indicators.

 

Suppose that in your arsenal of many indicators forex, you need to check, test and classified according to the results obtained. Now imagine how much time would it take to for each indicator forex select optimal parameters of its use. Of course, this may require not only months but years. Lesson, tedious, laborious, but extremely useful. Why? Yes because as a result of this work you will get invaluable experience. But we do not really know. It goes on how this is useful, and how to facilitate this work, significantly saving your own time.

 

To begin, we note that the process of conversion parameters is rather complicated. He, of course, can and automate, but we adhere to the rule never to trust completely control the outcome of the computer. Computer program itself should undertake the routine work for you, but "rake" the results and make the correction you have to yourself.

 

With trade-analytical MetaTrader 4 you have the opportunity to write and test on historical data, forex advisor, which is used to create mechanical trading systems.

 

Then all the work to create a forex advisor we break on the items.

 

1. Go to the program editor MetaEditor 4. Open the "File" and select "Create". Next will be "Wizard advisor. Select the type of adviser and click "Next". Then you'll be in the information window, where it will be necessary to make these labels forex advisor: the name of advisor, site, etc.

 

2. Now you need to edit the advisor forex. Must add its parameters to subsequently attach it to the schedule of prices. This will transmit the program specific information.

 

3. Pay attention to the table entitled "Parameters". To her right is a button "Add". Press this button and see that we have a new option «Paraml». This parameter is of type int, which means that this parameter is an integer and has no initial value specified. Then you can edit the data in this parameter. You can do this by clicking the mouse on the appropriate field of the table. Then change the name of the parameter «Stop Loss», the type of the parameter is defined as the double, and define the default "5". Complete editing by clicking on the button "Finish". Now our Forex Advisor is the basic code.

 

4. After that we face will be heading, where we fill in the data: name, author, and links to resources. Next to us there is information on the global variable and function parameters blank «start», «deinit» and «init». Those parameters, which we completed in the preceding paragraph for the parameter StopLoss, namely «init» contains information specified by us: «double», and the value 5.

 

5. For the function «init» could indicate a much more options. In this case, you must understand that the more parameters we ask for this function, the more global counterparts (codes) we obtain. Twins would be for each such code. After work "Wizard advisors" can remove unnecessary global variables.

 

Now we digress a bit and consider the values of the functions init, deinit, and start

 

Function init

 

This function is needed in the following cases:

 

• when there is a recompilation of the program in MetaEditor

• when we connect to the schedule advisor forex

• When we change the trade account

• when we change the time period of the schedule of prices

• when we change the settings of the expert

• after the launch MetaTrader 4 and download historical data

 

Function deinit

 

This function is needed in the following cases:

 

• when we complete the work with MetaTrader 4, or when we close the price chart

• when we switch between trading accounts

• When we change the time period of the schedule

• When we remove a judge from the price chart

• when we change the parameters of the expert

• when we recompile the program in MetaEditor

 

Function start

 

This function automatically starts when a new tick. It is one of the main functions of an expert, because it performs the most important work at any one time. Be sure to pay attention to one characteristic feature of this function: if the new tick come and start has not yet completed its work on the previous tic, for a new tick job start function will not be carried.

 

All the above functions are the foundation of forex trading advisor.

"Forex Never Lose Trade"