Close all trades on profit
-
Hi guys. I'd appreciate some help. I am trying to close all positions once total profit for the day has been reached, and then not trade until trading hours have been reached.
I looked all through the forums and found this example:
https://fxdreema.com/shared/x75d43Fwc
But it does not work, even though I have spent hours making absolutely sure each setting was correct. It alwasy give negative values, and incorrect values based on equity-balance. Here is my version:
https://fxdreema.com/shared/vzBR3MwMb
Is there an easier way to simply close all trades on profit?
Thanks so much for your help!
-
the pink blocks are titled 'For EACH Trade', meaning, each single trade.
One way to do it would be to check equity at the start of the day, put into variable. Now check that equity as often as you need (after each trade? each tick? etc.) and compare it to the current equity. Once it exceeds by the desired amount, turn off the trade blocks and then used a once per bar on a daily time frame to turn then back on.
-
Thanks! I will certainly try that, and that's what I had hoped for, a much simpler solution.
-
@tipsywisdom Looks like that causes some weird bug where it closes each trade on the exact bar it opened on. It starts out trading normally, then with 50 bars it immediately closes each order, even though it has not reached profit target.
-

the way this is built, on every tick you are seeking to close profitable trades. The logic seems right, but I would design it so that it would close any profitable trades after all conditions of another trade are met.
get rid of once per day and use once per bar, with a daily TF selected.
-
@binarykungfu Block 20 should have to be block number 1. Then current blocks 1 and 12 should be linked below block 1 (former block 20)
-
@l-andorrà Stop trading with that modification.
-
@tipsywisdom Also starts cutting off each trade at each bar, very strange.
-
It appears as though the formula is getting the wrong numeric value. It appears to be inverted or something. Which would explain the behavior.
-
@binarykungfu ugly comment blocks are a true savior.
-
oh wait, maybe it makes more sense to say, check equity at start of the day and the compare balance.
-
@tipsywisdom Going to try it every possible way at this point. Need it to work. Course maybe I should just go back to coding it by hand, in some way's it's faster.
-
@binarykungfu Can you please share the last version to check it out?
-
@l-andorrà This is the only version that worked: https://fxdreema.com/shared/ZHE6UmM7b
-
@binarykungfu Hello, in this link is how I check for a daily profit %, the same setup can be used for fixed pips or money. link text
Hope this helps
-
Very helpful! Thanks!
-
@binarykungfu Your welcome
-
@binarykungfu Just noticed in the 1st formula it's adding, it should be dividing.