MrCoffee

Newbie
Apr 23, 2023
3
0
1
42
I love this EA and it's so close to exactly what I need however I am either missing something (very possible) or perhaps I am looking for a new condition to be added. What I am trying to do is close all open (market and pending) orders and disable auto trading if either of the following is true:

a) daily profit (realized and unrealized) reaches $20 (just throwing a number out), or
b) daily loss (only realized loss...this is the part i'm stuck on) reaches $20

for a) condition daily profit/loss >= $20 I believe would fit the bill
for b) i can't figure out how to do this, because i only want it to be based off of realized loss. from what I can tell, everything seems to be based off equity. How can I accomplish b)?

This is the part of the manual that tells me I can't use daily to accomplish b), because it is based on floating : "The Account Protector uses server time to determine the start of the day for these conditions and includes the floating profit/loss in its calculations:" - Maybe another condition can be added for daily profit/loss that does not include floating p/l in it's calculations?
 
Last edited:

Enivid

Administrator
Staff member
Nov 30, 2008
18,614
1,366
144
Odesa
www.earnforex.com
I love this EA and it's so close to exactly what I need however I am either missing something (very possible) or perhaps I am looking for a new condition to be added. What I am trying to do is close all open (market and pending) orders and disable auto trading if either of the following is true:

a) daily profit (realized and unrealized) reaches $20 (just throwing a number out), or
b) daily loss (only realized loss...this is the part i'm stuck on) reaches $20

for a) condition daily profit/loss >= $20 I believe would fit the bill
for b) i can't figure out how to do this, because i only want it to be based off of realized loss. from what I can tell, everything seems to be based off equity. How can I accomplish b)?

This is the part of the manual that tells me I can't use daily to accomplish b), because it is based on floating : "The Account Protector uses server time to determine the start of the day for these conditions and includes the floating profit/loss in its calculations:" - Maybe another condition can be added for daily profit/loss that does not include floating p/l in it's calculations?
You can use the balance change condition, but you'd need to reset it manually once it gets triggered.
 

MrCoffee

Newbie
Apr 23, 2023
3
0
1
42
You can use the balance change condition, but you'd need to reset it manually once it gets triggered.
That's the issue, there's nothing available that is based on balance that also isn't taking into account floating pnl. I need it to only work based on realized loss.

I tried to comment these 2 lines out (I'm not a programmer at all. I only have experience with powershell scripting, I definitely don't know mql code) but now when I enable the condition, it triggers right away no matter what. So that didn't work. If anyone could suggest a code edit, I can compile a diff version of this that I could just run on another chart. I was really hopeful commenting out these 2 lines would do the trick but it didn't.

1682279287166.png
 
Mar 12, 2023
4
0
2
49
Hey.
I have two suggestions for improvements I really hope you can implement (one already suggested):
-Set a TP/SL on all purchases when they are in total profit, but TP/SL is then set against the current price so that all redeem at the same time when the price changes.
(is there any program that can do that please point me in that direction).

- the ability to set a timer on Action.
When the condition is triggered, a timer is started and if the condition is still thru after(and during) X seconds, only then does the action trigger. If the condition is not met, the timer is reset to be triggered again at the next opportunity.
 

MrCoffee

Newbie
Apr 23, 2023
3
0
1
42
That's the issue, there's nothing available that is based on balance that also isn't taking into account floating pnl. I need it to only work based on realized loss.

I tried to comment these 2 lines out (I'm not a programmer at all. I only have experience with powershell scripting, I definitely don't know mql code) but now when I enable the condition, it triggers right away no matter what. So that didn't work. If anyone could suggest a code edit, I can compile a diff version of this that I could just run on another chart. I was really hopeful commenting out these 2 lines would do the trick but it didn't.

View attachment 23908
Just an update on my request. I can't actually get the daily profit/loss to work at all on the mt4 version. So this might be a bug. I tried on mt5 version and it's working as expected. I also made a custom version with the 2 lines above edited as follows:
1682315387996.png

And this custom one works as I want it as well, only taking into account realized loss, not floating.

