MQL4 Function for Lotsize Calculation with AccountRisk

 

Hello,

i have codeing for myself a simple Lotsize calculation and it work good, but i think when i use other symbols like gold then this will give to much lotsize, because i dont have a pipvalue in my calculation, my calculation will give for every symbol same lotsize, can somebody helpt me to make my lotsize function better, that is calculate for every symbol the right risk percent lotsize?


Here is my current code:

   if(Stoploss>0)
   {
    double Percent=RiskPercent;
    double AllowedLoose=(AccountEquity()/100)*Percent;
    double Lots=NormalizeDouble((AllowedLoose/Stoploss)/10,2);
   }
 

Account Balance * percent = Risk = (orderOpenPrice - OrderClosePrice)*DIR * DeltaPerLot * OrderLots

  1. 10 is valid only for EURUSD on a USD account. Do it right
  2. Risk/stoploss is ignoring the spread.
  3. NormalizeDouble assumes lotstep = 0.01 do it right never use NormalizeDouble, ever.
  4. You must also verify that you have enough free margin (to open) and at most adverse excursion (mae) of ALL open orders to prevent margin call (stop out). See my lotsize code
 

Hello, can you please modify my function that it work right on all pairs or can you show me a function from you wich work right?

I have not see in your link such a function, but many different thinks.

Reason: