Quick Question
-
Hi,
I have an EA that executes trades whenever certain buttons (Buy/Sell, etc.) are being pressed on my MT5 chart.
I wonder if there's any way to create a button that will move the stop-loss of all the active positions to break-even. Once this is done, I'd like my EA to completely ignore those positions - none of the condition blocks in the EA will be able to affect the break-even positions anymore, none of the buttons will trigger anything on the break-even positions anymore, etc.)
I'm not very familiar with groups (the EA doesn't initialize any group), but maybe I could find a solution using them. The project is pretty large so I don't think it would be useful to share a link since it would take some time for you to get an idea of what's going on there.
Thank you very much in advance any help!
-
@tpt Buttons can do anything, set up a small project just doing the one thing you want.
-
@jstap said in Quick Question:
set up a small project just doing the one thing you wan
https://fxdreema.com/shared/roqGXazze
I'd like to have a break-even button. I know how to design it, but I'm not sure how to configure it. Whenever there's an active trade opened by one of those two buttons (Buy/Sell), I'd like to be able to break it even using the break even button. Each time there's one or more active broken-even trades, I'd like them to not be taken into account by the 'No Position' block, or any other conditional blocks in the project.
I will store the open price and the stop-loss of each trade into two variables to make sure they are break-even. But how can I separate those from the EA and its functions afterwards?
-
@tpt When is your button drawn? It should draw on init, so it can be used on tick and redrawn. As you have it in a separate tree moving to BE then being redrawn.
-
There it is: https://fxdreema.com/shared/oWCW0R1N
There's no BE button in the project yet. For the moment I'm just interested in the way I can implement my idea.
-
@tpt Draw button on int, once you click what is on tick will activate, then redraw button or change aspect with code.
-
@jstap What blocks should I add in the break-even button tree (on tick) in order to keep all the trades that are break-even separated from my EA functions?
Is it possible to add those trades into a separate group? Or to add a comment on each trade and then filter to keep them away from the other conditions in the EA?
-
@tpt The priciple is the same, get your buy/sell working, then you can add the BE button, in BE block have minimum settings in so when button pressed be activates and redraws button off, once working buy/sell should be copied to on chart and on tick put beneath a testing block.
-
@jstap I understand, thank you! How about having one broke-even trade and another trade with a stop-loss in place, both running at the same time. Can I apply the conditions above a 'Positions Count == 1' block only to the second trade (the one with a stop-loss different from the open price)?
-
@tpt If trade is placed with a different group, you can use this to control the trade.
-
@jstap I'm sorry, but I know nothing about groups and couldn't find useful information in the documentation.
Would it be possible to add the broke-even trades into a group and let the EA work by having all the other blocks' Group input field blank? If so, how?
Would the 'Position stops modified' block be useful on the 'on Trade' tab in achieving this?
Thank you for your effort!
-
@tpt Blank =0 most blocks have group, when a trade is placed you can add a group number, then add this number to other blocks, and only this group will be controlled.
-
@jstap Yes, but my question is how to change the position's group after the stop-loss moves to break-even? For example, a buy position is opened in group '1'. How do I move it to group '2' when stop-loss becomes equal to the open-price?
-
@tpt You can't, if placed as 1, it stays as 1.