Download MetaTrader 5
To add comments, please log in or register
Thousands of developers have already published their products in the Market. Join them!
hatlle
68
hatlle 2013.02.13 17:47 

I am trying to partially close a position, but I'm getting a lot of 10019 errors ("There is not enough money to complete the request") in backtest.

It is most likely that I am using the wrong volume when I try to close, and trying to close the existing order with more volume than it already has. (I am using a virtual order handling system because more than one EA is making trades on the same symbol simultaneously. I could check to make sure that my closing volume is not greater than the volume of the existing position, but that might hide an underlying problem that I would like to try and solve first).

So it occured to me that perhaps MT5 will only let me close a position if I have enough money to open the new "counter" position. Is this correct? After all, the command for closing is just the command for opening, so perhaps MT5 can not distinguish between an order being sent to open a new position and an order being sent to close an existing position. It should rightly stop me from opening a new position if I do not have the money, but it surely should not require that I have x amount of money in my account just in order to close an existing position.

I could not find anything specifically stating this. Can anyone confirm that sending an order when closing a position does not actually require the money to be in the account in the same way as opening a position with the same volume would? (I've tried testing it but I keep coming up with the same error, which could just be my bad code).


phi nuts
2184
phi nuts 2013.02.13 19:16  
hatlle:

I am trying to partially close a position, but I'm getting a lot of 10019 errors ("There is not enough money to complete the request") in backtest.

It is most likely that I am using the wrong volume when I try to close, and trying to close the existing order with more volume than it already has. (I am using a virtual order handling system because more than one EA is making trades on the same symbol simultaneously. I could check to make sure that my closing volume is not greater than the volume of the existing position, but that might hide an underlying problem that I would like to try and solve first).

So it occured to me that perhaps MT5 will only let me close a position if I have enough money to open the new "counter" position. Is this correct? After all, the command for closing is just the command for opening, so perhaps MT5 can not distinguish between an order being sent to open a new position and an order being sent to close an existing position. It should rightly stop me from opening a new position if I do not have the money, but it surely should not require that I have x amount of money in my account just in order to close an existing position.

I could not find anything specifically stating this. Can anyone confirm that sending an order when closing a position does not actually require the money to be in the account in the same way as opening a position with the same volume would? (I've tried testing it but I keep coming up with the same error, which could just be my bad code).


Nope, I just try that.

I open demo account with leverage 1:500 and account deposit $ 300 (just type in the deposit you want). I have a "not enough money" when I try to open buy 1.5 lot EURUSD but no problem with just 1 lot. Have the same problem when I try to open 2.5 lots sell against that 1 lot buy EURUSD but no problem when open sell 2 lots.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
hatlle
68
hatlle 2013.02.13 19:31  

OK, great. Thanks for confirming it. It must be my code :-(

Thanks!

/
To add comments, please log in or register