@fxfun said in Help wanted, please!:
@isp00rt Hi
FIRST of all, you say you want to Close all trades, after you accumulated a certain amount of Pips from all open trades. Right?
Yes, that's exactly what I want.
IF SO, your condition to close trades, is something TOTALLY DIFFERENT from what you say you want. Your condition to close is a MA Cross!?
No. My condition to close is having at least as many pips as I specified as a target. That includes all previous closed trades that were a loss.
Also, you NULL the variables at the MA cross as well, which could happen at any time, when you don't want that.
No, no. There's no MA anywhere. This EA will be operating on a chart and I will manually operate other charts. It will control all my open and closed trades so that the final amount of pips accumulated is at least the one I specified as a target.
I don't think you need to null the variables, cause if there are non open trades, MQL should calculate that your variable for Open Pips is 0.
Interesting. I didn't consider that.
Your condition to Close should probably be something like: CurrentTotalOpenPips >= MyTargetPips
That would count all my current open trades, but I need another variable to count my closed ones (wins and loses).
SECOND, you have 2 loops + 2 modify blocks that are identical. I would delete one of loops (to simplify & make the EA faster), and add the 2 formula blocks last in the one loop.
You're right. My fault! Good idea. 
I don't understand all your variables that aren't defined, but the formula you use could also be wrong.
I need 4 variables. ProfitOpen counts the total amount of pips from current open trades. ProfitClose does the same for all my closed trades. ProfitAll is the sum of both previous ones (this one must be at least as big as the target). ProfitTemp is the way to update ProfitOpen and ProfitClose.
I believe if you start correcting the above first, you should be much closer to the solution you want, or even solve it totally I guess. You need to start there anyway I believe. Let's know how you progress.
Have Fun! 
Thank you very much for your help. I did your suggested correction, but it still doesn't work.
https://fxdreema.com/shared/hAA1LhAmc
Maybe my problem is with variables. I assume that ProfitClose will just sum up all closed trades but I'm not sure how to do that. How can a variable distinguish when a trade is open or closed? Maybe this is why it is failing. What do you think?