Request/suggestion for "Close partially (group of trades)" block
-
Hi, fxDreema,
I would like to request/suggest, if not too much of a trouble, the creation of a block "Close partially (group of trades)".
The idea is that it will be a more precise partial close (with regard to the total position) than partially closing each trade and the rounding effects the current process has.
Example:
we are long
0.01
0.01
0.01
or total long of 0.03 lots.If we need to close 67% of that position and we use "close (partially)" block, the EA will close:
0.01 of 0.01
0.01 of 0.01
0.01 of 0.01
i.e. all the position will be closed out, instead of the needed 0.02 lots out of 0.03.The new block could start closing out positions one by one starting from the oldest/ or newest/ or most profitable/ or least profitable until it reaches the desired level.
Thanks in advance
-
This is crearly a great challenge for miro and/or roar :D.
-
-
Here: https://fxdreema.com/shared/ZVBBYk4M
1st loop: calculate the total lot size of all trades
2nd loop: start closing trades by some order, profitable first in the example
3rd loop calculates the current total size -> when current size is less than 67% of the original, break the 2nd loop and everything stopsIt's just a rough example, not very optimized, in fact I'm almost ashamed of that garbage algorithm lol

-
@roar Special thanks bro, You responded so fast. You are a gem. I am total newbie as far as coding is concerned but I am aware of this strategy to close orders and felt this one needed some heavy techie guidance. Let's see how it works.I hope the person who posted this will share the the code flow with us, as per your guidance.
-
Just curious. Why all those blocks on the 'On Timer' Tab? I never use that tab because I don't know what it it for

-
@l-andorrà
On Timer is similar to On Tick, the code just runs on every given time interval, instead of on every tick.
You can put the same blocks to On Tick as well.I used On Timer with 1 second setting to test the logic. It was late NY market session and there were no ticks happening, so On Timer was just a quicker way to test.
You can adjust the On Timer interval from the Project options

-
Although I am not a programmer, a friend of mine who is told me once that no EA can work without a tick arriving to the platform. Is 'On timer' emulating/simulating ticks in a way they are considered as such by the EA, maybe? Just curious
