Semua EA yang kita memprogramkan amnya menggunakan salah satu daripada tiga jenis pengurusan wang. I don’t really like that term, walaupun. Saya percaya bahawa kedudukan formula saiz pada umumnya lebih tepat.
Pilihan yang ada:
- Saiz Lot Tetap
- Gunakan peratusan margin tersedia
- Kehilangan peratusan tertentu daripada baki akaun setiap kali stop loss yang terkena.
Pengguna MetaTrader paling biasa dengan menggunakan banyak tetap dalam mereka pengurusan wang forex. It’s far and away the most common method found in commercial EAs. If you’ve watched any of the videos on this site or spoken with me, anda tahu bahawa saya secara amnya mempunyai pendapat yang rendah paling EA komersial. Just because everyone does it does not mean that it’s a good idea!
Setiap kali pesanan pelanggan menyebut idea menggunakan input Risiko untuk mengawal saiz lot untuk pengurusan wang mereka, ia biasanya bermakna untuk menggunakan peratusan yang dipilih margin yang ada. Katakanlah, contohnya, bahawa anda perdagangan yang $10,000 akaun pada 1% margin (100:1 leverage) dan mahu menggunakan 2% margin boleh didapati di mana-mana perdagangan diberikan. Jika anda tidak mempunyai posisi terbuka, maka margin untuk digunakan adalah $10,000 * 2% = $200.
Saiz lot adalah hasil formula berikut:
Lot = Margin untuk Menggunakan / Margin yang diperlukan bagi setiap lot standard
Kembali kepada contoh kita, anda hanya pasangkan nombor:
$200 / $1000 setiap lot standard (100:1 margin) = 0.2 banyak, yang 2 lot mini.
Kod MQL4 untuk ini adalah
double lots = (AccountFreeMargin() * Risk) / MarketInfo( Symbol(), MODE_MARGINREQUIRED);
Kelebihan kaedah ini adalah bahawa saiz lot kekal konsisten sekatan perubahan dramatik dalam margin tersedia. I don’t actually see that as an advantage, tetapi ramai peniaga seperti melihat saiz lot yang sama pada kebanyakan dagangan.
Kelemahan banyak. Jika anda suka untuk berdagang di leverage tinggi dan perdagangan banyak instrumen yang berbeza, anda boleh dengan mudah mendapatkan diri anda ke dalam panggilan margin. Jika strategi anda memerlukan meletakkan berhenti berdasarkan tindakan harga, jumlah yang hilang akan berbeza-beza mengikut mana perhentian itu diletakkan. Beberapa perdagangan akan kehilangan $20 manakala yang lain hilang $100.
double lots = Risk * AccountEquity() / MarketInfo(Symbol(), MODE_TICKVALUE) / Stop;
Kegemaran saya kaedah pengurusan wang forex adalah untuk memilih saiz lot saya berdasarkan kerugian ekuiti jika berhenti saya terkena. Jika saya mengambil risiko 0.5% pada $10,000 akaun dan stop loss saya 20 pips jauh, maka saiz lot yang dikehendaki adalah
lot = 0.5% * $10,000 / $10 setiap tandakan setiap lot standard / 20 pips = 0.25 banyak, atau 2.5 Mini banyak
Saiz banyak berkurangan setiap kali stop loss jarak kenaikan, dan begitu juga sebaliknya. A 60 stop loss pip memerlukan saiz lot daripada
lot = 0.5% * $10,000 / $10 setiap tandakan setiap lot standard / 60 pips = 0.083 banyak, atau 0.8 mikro lot selepas mengambil kira penggenapan.
Saiz lot yang berbeza-beza mendorong kebanyakan peniaga gila. Saya percaya rasional seperti mengabaikan logik perdagangan. Trading adalah hasil statistik, pengagihan peristiwa yang secara teori mengembalikan hasil bersih lebih besar daripada sifar. Kami menyeru keuntungan ini dalam kehidupan seharian.
Jika sistem trading anda adalah x% tepat dan anda tahu faktor keuntungan yang lebih besar daripada 1, mengapa di bumi seorang peniaga tidak berdisiplin akan bertaruh dolar jumlah berbeza pada setiap perdagangan adalah di luar saya. Kesannya adalah tidak berbeza daripada secara rawak memilih untuk bertaruh $10 pada perdagangan ini dan $100 pada seterusnya. Rawak, sistem-kurang pengurusan wang kedudukan memilih saiz bagi sistem perdagangan anda akan mengatasi yang bagus, even distribution that you’re expecting from the signals.
mperk berkata
Hello,
The problem I have is that I need to calculate lot size based on a set percentage of USED MARGIN. The reason being that I trade 12 currency pairs with a recovery system. I’m having a difficult time working backwards, for some reason.With the following inputs how is Lot Size calculated based on a set percentage of USED MARGIN:
Standard lot = 100,000
Leverage = 50
Account Equity = $10,000
Used Margin Risk max per trade = 5% = $500
AUDUSD = $10.00
Stop Loss = 20 pips = $200
Lot Size = ???
Terima kasih
Shaun Overton berkata
Thank you for the question. The lot size is
used margin * leverage
$500 * 50 = 25,000 unit, atau 2.5 lot mini (0.25 lots in MetaTrader’s standard notation).
swiz berkata
Hi,
can you write MM like this:
Risk=5 means stop loss = 5% of account balance
terima kasih
Shaun Overton berkata
Hi swiz,
Ya, this is possible to do. Are you asking me something specific? I get the feeling that maybe I didn’t understand you correctly.
Milton Pang berkata
do you recall John Burch from forex-tools-cafe.com? He created trademan v4 which looked for the past highest high and low and set those as sl and trade position size to give the amount of lots for the trade. I think he might of passed on but his website still exists and the software sells for a cool $18 dolar.
BTW your enthusiasm for what you do rather infectious.
Milt
Shaun Overton berkata
Terima kasih, Milton!
Thomas Ng berkata
Talking about this line: “My favorite forex money management method is to select my lot size based on the equity loss if my stop is hit.” How would you describe it in MQL4 though?
Shaun terima kasih….hope you don’t mind to share the code
PS you got a good EA there but it is very unfortunate you only open a MAM or PAMM account
Shaun Overton berkata
Terima kasih, Thomas. The code is already in the middle of the article in a different font. Please look again.
David berkata
Hi Shaun,
I’m trying to figure out how to calculate below figures with a ratio of $500:0.01micro lot
Account Balance = $500
Leverage = 200
Risiko % = 10
can you please give me a formula with every $500 peningkatan, lot size increase by 0.01 micro lot?
Shaun Overton berkata
Hi David,
Thanks for asking. You’re making it more complicated than it needs to be. Leverage and risk are extraneous variables for the equation that you’ve proposed.
The formula is:
$500 (ekuiti akaun) * 0.01 banyak / $500 = 0.01 banyak.
If your account equity grew to $1,200, the formula gives you:
$1,200 * 0.01 banyak / $500 = 0.02 banyak (I rounded down).
I hope that helps.
MOHAMMED berkata
Well is educative
Shaun Overton berkata
I’m glad you learned something.
Sam Trinston berkata
Your formula (and weakness in MT4) is that one alwats needs to calculate LOTS – which doesn’t help when trading a multi-instrument portfolio. Sebagai contoh 1 lot of EURUSD isn’t the same as 1 lot of GBPJPY – yang, they expose different quantities of USD$ to the market. So if you are looking to create a system that ensures you expose USD$x then the formula becomes a lot more complex
Shaun Overton berkata
Sebenarnya, that’s not the true. The formulae provided use MarketInfo, which returns the values in terms of the account currency. It already compensates for multiple instruments and currencies.
regani berkata
thankq .. more use ful infomormation.. use full to me thankqs
Shaun Overton berkata
I appreciate you letting me know. It’s feedback like that that keeps me going.
Andrea berkata
i try your formula
lot = 0.5% * $10,000 / $10 setiap tandakan setiap lot standard / 20 pips = 0.25 banyak, atau 2.5 lot mini
but if i calculate it
0.5*10.000/10/20 = 25 tidak 0.25
it’s wrong, how i can correct?
Shaun Overton berkata
0.5% needs to be 0.005.
Philipp berkata
Hallo Herr Shaun Overton,
ich habe auch ein Problem. Vielleicht könnten sie mir beim Code helfen:
Gehandelt wird auf der Dax.
Long Trade: 3% Risiko pro Trade – Position sollte auf 0,10lot auf / abgerundet werden. SL ist -15Pips
Short Trade: 4% Risiko pro Trade – Position sollte auf 0,10lot auf / abgerundet werden. SL ist -20 Pips.
Danke für Ihre Hilfe!
Shaun Overton berkata
Make sure that your stop loss is a positive number. You wrote a negative number in your post.
The formulas should work on the DAX or any instrument. It’s not FX specific.
Andrew Coles berkata
It is often easier to specify Stop Loss as a Rate difference, Dgn kata lain. from the current Ask or Bid Rate to a Support or Resistance Level respectively, rather than in Pips. This is typically how an EA would form the Stop Loss Value, or alternatively as some (sub one) gandaan Purata Julat Benar.
Here is a minimal EA, to demonstrate Lot size Calculation. It includes normalization of the raw Lot size formed into Lot Step sizes the Server will accept, within minimum and maximum Lot sizes also.
Example Balance Risk and Stop Loss are provided as input Statements, for ease:
#property strict
input double StopLossRate = 0.00500; // Stop Loss with 50 Pips (Non JPY)
input double Balance_Risk = 0.012; // 1.2% of Account Balance risked
//+——————————————————————+
//| Expert initialization function |
//+——————————————————————+
void OnInit()
{
double tickVal;
double powTerm;
double rawLots;
double stpLots;
double lotSize;
double maxLots;
tickVal = MarketInfo (NULL, MODE_TICKVALUE);
Print (“TICKVALUE = “, tickVal);
rawLots = (Balance_Risk * AccountEquity() * Titik) / (tickVal * StopLossRate);
Print (“rawLots = “, rawLots);
stpLots = MarketInfo (NULL, MODE_LOTSTEP);
lotSize = stpLots * NormalizeDouble (rawLots / stpLots, 0);
Print (“Normalized lotSize = “, lotSize);
jika (lotSize maxLots)
{
lotSize = maxLots;
}
}
Print (“Trade lotSize = “, lotSize);
}
//+——————————————————————+
//| Expert deinitialization function |
//+——————————————————————+
void OnDeinit(const int reason)
{
//—
}
//+——————————————————————+
//| Expert tick function |
//+——————————————————————+
void OnTick()
{
//—
Shaun Overton berkata
Thanks for adding this!
Andrew Coles berkata
[Private Note]
It seems as though the .LT. sign on the minimum Lot Size stripped out some of the submitted code.
It might be easier to send you the MQ4 File, if you think it might be helpful to post, or expand your already very helpful Page.
Yang “powTerm” Variable can be removed. This was just a Test-bed for an EA written, that runs on M15 Time Frame. Very challenging to get into profit. I wanted a lot of Trades, for rapid Equity growth.
I had considerable problems getting the MT4 Back-tester to work. Eventually achieved a Profit Factor of 1.29 lebih 7 Month Back-test with a few combinations of Parameters.
I could not get a Break Even Stop Loss to work in the Back-test EA Version. The operational EA is radically differently coded (written for real-time, with fault tolerance).
Expect to go Live shortly, if forward Demo Test is consistent with the Back-test Results. Currently migrating the Entry Filters proven in the Back-test EA, into the Operational EA. The latter has already run (with minor Bugs), at a small loss on Demo.
Calvin berkata
Please do share your code snippet. Terima kasih!
Ilan Tree berkata
I added a post in my recent blog discussing some useful MQl4 functions when verifying and calculating lot size based on currency and risk parameters – http://www.ilantree.com/useful-mql4-lot-size-functions/, happy to exchange ideas with you.