How do you calculate Lot size

 
If I want to risk 1% of my account for a trade, is there any code or function to calculate lot size
 

Hi,

What do u think of this ?

int Risk = 1; // risk = 1%

sizeLots=AccountEquity()/Close[0]/1000*Risk/100;

Later.

 
sharteel:

Hi,

What do u think of this ?


I think it's wrong . . .
 
sharteel:
What do u think of this ?

No much.

Assume trading EURUSD which moves $10 per pip per lot. If you open one lot with a 100 pip SL, you're risking $1000. Open the same one lot with a 10 pip SL and you're risking only $100.

Your Close/1000 also assumes you're using a USD account and trading some xxxUSD with standard size lots, not mini lots.

Put your stops where they need to be. and calculate lotsize from there. See my code