Account Protector

Let me know if you are curious how AI (Deep Seek)analyzes your suggestion for fun's sake.
Sure! You can send it to me via a direct message.
On a side note, I find out that many of the buttons and check boxes of AP, become unresponsive or probably inconsistently responsive, when pasted onto the charts for a little while. I wonder if there is a problem with my computer and if anybody else has ever reported this.
No, I never encountered anything like that. Please let me know if you find some more or less reliable steps to reproduce the issue. Thank you!
 
Just sent you the direct message.

Regarding those glitches. It's there almost every time like I described. I am not that concerned because I have not got to used it on a live account. I just don't know how I could reproduce it and show it here. I don't want to video record it, at least for the time being. I am still figuring out how to set up that trailing stop thing. But thank you so much again Enivid.
 
Going around in circles trying to simply set a daily loss percentage of balance at 5% loss. Done various testing with greater than / less than and a positive or negative value and not working correctly.

Can someone please advise how to set a daily 5% loss please? (Whislt allowing over 5% profit)
 
Going around in circles trying to simply set a daily loss percentage of balance at 5% loss. Done various testing with greater than / less than and a positive or negative value and not working correctly.

Can someone please advise how to set a daily 5% loss please? (Whislt allowing over 5% profit)
You need to set the 'Daily profit/loss <= % of balance' to -5. Like this:
1764749207452.png
 
Hello,

I have identified an issue with the balance calculation in the Account Protector (I am using the latest version, 1.13).

My current balance is as follows:
1765406571033.png

However, the Account Protector displays the following:
1765406617352.png

I understand that the calculation is based on the previous day’s balance, which is absolutely fine.
The problem is that the Account Protector appears to subtract the Credit from the balance.
The correct previous-day balance should be 18001.69, not 16501.69.

Can you please review and fix this issue?

Thank you.
 
Hello, I'm happy to join the community.

I'm using Account Protector on the latest version of MT4. I only have the "Floating loss rise to currency units" condition active, and the first three actions are active too.

With Account Protector and Auto Trading active, I changed the condition to a higher value. At that moment, the floating was at -90, and the value I entered in the condition was 7,000. As soon as I finished entering the condition value and tab to another field, Account Protector triggered and executed the actions, closing all active operations. That wasn't what I wanted.

What should I do to prevent this from happening?

Thank you in advance.
 
Hello, I'm happy to join the community.

I'm using Account Protector on the latest version of MT4. I only have the "Floating loss rise to currency units" condition active, and the first three actions are active too.

With Account Protector and Auto Trading active, I changed the condition to a higher value. At that moment, the floating was at -90, and the value I entered in the condition was 7,000. As soon as I finished entering the condition value and tab to another field, Account Protector triggered and executed the actions, closing all active operations. That wasn't what I wanted.

What should I do to prevent this from happening?

Thank you in advance.
What was the value before you entered 7,000? What was the output in the Experts tab log?
 
What was the value before you entered 7,000? What was the output in the Experts tab log?
The value before was 4.200. I'm not sure what is the output in the Expert tab log. If you mean the log file, I'm afraid that I don't have it since I had change the VPS where the MT4 was running in that moment.
 
Hello,

I have identified an issue with the balance calculation in the Account Protector (I am using the latest version, 1.13).

My current balance is as follows:
View attachment 35331

However, the Account Protector displays the following:
View attachment 35332

I understand that the calculation is based on the previous day’s balance, which is absolutely fine.
The problem is that the Account Protector appears to subtract the Credit from the balance.
The correct previous-day balance should be 18001.69, not 16501.69.

Can you please review and fix this issue?

Thank you.
That's weird. Currently it calculates that starting balance value this way:
It gets the actual account balance value - in your case that would be 18 423.60 - then it calculates the realized profit/loss profit since the start of the day and subtracts that value from the balance. When calculating the realized profit/loss value, it ignores all deals that aren't either buy or sell deals (so, balance deals for example are ignored). Could you please show how your History tab looks when switched to the Deals view?
 
The value before was 4.200. I'm not sure what is the output in the Expert tab log. If you mean the log file, I'm afraid that I don't have it since I had change the VPS where the MT4 was running in that moment.
The Experts tab log is this:
1765464449087.png

Unfortunately, without the log there isn't much I can do since I cannot reproduce the issue.
 
