Structure and architecture of an EA

 

Hi all,

I am a veteran programmer, have learned many languages during my 35+ years in the computer industry. I have also programmed systems for trading, like OmniTrader, Bioprofit, Dakota and others. Forex is new to me. I have acquired some Forex trading methods (not programs) that I would like to program into MetaTrader in order to test how good they are. They are a bit complicated so there is a fair amount of code to write and that means that code has to be broken down to subroutines and functions.

If possible nor the main routine nor any of the functions/subroutines should be longer than one page and the action it performs should be well defined.

I have written some simple EA and a fairly complicated Indicator so I have go the basic hang of MT4.

Here is a question on Indicators. I have written one that that returns either +1, 0, -1 if a specific setup has occured. It is shown as a graph in a separate window. How should I change it so I can call it from an EA?Should it be defined as an Indicator at all or should I define it as library routine. If I define it as a library routine it seems like I have to pass it an array of Open, Low, High and Close since the system array of these are not readily available in a library routine. I have to have the last 100 bars available in order to calculate the setup signal.

Are there specific considerations to take to ensure that backtesting works OK?

Ingvar

 
ingvar_e:
Hi all,

I am a veteran programmer, have learned many languages during my 35+ years in the computer industry. I have also programmed systems for trading, like OmniTrader, Bioprofit, Dakota and others. Forex is new to me. I have acquired some Forex trading methods (not programs) that I would like to program into MetaTrader in order to test how good they are. They are a bit complicated so there is a fair amount of code to write and that means that code has to be broken down to subroutines and functions.

If possible nor the main routine nor any of the functions/subroutines should be longer than one page and the action it performs should be well defined.

I have written some simple EA and a fairly complicated Indicator so I have go the basic hang of MT4.

Here is a question on Indicators. I have written one that that returns either +1, 0, -1 if a specific setup has occured. It is shown as a graph in a separate window. How should I change it so I can call it from an EA?Should it be defined as an Indicator at all or should I define it as library routine. If I define it as a library routine it seems like I have to pass it an array of Open, Low, High and Close since the system array of these are not readily available in a library routine. I have to have the last 100 bars available in order to calculate the setup signal.

Are there specific considerations to take to ensure that backtesting works OK?

Ingvar

Hi. You can of use stand-alone indicators from EA's with the use of the iCustom() function.

 

Thanks omelette, that was uesful information.

Ingvar

Reason: