Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
1- I open the EA, no options are selected.
2- The I have chosen the first three option in the actions tab
a) Close 100%
b) Delete all pending orders
c) Disable autotrading

3- Then I have open four orders. Because of the spread they were all negative around -100 USD.
4- Then I have Condition tab I have chosen "Floating point rises to currency units:"
and I have not changed the value from 0 to any other value.

Then in the same moment the EA has closed all the four orders.
In the MT4 experts tab the following message appeared;
Account Protector AUDCAD M1: CONDITIONS IS MET: Floating loss rose to 0.00 USD

In my opinion
the following condition should be added (in the file Account Protector.mqh function CAccountProtector::CheckAllConditions()):

// Floating loss rose to <Actual number> <currency ISO code>.
if ((!DisableFloatLossRiseCurr) &&
(sets.doubleLossQuanUnits != 0) && // This additional validation should be done , exclude the case when it is zero
(floating_profit <= -sets.doubleLossQuanUnits))

Besides this situation all the others variables fields in the Conditions should be changed to include this new condition. To only consider it when the respective value is not zero.
I understand how this can be confusing, but that's how the AP is intended to work. The idea is that the user enters the value first and only then ticks the checkbox. Having a zero value in that condition is a totally valid situation.
1- The send email is not working, there is not place to add the destination email address. Why ?
Email address (and other related settings) are controlled via MetaTrader's options: Tools->Options->Email.
2- I would be nice if there was an option to save the configurations the user prefers.
Because every time I want to use it all the options I have selected before disappeared, specially when I have selected the "Disable autotrading" option
and I press the Auto Trading button back to on.
I'm not sure what exactly you mean here, but you might want to look at the DoNotDisableConditions and DoNotDisableActions input parameters.
3- I don't know if it makes sense, but it could be useful and option to trigger the EA only when the user wants, that is the user setups all the
EA options and only when he wants the EA will kickoff and execute the actions according to the configurations. Otherwise the EA triggers immediatly
just before you have finished all the setup steps, especially if you don't have left the conditions setup as the last step.
You mean something like a global "Enable/Disable" button? I will consider adding this. Thanks!
 

Ssantos

Trader
Feb 2, 2023
3
0
6
48
I understand how this can be confusing, but that's how the AP is intended to work. The idea is that the user enters the value first and only then ticks the checkbox. Having a zero value in that condition is a totally valid situation.

Email address (and other related settings) are controlled via MetaTrader's options: Tools->Options->Email.

I'm not sure what exactly you mean here, but you might want to look at the DoNotDisableConditions and DoNotDisableActions input parameters.

You mean something like a global "Enable/Disable" button? I will consider adding this. Thanks!
Thanks a lot for the answer.

--> "Having a zero value in that condition is a totally valid situation."

I think the user will be able to input a zero, but input a zero and then checking the option in the checkbox, in my opinion two options should be considered:
1- when you tick the checkbox and you have a zero value a message should appear
2- when you tick the checkbox and you have a zero value, nothing should happen in case you have open orders.
Because I have input a zero and then tick the chekbox and the EA automatically has removed the orders I had open. And when you are dealing with money that's not easy (although I have done it in a demo account).

Another nice to have, in my opinion, would be to not allow the user to input negative values. Specially in the conditions fields.


--> "I'm not sure what exactly you mean here, but you might want to look at the DoNotDisableConditions and DoNotDisableActions input parameters."
What I meant was an option to save to the disk your EA defaults. This way when you open the EA you could automatically populate the fields/options with your configuration.


--> "You mean something like a global "Enable/Disable" button? I will consider adding this. Thanks!"
Yes. This way you could change the options without any risk of kicking off the EA inadvertently.
The default behavior would be Disable, then only when the user selects Enable the EAs kicks off.


Thanks
 

UglyAndBroke

Trader
Feb 5, 2023
4
0
6
61
You can only simulate that via Free Margin conditions.

This can be done using the timer. But you would need to use a separate instance of the AP for that, setting GlobalSnapshots input parameter to true on both of the instances.

Not sure about this one. Is it historic highest? For the account's lifetime? Or is there some other way to determine it?
I think, would be best after, a recent snapshot of equity.
Just when the equity > snapshot, then update.

Johannes
 

UglyAndBroke

Trader
Feb 5, 2023
4
0
6
61
HI,
Could you please confirm that I not have forgotten something?
I want daily disable all when the profit or floating profit is 1% above equity snapshot,
I want daily disable all when the loss or floating loss is 4,5% below equity snapshot,
and reset at midnight all again.
So I use 2 different AP with his settings

AP1
Set file
Set file --> Global Snapshot --> true
Set file --> DoNotDisableActions--> true
Set file --> DoNotDisableConditions--> true

Conditions
Equity >= % of snapshot 1.00
Equity <= % of snapshot 4.50

Actions--> close 100% of all trades
Actions--> delete all pending orders
Actions--> Disable autotrading
Actions--> Send push

AP2
Set file --> Global Snapshot --> true
Set file --> DoNotDisableTimer --> true
Set file --> DoNotDisableActions--> true

Timer !
Use timer --> 23:59
Actions --> Enable autotrading
Actions --> recapture snapshots

Could this work like that ?
Or have you some better Ideas or suggestions.

Help is appreciated,
Thanks
Johannes
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
I think, would be best after, a recent snapshot of equity.
Just when the equity > snapshot, then update.
Hmm... That should actually be doable already. With GlobalSnapshots = true, you can set up a second AP instance with the "Equity - Snapshot" condition set to 0.01 (1 cent) and the "Recapture snapshots" action. That instance also needs to have both DoNotDisableConditions and DoNotDisableActions set to true.