That's weird. Currently it calculates that starting balance value this way:
It gets the actual account balance value - in your case that would be 18 423.60 - then it calculates the realized profit/loss profit since the start of the day and subtracts that value from the balance. When calculating the realized profit/loss value, it ignores all deals that aren't either buy or sell deals (so, balance deals for example are ignored). Could you please show how your History tab looks when switched to the Deals view?
It is strange because I understand the first part of your message: "It gets the actual account balance value - in your case that would be 18 423.60 - then it calculates the realized profit/loss profit since the start of the day and subtracts that value from the balance"; but definitely there is a problem with the rest as it subtracts the broker Credit.

This is the Account History tab related to the Credit:
1765571787314.png
 
It is strange because I understand the first part of your message: "It gets the actual account balance value - in your case that would be 18 423.60 - then it calculates the realized profit/loss profit since the start of the day and subtracts that value from the balance"; but definitely there is a problem with the rest as it subtracts the broker Credit.

This is the Account History tab related to the Credit:
View attachment 35349
OK. Now I see the problem. Account credit isn't considered a part of the account balance by MQL5 programs, so a call to AccountInfoDouble(ACCOUNT_BALANCE) returns only 16,501.69 in your case.

I think the best solution here would be to add an input parameter in the next version of the Account Protector to either include or not the account credit in balance calculations. If you need a quick fix for the daily % profit/loss condition, you can just change the following line (#1476) in Account Protector.mqh:
MQL5:
DailyStartingBalance = AccountInfoDouble(ACCOUNT_BALANCE) - realized_daily_profit_loss_units;
to this:
MQL5:
DailyStartingBalance = AccountInfoDouble(ACCOUNT_BALANCE) + AccountInfoDouble(ACCOUNT_CREDIT) - realized_daily_profit_loss_units;
Then re-compile Account Protector.mq5. Please note that the change goes to the .mqh file, while it's the .mq5 file that gets compiled.

Please let me know if you have any questions!
 
OK. Now I see the problem. Account credit isn't considered a part of the account balance by MQL5 programs, so a call to AccountInfoDouble(ACCOUNT_BALANCE) returns only 16,501.69 in your case.

I think the best solution here would be to add an input parameter in the next version of the Account Protector to either include or not the account credit in balance calculations. If you need a quick fix for the daily % profit/loss condition, you can just change the following line (#1476) in Account Protector.mqh:
MQL5:
DailyStartingBalance = AccountInfoDouble(ACCOUNT_BALANCE) - realized_daily_profit_loss_units;
to this:
MQL5:
DailyStartingBalance = AccountInfoDouble(ACCOUNT_BALANCE) + AccountInfoDouble(ACCOUNT_CREDIT) - realized_daily_profit_loss_units;
Then re-compile Account Protector.mq5. Please note that the change goes to the .mqh file, while it's the .mq5 file that gets compiled.

Please let me know if you have any questions!
For MT4, I see this (line 1398):
MQL4:
DailyStartingBalance = AccountInfoDouble(ACCOUNT_BALANCE) - realized_daily_profit_loss_units - deposit_withdrawal;

Anyway, I prefer to wait for the new official version of the Account Protector.

Thank you.
 
  • 👍
Reactions: Enivid
I meant can the Switch be toggled to off automatically after a trigger? 🙂
I'll consider adding such a feature in the next version, but normally it's not needed. By default, all actions get disabled after triggering, and if you set DoNotDisableActions to true, then you probably don't want the AP to be turned off either.

What's your use case where you'd need it to be toggled off after triggering?
 
I'm using a grid based ea where I want to close all my trades an hour before a high impact news when the floating pnl turns green. This is currently working well. However after the news, I often turn on the Autotrading button but forgotten to toggle this ea switch to off.

I would like to keep the Actions settings as I would need to reselect 5 options each time.
 
I'm using a grid based ea where I want to close all my trades an hour before a high impact news when the floating pnl turns green. This is currently working well. However after the news, I often turn on the Autotrading button but forgotten to toggle this ea switch to off.

I would like to keep the Actions settings as I would need to reselect 5 options each time.
I assume you also have DoNotDisableConditions set to true? If you disable it, you will be able to effectively turn the EA on and off by ticking/unticking your condition's checkbox.