Is this the correct code for calculating a lot size? - page 2

 
DxdCn:

use codes: and then publish them here for other one to check them!

--------------------------------------------

double Lots = (AccountEquity() * RiskPercentage * 0.01 ) / ( MarketInfo( Symbol(), MODE_LOTSIZE ) / AccountLeverage() );

Print("lot=",Lots , "Aeq=",AccountEquity()," ris=", RiskPercentage ," lt=", MarketInfo( Symbol(), MODE_LOTSIZE ) ," lev=",AccountLeverage() );

--------------------------------------------------

I use such code to get lots:

lot=NormalizeDouble(AccountBalance()*RiskPercentage /MarketInfo(Symbol(), MODE_MARGINREQUIRED), 1);

pls what does Risk Percentage mean and where
can i put it.

Am looking for a way to make my lot size be dynamic.

 
Hello, I want to involve SL point in determining lot size, below is my code. I found difficulties when entering 30% risk, according the report, the balance is not enough. Please correct it
   double val=MarketInfo(Symbol(),MODE_TICKVALUE);
 
   double lot=NormalizeDouble((AccountFreeMargin()*MaximumRisk)/(StopLoss*val),1);
I'm using 5K demo account.

Thx
 
Up..up.. :)
 
devilian1899:
Hello, I want to involve SL point in determining lot size, below is my code. I found difficulties when entering 30% risk, according the report, the balance is not enough. Please correct it
   double val=MarketInfo(Symbol(),MODE_TICKVALUE);
 
   double lot=NormalizeDouble((AccountFreeMargin()*MaximumRisk)/(StopLoss*val),1);
I'm using 5K demo account.

Thx


hi devilian1899,


did you finish your code? I am a beginner and am looking for an indicator/EA to help set my lot size based on risk and stop loss. I have found a few that work with my $50,000 demo a/c but they don't work with my $500 live mini a/c....

Reason: