Heeeelp! heeeelp! - page 2

 
Will this be OK?
extern int LotPercentage=10; // use 10% of balance as lot size


double LotInBalance=(LotPercentage/100)*AccountBalance(); // find the amount that is 10% of balance lets assume balance is $1000
double Lot=LotInBalance/(MarketInfo(Symbol(), MODE_MARGINREQUIRED)) // divide as you said
 
onewithzachy:
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
 
jameslarry:

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.

 
onewithzachy:

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
extern int LotPercentage=10; // use 10% of balance as lot size


double LotInBalance=(LotPercentage/100)*AccountBalance(); // find the amount that is 10% of balance lets assume balance is $1000
double Lot=LotInBalance/(MarketInfo(Symbol(), MODE_MARGINREQUIRED)) // divide as you said
 
jameslarry:

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.
 
jameslarry:
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.
 
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?

extern int LotPercentage=10; // use 10% of balance as lot size


double LotInBalance=(LotPercentage/100)*AccountBalance(); // find the amount that is 10% of balance lets assume its $1000
double LotUnits=LotBalance*AccountLeverage(); // multiply this 10% balance($100) by leverage to get lot units
double 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 ?

 
jameslarry:

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?

show me your OrderSend()