Total profit reduces by x % then close everything.
-
Im looking for something to effect all of the positions on the terminal when the total profit reduces by lets say 10% then it have to close every position.
Have tried different approaches using the condition block but havnt found nothing that works .
-
I would play with some variable:
Variable maxprofit:
condition: equity > maxprofit -> modify variable maxprofit to same as current equityif equity < maxprofit -> calculate the ratio with formula equity/maxprofit
if formula result is, lets say lower than 0.9 (thats 10% decrease) -> close positions
You then should reset the maxprofit to 0, to not mess up calculations in future
I hope you get what I mean

-
That was alot to take in , can you set blocks up as you described so i can see what you ment by sharing the link to it ?

I dont really know how to use vairables and modify them , and the formula block is something that i dont dear to touch haha

Hope you can help me with this one

-
Haha, okay, I see

Wait a moment, I'll build them.
Variables are some values, like constants, that store numbers
Formula is just basic calculating, plus minus multiply divide
I also avoided using variables for years because I didn't want to understand them

-
Thank you so much !

Sometimes you just need someone to show you how its done to be able to play around with it even further , and that someone is you right now

-
-
It's useful to see what the variables are at each moment - the comment block is for that
-
-
Yes, thats how you set them up.
You dont usually need to give them any values different than 0, because the ea updates them anywayAnd the names "maxprofit" and "Ratio" are just pulled from the hat, the code doesn't really care what you name them of course

-
@roar said in Total profit reduces by x % then close everything.:
Yes, thats how you set them up.
You dont usually need to give them any values different than 0, because the ea updates them anywayAnd the names "maxprofit" and "Ratio" are just pulled from the hat, the code doesn't really care what you name them of course

Its a lot to take in , but thank you for helping me out with this one !

The backtest of it seems to close everything constantly so i dont think it works quite as it should

-
Hmm, did you use the comment block, to view how the variables change?
Care to share the project so I can check
-
Changed the strategy a bit so we easier can see what its wrong

-
In condition five, I set the Ratio to be lower than 0.9 - check your terminal that the value (inp4_value) really is 0.9. You can also try some different ratio value, maybe that helps.
Does it close everything constantly, if you disable the whole variable block tree? -
I read that the comment function dosnt work in backtest , so maybe thats why ?

does it need the comment block to see and know the value of the maxprofit and ratio variables ? -
Ah, I use mt5 myself and comment works fine.
No, the comment block is just for you, for debugging
-
If you set up some trading conditions to the closing part and backtest it , do you also get that it closes the trades constantly ?

-
Aaa, I found the problem!
-
After closing the trades, you need to reset the maxprofit to 0 - otherwise the logic works only one time.
Check how I did the resetting in https://fxdreema.com/shared/6FWqaYX2b
Block #5 -
This method doesn't actually precisely answer to your question, because it works with account equity, not profit. But with some changes, the method can be applied to the profit, loss or anything you want
-
the block 5 changes dosnt show , but i assume that you write 0 in the maxprofit adjust field ?


