Which EA model is best to use? - page 2

 

yes, interestingly enuff, 1000 < 2500 and [worstcase] leave only 1500 to play with.

in end each does wat they do and within own perceived comfort zone.

i prefer seeing and perceiving using expert like interrupt handler [and all that this means] - others obviously see expert much differently...

for me, i go back to my designs.

Best to all traders

 
Hello
As for 1500 ms, ordinary computers may perform millions operations per each ms.
It is well known that MetaTrader4 uses computer resources very effectively.
So in most cases run period 1000 ms for Approach 2 looks like optimum
.
Best regards
Ais

 

how can deinit() get called if in basically a forever loop in start()?

start() is a function called by the controlling MT4 system, when it wants to allow your code to run.

deinit() is a function too. The system calls it as a "courtesy" when it is stopping your code execution. You can call it if you like, and it will return to your code. It is not magic.

dotted variable names

These will come into use with MT5, to access structure elements. Ais' code will probably have to be reworked at that time. Maybe he is planning for that, I can't tell.

The current compiler is not "rigorous".

 
abstract_mind:
Which model to use Which working model is the best for running the EAs?

- approach 1: wait for each incoming tick in order to open/close/modify orders

int start()

{

// do the work here

// then go away, until the next tick comes in.

}


- approach 2: EA is always running and periodically asks fresh information from server in order to open/close/modify orders

int start()

{

__double __ask=0;

__while(!IsStopped())

__{

____Sleep(5000); // sleep sometime

____if(Market_is_closed() )

________break; // goes away. Resumes at the next tick (at market opening)

____RefreshRates(); // get fresh market information

____if(Ask==__ask) // apparently, no new info

_______continue;

........__ask = Ask; // new ask price, could also test for Bid changes

____go_trading(); // go open/close/modify

__}

}

I personally enjoy and have been using approach 1, but the eventual issue here is whether the server, for some reason, stops broadcasting ticks. There are many hypothesis for this to happen, such as in high market volatility causing overload, server’s workload in processing orders, network traffic jam, ....


In the approach 2, there is always the warranty that the EA is running and it obtains newer rates periodically in order to proceed with trading.


Conclusion: approach 1 seems the one used in every EA I’ve seen. It is the one I've used in assessing EAs. But it seems to depend on the server “benevolence” to receive ticks. Approach 2, on the other hand, seems more reliable, as it is always running and playing the game.

I haven't deeply studied this subject yet. So, I would really appreciate some wise opinions on this.

Thanks for the help. :-)

Joao

i sell a robot that i programed. it works perfectly well only when u follow my instructions. +2348036860370

Reason: