externint LotPercentage=10; // use 10% of balance as lot sizedouble LotInBalance=(LotPercentage/100)*AccountBalance(); // find the amount that is 10% of balance lets assume balance is $1000double Lot=LotInBalance/(MarketInfo(Symbol(), MODE_MARGINREQUIRED)) // divide as you said
The attachment is an indicator i didnt know where to start coz i know nothing about indicators i just started learning EAs
Alright, there's way to do this.
Open your MetaTrader folder where you install it (C:\Program Files\...) > open expert folder > open indicator folder and move or copy the attachment over there.
Open your MetaTrader folder where you install it (C:\Program Files\...) > open expert folder > open indicator folder and move or copy the attachment over there.
yer i know how to open the file with metaeditor. Will my code below return 0.1 now? And also the untested risky code gives error you cant afford minimum lot even if i set balance $5000
externint LotPercentage=10; // use 10% of balance as lot sizedouble LotInBalance=(LotPercentage/100)*AccountBalance(); // find the amount that is 10% of balance lets assume balance is $1000double Lot=LotInBalance/(MarketInfo(Symbol(), MODE_MARGINREQUIRED)) // divide as you said
yer i know how to open the file with metaeditor. Will my code below return 0.1 now?
I don't know, because I don't know the value of MarketInfo(Symbol(), MODE_MARGINREQUIRED), which depend on your leverage, and the current price of the currency you want to trade.
I have to go James, I live on different time zone you know
onewithzachy: That small. the cost of 1 lot EURUSD now - I think - is about $ 1268.78. There's plenty calculation the to be more safer.
It still gives the error. I just want to get lot from balance doesnt matter wether its safe or not i think AccountBalance doesnt work on strategy tester. Is there a way to output value of lots in chart so i can know what its returning?
externint LotPercentage=10; // use 10% of balance as lot sizedouble LotInBalance=(LotPercentage/100)*AccountBalance(); // find the amount that is 10% of balance lets assume its $1000double LotUnits=LotBalance*AccountLeverage(); // multiply this 10% balance($100) by leverage to get lot unitsdouble lots=NormalizeDouble((LotUnits/100000),2); // expected to return 0.1/* divide this lot units by 100,000(standard lot size units) and normalize to 2 decimal places to get something like 0.1 if account balance is say $1000 for use in ordersend()*/
jameslarry: Hi i would like to calculate lots such that if say account balance is $1000 to open trades with $100 in other words 10% and when the balance grows to $2000 to open trades with $200. This is some sort of incremental system that should maintain lot size of new trades at 10% of balance. How do i go about it its nowhere in mql4 book.
So $100 is your risk ? or you want to use $100 of margin ?
It still gives the error. I just want to get lot from balance doesnt matter wether its safe or not i think AccountBalance doesnt work on strategy tester. Is there a way to output value of lots in chart so i can know what its returning?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
It return in your Account currency. I gave you attachment in here https://www.mql5.com/en/forum/140034
The attachment is an indicator i didnt know where to start coz i know nothing about indicators i just started learning EAs
The attachment is an indicator i didnt know where to start coz i know nothing about indicators i just started learning EAs
Alright, there's way to do this.
Open your MetaTrader folder where you install it (C:\Program Files\...) > open expert folder > open indicator folder and move or copy the attachment over there.
Alright, there's way to do this.
Open your MetaTrader folder where you install it (C:\Program Files\...) > open expert folder > open indicator folder and move or copy the attachment over there.
yer i know how to open the file with metaeditor. Will my code below return 0.1 now? And also the untested risky code gives error you cant afford minimum lot even if i set balance $5000
yer i know how to open the file with metaeditor. Will my code below return 0.1 now?
I don't know, because I don't know the value of MarketInfo(Symbol(), MODE_MARGINREQUIRED), which depend on your leverage, and the current price of the currency you want to trade.
I have to go James, I live on different time zone you know
:D
Leverage is 1:100 i also want it to work on different leverages.
That small. the cost of 1 lot EURUSD now - I think - is about $ 1268.78. There's plenty calculation the to be more safer.
It still gives the error. I just want to get lot from balance doesnt matter wether its safe or not i think AccountBalance doesnt work on strategy tester. Is there a way to output value of lots in chart so i can know what its returning?
jameslarry:
Hi i would like to calculate lots such that if say account balance is $1000 to open trades with $100 in other words 10% and when the balance grows to $2000 to open trades with $200. This is some sort of incremental system that should maintain lot size of new trades at 10% of balance. How do i go about it its nowhere in mql4 book.
So $100 is your risk ? or you want to use $100 of margin ?
It still gives the error. I just want to get lot from balance doesnt matter wether its safe or not i think AccountBalance doesnt work on strategy tester. Is there a way to output value of lots in chart so i can know what its returning?