It would then perpetually update the equity snapshot as it increases, while your other (main) instance will be able to work with its own conditions based on that equity snapshot.
 

RickCreation

Trader
Feb 9, 2023
8
0
17
41
Hello how could i add a boolian True/False variable so if the users wants to they can disable Account Protector on the chart so that they can preform backtest on the EA that it is attached to.
 

RickCreation

Trader
Feb 9, 2023
8
0
17
41
What does that mean?
i want to be able, to add a variable in the ea settings . so that
if True the account protector is enabled
if False the account protector is disabled.


i developed an ea for myself to use and i added the account protector into the code and it works fine during demo and live.
but i want to be able to disable it completely so that i can run backtest.


so my question is it possible to program a variable to enable and disable the account protector so that you don't see anything on the screen and it doesn't control the trades at all.

i hope i made myself more clear this time sorry about earlier if you didn't understand what i was talking about.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
i want to be able, to add a variable in the ea settings . so that
if True the account protector is enabled
if False the account protector is disabled.


i developed an ea for myself to use and i added the account protector into the code and it works fine during demo and live.
but i want to be able to disable it completely so that i can run backtest.


so my question is it possible to program a variable to enable and disable the account protector so that you don't see anything on the screen and it doesn't control the trades at all.

i hope i made myself more clear this time sorry about earlier if you didn't understand what i was talking about.
Yes, it is possible. If you managed to incorporate the Account Protector's code into another EA, you should be able to add such a controlling variable.
 

RickCreation

Trader
Feb 9, 2023
8
0
17
41
Yes, it is possible. If you managed to incorporate the Account Protector's code into another EA, you should be able to add such a controlling variable.
Great. could you maybe teach me what i should write since i am still new to mql coding.


MQL4:
bool DisableRoyal = true;     // set to "true" or "false" to enable or disable 
 
if (DisableRoyal)
{
    // code to run exitdialog.run()
    exitdialog.run();
}
else
{
    // code to not run exitdialog.run()
}

i tried to write this, but it didn't work i think its because i am trying to turn off the wrong thing, could you please help me.
thank you so much.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
Great. could you maybe teach me what i should write since i am still new to mql coding.


MQL4:
bool DisableRoyal = true;     // set to "true" or "false" to enable or disable
 
if (DisableRoyal)
{
    // code to run exitdialog.run()
    exitdialog.run();
}
else
{
    // code to not run exitdialog.run()
}

i tried to write this, but it didn't work i think its because i am trying to turn off the wrong thing, could you please help me.
thank you so much.
I am not sure how you incorporated the AP's code into your EA, but AP main operation is implemented by sequentially calling these lines in OnTick() and OnTimer():
MQL5:
    ExtDialog.RefreshValues();
    ExtDialog.Trailing();
    ExtDialog.EquityTrailing();
    ExtDialog.MoveToBreakEven();
    ExtDialog.CheckAllConditions();
So, if you wrap them in your condition, it should do the job.
 

RickCreation

Trader
Feb 9, 2023
8
0
17
41
I am not sure how you incorporated the AP's code into your EA, but AP main operation is implemented by sequentially calling these lines in OnTick() and OnTimer():
MQL5:
    ExtDialog.RefreshValues();
    ExtDialog.Trailing();
    ExtDialog.EquityTrailing();
    ExtDialog.MoveToBreakEven();
    ExtDialog.CheckAllConditions();
So, if you wrap them in your condition, it should do the job.
i wrote both in Ontick and OnTimer this


MQL4:
void OnTimer()
{
 if (DisableAP)
 {
 
    ExtDialog.RefreshValues();
    ExtDialog.Trailing();
    ExtDialog.EquityTrailing();
    ExtDialog.MoveToBreakEven();
    ExtDialog.CheckAllConditions();
    ChartRedraw();
   }
   else
   {
 
   }
}
but it didn't disable it and yes i tried both True and False (i am in mql4 not mql5) the AP window still pops up when hitting apply EA to chart.
 

Enivid

Administrator
Staff member
Nov 30, 2008
18,534
1,355
144
Odesa
www.earnforex.com
but it didn't disable it and yes i tried both True and False (i am in mql4 not mql5) the AP window still pops up when hitting apply EA to chart.
It won't remove the panel, but it will disable its operation. If you want to hide the panel, you can try doing something like ExtDialog.Hide() in the else statement.
 
  • 👍
Reactions: RickCreation

letsfork123

Trader
Oct 5, 2022
5
0
17
32
hello everyone , I quickly need ap to trigger conditionce once I loose 2.5% of starting day balance and if i gain 5% of daily starting balance , what would be the best way to do this ?
 

RickCreation

Trader
Feb 9, 2023
8
0
17
41
@Enivid quick question about Account Protector is there a way to change the color of the panel, because i noticed through the account protector .mqh file i didn't see anything on how to change the color of the panel
 

CaniTrader

Newbie
Mar 7, 2023
1
0
2
63
awesome EA..account protection is one of the most important but often overlooked aspects of trading...all too many look for an EA/system that makes 50-80% a mth and think its real...lol

Anyway, a suggestion ...EP is especially important with prop funds and the max daily DD% is what usually takes out traders..so having an accurate EP limit is great.
The max daily loss DD% is calc'd from the brokers daily rollover and with this EP we need to manually select the "new snapshot of equity" button..could this be automated with an input setting where we can input the current broker reset time so the EA can then be automated to take a new equity snapshot at broker rollover?