First you determine how much money to want to risk for the trade (eg 2% of AccountEquity etc). This may differ for different market conditions, strategy, etc.
this depends on the EA win
ratio, and the size of average winning trade compared to average losing
trade.. eg 100% perfect EA you'd risk all,
Then find the StopLoss size used by the EA. This may be fixed size for a simple EA, or dynamic for an EA that adapts to market conditions (eg using some multiplier of ADR, ATR, S/R levels, BB etc. - this in turn means the average losing trade size can vary a lot more )
Using the above :
Money Risked = number of lots * MODE_LOTSIZE* changeInExchangeRate
Money Risked = number of lots * MODE_LOTSIZE* ((stopLossPips + spreadPips) * PIPSize )
So
number of lots = MoneyRisked / ( MODE_LOTSIZE * ((stopLossPips + spreadPips) * PIPSize ) )
[edit#1: for clarity - I hope - Changed 'AccountLotSize to MODE_LOTSIZE]
[edit#2: Was wrong afterall. Should be *PIPSize not /PIPSize eg PIPSize maybe 0.001 ]
False! A 100 pip SL risks the same per lot on a $100 account or a $million. Money Risked = number of lots * Change Per Pip * ((stopLossPips + spreadPips) / PIPSize )
By AccountLotSize I mean MODE_LOTSIZE ? (Probably shouldnt have mentioned 'Account' but I meant the LotSize for the account type, nothing to do with the size of the account). Is that still wrong? If so I'll sit down with pen&paper, cause I need to understand this myself :)
I'll assume silence means that MODE_LOTSIZE is correct, now that I've made it clearer..
What's my mystake ?
double Account_Equity = AccountEquity();
double Lots = Account_Equity/1000;
How can I write it better ?
Thabks
Did you understand my earlier (updated) post . For MoneyManagement you generally calculate lots(position sizing) from two things the amount of equilty you want to risk, and the stop loss.
number of lots = ActualMoneyRisked / ( MODE_LOTSIZE * ((stopLossPips + spreadPips) * PIPSize ) )
Where ActualMoneyRisk is usually a percentage of your equity based on the EA win/lose ratio and expectancy etc. Or just 2% of Equity to keep things simple..
My english is not perfect, and I think my first question was no so clear. Sorry.
I 'll trying to explain better what I want exactly.
In my EA, I have simply written :
double Lots = 1;
It's ok. I have good results with my EA, but always limited in results. I know I can optimise this number of lots after each take profit or close or stop loss.
Manualy, in backtests, with (amount /1000), I tried to use an optimised size of lots (amount of my account / 1000), and I had better results. And it works always fine.
Important : "equity" is corresponding to the total of available money I have on my account, I think.
I must use it and not "balance", because it's possible i have orders not closed at the same time... or another EA who is working on the same account.
The amount of equity must replace the balance... If not, what i must to do to replace it with a better option ?
And to have the good size of the Lots, I must also open orders SELL or BUY with equity % (equity/1000 exactly) to replace automaticaly the number of Lots who is initialy "1" in this sample.
And (equity % /1000) must be now the size of the lot.How can I formulate it correctly to replace :
double Lots = 1;
Thanks for your answer.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have not a lot of experience on EAs. Only from may 2013... And I have two questions
1. I have a EA who is working fine with my personal settings.
But I have no Money Management... and best presets are only "1 lot for 1000 € or $" of money on my account...
Il want to change automaticaly this number of lots when I have more profits (or loss) on my account.
For sample... If I have 12 000 € of gains, it works perfectly with 12 lots, 100 lots for 100 000 €, etc... and it has no limit of profit on my backtests. And it can start also with only 100 € and only 0,1 lot...
How can I do to adjust itself the new number of lots ?
The original parameters are :
----------------------------
extern double Lots = 1;
---------------------------
2. The second question is :
It works fine only with EURUSD on M15 period...
Can I have an alert or specified parmaters on presets to avoid mistake ? And how can I do.
Thanks for your help.
goldy-40