One Time EA

 

Hello, I`m a newbie!

I need help. I`m looking for a possibility to"tell" to my EA, that he has to open a trade only one time. I mean, if the EA found all conditions to enter the market he has to enter and if the conditions come to exit he has to exit and now NO enter again!

Thanks

 
If you only allow 1 trade open at any one time you can check all the open orders and count how many match your Symbol and Magic number, if that is less than one then you can place a new trade.
 
aldea13:

Hello, I`m a newbie!

I need help. I`m looking for a possibility to"tell" to my EA, that he has to open a trade only one time. I mean, if the EA found all conditions to enter the market he has to enter and if the conditions come to exit he has to exit and now NO enter again!

Thanks

Offhand I can think of three possibilities:

1) use a script (rather than an EA) and when it is finished it will delete itself from the chart.

2) Use a stop command, where you set a boolean variable called stop and as the first lines in your EA you test

if( stop )
   return( 0 );

3) use a self-destruct command in the EA to terminate it. (NOT RECOMMENDED METHOD as it is advanced programming)


Method (2) is probably what you need.

 
aldea13:

I need help. I`m looking for a possibility to"tell" to my EA, that he has to open a trade only one time.

How do I programmatically stop an EA from trading? - MQL4 forum
Reason: