lot size problem testing ea in live

 
Hello programmers! unfortunatly i have a problem with my martingale ea, during backtest ea lot size worked very well, now i'm testing it in my demo account with vps, when multiple trades occur i noticed that le last trade lot size wasn't enough to cover prevoius trades, i backtested the same trades in the backtester and the ea worked well with the right lot size. at this point i don't think is a code problem, do you have a solution to this problem?
 
Cedro:
Hello programmers! unfortunatly i have a problem with my martingale ea, during backtest ea lot size worked very well, now i'm testing it in my demo account with vps, when multiple trades occur i noticed that le last trade lot size wasn't enough to cover prevoius trades, i backtested the same trades in the backtester and the ea worked well with the right lot size. at this point i don't think is a code problem, do you have a solution to this problem?

It may depends on a lot of factors.

From a purely theoricetical approach, if your SL = TP and you just double the lot size, you can't fully cover losses because higher lots means higher commissions/spreads. For making it working consistenly you should use some more points for TP rather than for SL, it can be a little difference, but enough to make the martingale sequence conssitent.

Then, in a real environment you need to take care also of execution and slippages, because few points worse in price execution will means to break the consistency of the strategy and may lead to incomplete loss recover. Also, if your trades goes overnight, you need to take care of swap.

Which problem do you exactly see running in demo account? Lot size calculation is wrong? Or even if correct you can't fully cover the loss?

 
Fabio Cavalloni #:

It may depends on a lot of factors.

From a purely theoricetical approach, if your SL = TP and you just double the lot size, you can't fully cover losses because higher lots means higher commissions/spreads. For making it working consistenly you should use some more points for TP rather than for SL, it can be a little difference, but enough to make the martingale sequence conssitent.

Then, in a real environment you need to take care also of execution and slippages, because few points worse in price execution will means to break the consistency of the strategy and may lead to incomplete loss recover.

Which problem do you exactly see running in demo account? Lot size calculation is wrong? Or even if correct you can't fully cover the loss?

in the ea there is no sl, just recovering trades and the lot size is based on the tp, the problem was that the lot size was not enough to cover all previous trades 

 
Cedro #:

in the ea there is no sl, just recovering trades and the lot size is based on the tp, the problem was that the lot size was not enough to cover all previous trades 

If you don't take care of SL or cumulated losses amount how can you pretend to correctly cover losses?

 
Fabio Cavalloni #:

If you don't take care of SL or cumulated losses amount how can you pretend to correctly cover losses?

the sistem is based on cumulated losses and calculates the lot size based on the losses and the tp of the new signal

 
Cedro #:

the sistem is based on cumulated losses and calculates the lot size based on the losses and the tp of the new signal

So, the TP of a trade is equal to the amount of the total previous losses? It may work, but you need to be sure that you correctly calculated the cumulated losses, and you should also be aware of side effects that I explained in my previous messages.

First of all, you should set the TP after the trade is on market, to put the correct value and void the entry slippage. Anyway, you can't be sure of the entity of closing (TP) slippage.

You should always add a spare amount of points to your TP to include the possible closure slippage, but even of this, you can't be sure because you can't know in advance the amount of the slippage.

 
Cedro:
Hello programmers! unfortunatly i have a problem with my martingale ea, during backtest ea lot size worked very well, now i'm testing it in my demo account with vps, when multiple trades occur i noticed that le last trade lot size wasn't enough to cover prevoius trades, i backtested the same trades in the backtester and the ea worked well with the right lot size. at this point i don't think is a code problem, do you have a solution to this problem?

The EA should check if the calculated lot size is correct according to the symbol's min. lot, max. lot and lot step. If the calculated lot size is correct then the EA should check if the Margin for that position is available or enough.