I am really stuck...I'm trying to code an EA that will close a certain percent of a total number of lots. Example: I have positions as follows:
- Position 1 = 0.3 lots
- Position 2 = 1.2 lots
- Position 3 = 0.5 lots
- Total = 2.0 lots
when price reaches a certain point I want to close 75% (1.5) of my total lots. Clearly this could be accomplished by closing positions 1 & 2, but I don't seem to be able to get MT4 to calculate what it has closed and compare that to what is still open. It just closes everything. I am using a for loop to calculate the open lots but for some reason that loop doesn't catch up fast enough to trigger to bool: exit = false.
I've tried putting this loop in before and after the exit loop but it doesn't seem to make any difference.
Again I want it to continue closing until it reaches a user defined percent of open lots...then stop and close nothing else. Any Ideas?