Download MetaTrader 5

How do I convert the amount of money into lot size?

To add comments, please log in or register
mql4student
147
mql4student  

I'm trying to convert the amount of money into lotsize to buy or sell.

let's say account balance is: $1000

Lotsize risk percent is: 20

the formula I used below return the value of $20. How do I convert that into lot size?  

 Here's the code I'm working on. What am I missing?

 

 double RiskedAmount=AccountBalance()*(LotSizeRiskPercent/100)*0.01;
Carl Schreiber
7237
Carl Schreiber  
mql4student:

I'm trying to convert the amount of money into lotsize to buy or sell.

let's say account balance is: $1000

Lotsize risk percent is: 20

the formula I used below return the value of $20. How do I convert that into lot size?  

 Here's the code I'm working on. What am I missing?

 

Do you know google or the search filed (top right) here?

I'll bet it's a lot faster than waiting for someone answering your question which has been discussed here many times with solutions and code!

mql4student
147
mql4student  

I just thought about something. 

riskpercent = 20 so 20/100 =  .20 * 0.01 = .002

$1000 * .002 =  2 /100 = 0.02

 

I'm asking about the math equation, not what code to use. 

is this formula correct? 

 double RiskedAmount=(AccountBalance()*(LotSizeRiskPercent/100)*0.01) /100;
Donald Gibson
495
Donald Gibson  
mql4student:

I just thought about something. 

riskpercent = 20 so 20/100 =  .20 * 0.01 = .002

$1000 * .002 =  2 /100 = 0.02

 

I'm asking about the math equation, not what code to use. 

is this formula correct? 

double RMLotSize()
  {
/*
//-------------------------------------------------------------------------------------------------
//Risk Management - LotSize
//-------------------------------------------------------------------------------------------------
extern string Risk="Use Risk Management to set LotSize - True or False";//Alert
extern bool   Use_RiskManagement_LotSize=false;//Choose True or False
extern double Risk_Percent=2;//Percentage of Account Balance to Risk
extern string Risk_break="";//=======================================
//-------------------------------------------------------------------------------------------------
*/
//-------------------------------------------------------------------------------------------------
//lotsize based on risk capitol
   double Acct_Equity=AccountInfoDouble(ACCOUNT_EQUITY);
   double Acct_RiskCapitol=Acct_Equity*(Risk_Percent*0.01);
   double LotSize=Acct_RiskCapitol*0.01;
//-------------------------------------------------------------------------------------------------
//if lotsize is more than is permitted change the lotsize to the maximum  permitted
   if(LotSize>MarketInfo(Symbol(),MODE_MAXLOT)) {LotSize=MarketInfo(Symbol(),MODE_MAXLOT);}
//-------------------------------------------------------------------------------------------------
//if lotsize is less than is permitted change the lotsize to the minimum  permitted  
   if(LotSize<MarketInfo(Symbol(),MODE_MINLOT)) {LotSize=MarketInfo(Symbol(),MODE_MINLOT);}
//-------------------------------------------------------------------------------------------------
//if there is no orders available print Account Information and LotSize available   
   if(OrdersTotal()==0)
     {
      Print("-------------------------------------------------------------------------------------------------");
      Print("LotSize based on the Capitol available...",DoubleToStr(LotSize,2));
      Print("Amount of Capitol to Risk...",DoubleToStr(Acct_RiskCapitol,2));
      Print("-------------------------------------------------------------------------------------------------");
     }
   return(LotSize);
  }
This is what I use. Hope it helps.
Siti Latifah
10998
Siti Latifah  
may be you can see here..

https://www.mql5.com/en/code/13593
Auto MM
Auto MM
  • votes: 12
  • 2015.08.06
  • Siti Latifah
  • www.mql5.com
This script will help you calculate your lot to open position.
To add comments, please log in or register