account balance / equity / margin / free margin

 

I run my EA in the MT5 strategy tester and at the beginning of the test no errors are reported but then at some point I start getting always the same error : [no money] [not enough money]

I don't understand where that come from since my EA take a trade one at a time and the first time the error come here the message :


2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   current account state: Balance: 15595.25, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 15595.25, Margin: 0.00, FreeMargin: 15595.25

2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 15595.25, Margin: 15696.84, FreeMargin: -101.59

2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   not enough money [market sell 2.27 BTCUSD sl: 23118.45 tp: 22912.17]

2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   failed market sell 2.27 BTCUSD sl: 23118.45 tp: 22912.17 [No money]

2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   CTrade::OrderSend: market sell 2.27 BTCUSD sl: 23118.45 tp: 22912.17 [not enough money]


I don't have any position opened before the EA start to open this trade.

I understand that because the margin used is over my balance, the order can't process because "not enough money", but why my margin suddenly go from 0 to 15696.84 in the "calculated account state"?


 
Opening 2.27 lots requires you to have more margin that you have.

You need to do at least 1 thing: decrease lot size, increase leverage, increase balance.

You can choose :-) 
 
Fabio Cavalloni #:
Opening 2.27 lots requires you to have more margin that you have.

You need to do at least 1 thing: decrease lot size, increase leverage, increase balance.

You can choose :-) 


I understood that. And when I set the leverage to 1:500 in the Setting tab of the Tester, there is indeed no more error.


But what I want to know is : why the margin used suddenly go to 15696.84 when I have 0 position opened and 15595.25 equity (so for a 2.27 lot, I need to use a 3.3-3.4 leverage, but in the setting I need to put at 500 leverage for no error occurs)

How can I have a Free Margin of -101.59, without any position opened??
 
Fabio Cavalloni #:
Opening 2.27 lots requires you to have more margin that you have.

You need to do at least 1 thing: decrease lot size, increase leverage, increase balance.

You can choose :-) 


The question is : what happen between these 2 lines :


2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   current account state: Balance: 15595.25, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 15595.25, Margin: 0.00, FreeMargin: 15595.25

2023.01.21 13:42:29.935 Core 01 2022.07.21 22:05:40   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 15595.25, Margin: 15696.84, FreeMargin: -101.59

 

I think that message is generated to let you know that, after opening the wanted trade, the free margin will be negative, so it cannot be opened.

The problem is not that you have no free margin before opening the trade, but that the margin your trade will take is more than your free margin, so it's impossible to be opened!

Reason: