MT4 adding commission to (risk) lot size calculaton.

 

I am using below code to calculate lot size before opening order, but now I changed to ECN accout that has commission.

Is it possible add commission to lot size calculation before order is open on a symbol?


double lots    = AccountBalance()*(RiskPercent/100.0)/(StopLoss*pipValue);
 
  • You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
  • Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerlot + CommissionPerLot) (Note OOP-OSL includes the SPREAD)
  • Do NOT use TickValue by itself - DeltaPerlot
  • You must normalize lots properly and check against min and max.
  • You must also check FreeMargin to avoid stop out
Reason: