coding expert advisor

 

could someone please help me in coding this:

 double lotsoptimized(){

double lot;
if(stoploss>0)lot=AccountBalance()*(risk/100)/(stoploss*pt/MarketInfo(Symbol(),MODE_TICKSIZE) 
*MarketInfo(Symbol(),MODE_TICKVALUE));
else lot=NormalizeDouble((AccountBalance()/lotsize) 
*minlot*risk,lotdigits);
return(lot);

 

into the file for risk management so that

 2% Per Trade Risk Formula

Account size x 2% = Risk Amount
$10,000 X 2% = $200

 If you had a $10,000 account balance and 200 pip stop and selected 2% risk per trade, you would be able to trade only 0.1 lots because 0.1 lots stopped out at the 200 pips stop loss would be $200 or 2%

Files:
EA1.mq4  23 kb
 
When posting code sections, please use the SRC button (located at the top of the comment entry area next to the camera icon).