Close partly volume issue
-
Hi there,
I seem to have an issue with close partly volume in a loop
Please take a look at this screen, this is how close partly is done in this EA
Now this seems to work in Backtest. On a Demo Account its closing wrong.
http://prntscr.com/20pdyzThis was 2 Lots initial size. Its closing 2x 1 Lot instead of just 1x 1 Lot (the Constant has 50 entered so it should close 50% of the volume)
Is there anything possible why this works fine in Backtest but not on a Demo / Live Account ?Cheers
Andy -
If you have trade with 1 lot, it should close that and reopen new one with 0.5 lot.
On the screenshot I can see opened trades, but how are they closed... or there are trades after closing...
By the way, go to Options -> Project Blocks: Normalize IDs
-
Thanks for the normalize IDs hint, great one ^^
I am just testing this on Demos with a colleague. We are actually confused atm, so give me some more time to test, we are not sure whats going on so I report here later

-
In MT4 you know you can have many trades at a time, but each one of them has fixed lot size. Closing part of it's volume is done with native MQL4 function, but it happens that the trade is first closed and then a new one is created (with volume size equal to the difference). So, if you have 1 lot and you decide to close 0.3 lots, this 1 lot is closed and 0.7 lots are openend. The newly created trade has different ticket number, but the same... I think it was the open time, or open price...
-
Ok this is really strange. I cannot find the error atm.
But I know what is causing the error. If I do the example with with Lot Size 2 it goes wrong, closing the full 2 lots instead of 50%
If I do the same with 1 Lot, it works perfect as we want it.
Let me write you a pm...
-
At least this one seems to work for me: http://fxdreema.com/shared/2FeRN6Cod
In demo:
2013.10.30 13:56:03 '1218115382': remainder of order #75764982 was opened : #75764983 buy 0.50 EURJPY at 135.187 sl: 134.187 tp: 136.187 2013.10.30 13:56:03 '1218115382': order #75764982 buy 0.50 EURJPY at 135.187 sl: 134.187 tp: 136.187 closed at price 135.159 2013.10.30 13:56:03 '1218115382': request in process 2013.10.30 13:56:03 '1218115382': request was accepted by server 2013.10.30 13:56:03 '1218115382': close order #75764982 buy 0.50 EURJPY at 135.187 sl: 134.187 tp: 136.187 at price 0.000 2013.10.30 13:56:03 '1218115382': order was opened : #75764982 buy 1.00 EURJPY at 135.187 sl: 134.187 tp: 136.187 2013.10.30 13:56:03 '1218115382': request in process 2013.10.30 13:56:03 '1218115382': request was accepted by server 2013.10.30 13:56:03 '1218115382': order buy market 1.00 EURJPY sl: 134.187 tp: 136.187 2013.10.30 13:56:01 Expert MT4 EURJPY,H1: loaded successfullyIn backtest:
2013.10.30 13:57:42 2013.09.11 00:00 MT4 EURJPY,M1: close #1 buy 0.50 EURJPY at 133.178 sl: 132.178 tp: 134.178 at price 133.158 2013.10.30 13:57:42 2013.09.11 00:00 MT4 EURJPY,M1: open #1 buy 1.00 EURJPY at 133.178 sl: 132.178 tp: 134.178 okAnd I always end up with 0.5 lots
