Download MetaTrader 5
To add comments, please log in or register
Write your articles using our editor. It is convenient!
Fabio Geraci
300
Fabio Geraci 2015.06.20 19:51 
Hello all expert coders,

I wrote an ea to move away from spending countless hours on the monitors. I am doing some back testing but whenever I run a back test i get the following error:
Warning : Can not execute new OP_SELL order for Symbol EURUSD. Maximum number of 1 open positions reached.

Now the strange thing is that if i run it on demo/live account, it works fine and does what is meant for. So you may ask what is the problem? Well I would like to add some more logic such as a trade manager and few more things, and guess i need to do the back testing to reach confidence to go live trading.

i have attached the code, thanks in advance for any help provided
Files:
Marco vd Heijden
Moderator
4505
Marco vd Heijden 2015.06.20 20:34  
is because of
extern int        MaxNumberofPositions = 1;          // max open positions
Fabio Geraci
300
Fabio Geraci 2015.06.21 09:56  

Hello Marco,

 

but that what i should have, one open position at the time.

Marco vd Heijden
Moderator
4505
Marco vd Heijden 2015.06.21 10:52  

it only says that when it tries to open an order but it detects there is already one order open what is the problem exactly?

if you want to change it you need to swap the flow so it first detects open orders and then places an order if 

 < MaxNumberofPositions 
Fabio Geraci
300
Fabio Geraci 2015.06.21 11:51  

thanks enlighten, i thought i added the correct function to take care of that, guess it is not implemented 

four eyes better than two 

Fabio Geraci
300
Fabio Geraci 2015.06.21 17:44  
Marco vd Heijden:

it only says that when it tries to open an order but it detects there is already one order open what is the problem exactly?

if you want to change it you need to swap the flow so it first detects open orders and then places an order if 

Marco,

 well i think i fixed the issue of opening more than one position at the time. but i actually notice that the TDI condition is not working properly, as you can see the 3rd and 4th red line should not have triggered a trade, could you advice, please?

I have attached the revised code. 

 

Files:
Marco vd Heijden
Moderator
4505
Marco vd Heijden 2015.06.21 20:17  
maybe like so
Files:
Fabio Geraci
300
Fabio Geraci 2015.06.21 22:28  
sorry didnt work
/
To add comments, please log in or register