Are the devs of this EA able to look at the mt4 code for the daily profit/loss by currency units and see if there's an issue?
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,614
1,366
144
Odesa
www.earnforex.com
-Set a TP/SL on all purchases when they are in total profit, but TP/SL is then set against the current price so that all redeem at the same time when the price changes.
I don't quite understand how that would work. Could you please explain in details?
- the ability to set a timer on Action.
When the condition is triggered, a timer is started and if the condition is still thru after(and during) X seconds, only then does the action trigger. If the condition is not met, the timer is reset to be triggered again at the next opportunity.
OK. I will consider adding such a timer.
 

xsteedx

Newbie
May 4, 2023
1
0
1
27
I seem to be getting an error when compiling the EA, are you able to help me? The 3 errors I get when trying to compile the EA are:
Screenshot 2023-05-04 at 23.11.56.png
I'm running mt5 on Mac btw so don't know if that makes any difference.
 
Mar 12, 2023
4
0
2
49
I don't quite understand how that would work. Could you please explain in details?

OK. I will consider adding such a timer.
buy1 was made on price 1, buy2 was made on price 2, buy3 was made on price 3. the price fluctuates and when the sum of all three buys shows a total profit, then a S/L ore trailing S/L is set at the same level on all 3 buys so they are sold at the same time if/when triggered, the profit is locked in. so the three buys are treated as one.
the same on sell, so that you handle buy and sell separately.
If another buy/sell is made when the S/L is set, it is handled as a new purchase in a new "order-bundle" that is filled with new trades until they are at a profit. (does this exist in any EA?)
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,614
1,366
144
Odesa
www.earnforex.com
I seem to be getting an error when compiling the EA, are you able to help me? The 3 errors I get when trying to compile the EA are:
View attachment 23995
I'm running mt5 on Mac btw so don't know if that makes any difference.
For some reason, it thinks that 'Enable' is some kind of a function. It looks like it's some kind of a quirk of macOS. You could try renaming the 'Enable' enum here (in Account Protector.mq5) and in Defines.mqh. For example, to 'EnableEnum' or something like that. Not sure if that will help but it's easy to try.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,614
1,366
144
Odesa
www.earnforex.com
buy1 was made on price 1, buy2 was made on price 2, buy3 was made on price 3. the price fluctuates and when the sum of all three buys shows a total profit, then a S/L ore trailing S/L is set at the same level on all 3 buys so they are sold at the same time if/when triggered, the profit is locked in. so the three buys are treated as one.
the same on sell, so that you handle buy and sell separately.
If another buy/sell is made when the S/L is set, it is handled as a new purchase in a new "order-bundle" that is filled with new trades until they are at a profit. (does this exist in any EA?)
So that looks like an equity stop-loss but with some more or less arbitrary bundling of orders. I will see what can be done, but at a first glance it looks very complex to handle.
 

refjamie

Trader
May 21, 2023
5
0
6
40
I seem to be getting an error when compiling the EA, are you able to help me? The 3 errors I get when trying to compile the EA are:
View attachment 23995
I'm running mt5 on Mac btw so don't know if that makes any difference.
I seem to be getting an error when compiling the EA, are you able to help me? The 3 errors I get when trying to compile the EA are:
View attachment 23995
I'm running mt5 on Mac btw so don't know if that makes any difference.

I'm getting the same errors, but running windows not mac.

I tried changing Enable to EnableEnum but that did not work

1684697648168.png
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,614
1,366
144
Odesa
www.earnforex.com
I'm getting the same errors, but running windows not mac.

I tried changing Enable to EnableEnum but that did not work

View attachment 24115
Make sure you copied all the files from the archive to your MetaTrader 5 Experts folder because "Enable" is defined in the "Defines.mqh" file which is bundled with Account Protector.
 

refjamie

Trader
May 21, 2023
5
0
6
40
Make sure you copied all the files from the archive to your MetaTrader 5 Experts folder because "Enable" is defined in the "Defines.mqh" file which is bundled with Account Protector.
Thanks for the reply, sadly I do have all the files;
1684756783768.png
I've seen one suggestion to compile with no optimisation, but that sadly did not work either
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,614
1,366
144
Odesa
www.earnforex.com
Thanks for the reply, sadly I do have all the files;
View attachment 24123
I've seen one suggestion to compile with no optimisation, but that sadly did not work either
And if you try to open Defines.mqh in MetaEditor and press Compile there, what does it say? It won't compile an .ex5 out of it, but it will check it for errors.