-->

Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

Metatrader 5 Libraries | Discover: nCalculate Lot by Percent | MQL5 Library

RobotFX curates the best open-source MetaTrader code to inspire your trading automation.

Image for nCalculate Lot by Percent
  • Checks: monitors correct prices, minimum and maximum lots.

  • Ready to use: one function call returns the lot to be sent to the market order.

  • Example of use in the code:

    // Risk 1.5% of the deposit by placing a stop loss at 1.08500
    double myLot = Calculate_Lot_by_Percent(1.5, 1.08500);
    
    if(myLot > 0) {
        // Open a deal with the calculated lot
        trade.Sell(myLot, _Symbol, 0, 1.08500, 0, "Trade with 1.5% risk");
    }

    Bottom line: this code gets rid of manual calculations and helps you maintain risk discipline in every trade. Simply plug it into your EA or script.


    Protect profits effectively with the smart Trailing Stop Expert Advisor. Advanced trailing options for MT4/MT5. See it in action.

    Thanks for reading. Discover premium MetaTrader solutions at RobotFX.

    68396

    Best MetaTrader Indicators + Profitable Expert Advisors