Join & EARN

FOREX ALGOS { }

Position Sizing Logic

The rules for determining how large each trade should be (e.g. number of lots or volume). Position sizing logic is a subset of money management: it might use fixed lots, fixed fractional risk, martingale (doubling after a loss), or other algorithms. Correct position sizing is crucial – as Investopedia notes, “the single most important factor… is the size of the position you take” and position sizing “will account for the quickest and most magnified returns”.

  • Definition: Calculation of trade volume (lot size) based on strategy parameters, account equity, or risk per trade. For example, a bot might use “2% of equity per trade” or “fixed 0.1 lots.”

  • Context: Usually coded by reading account information (balance or equity) and dividing by required margin or risk. In MQL one might use AccountBalance() or AccountFreeMargin(), in cAlgo Account.Equity, and in NinjaScript Account.GetAccountValue(). The logic applies whichever money-management rule the EA specifies.

  • Example Code:

    // Use 1% of equity with dynamic lot size
    double riskPct = 0.01;
    double riskAmount = AccountBalance() * riskPct;
    double stopPips = 50;
    double pipValue = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE);
    double lot = NormalizeDouble(riskAmount / (stopPips * pipValue), 2);
    MqlTradeRequest req={0};
    req.volume = lot;
    // ... fill other fields, then OrderSend(req)
    // cAlgo: use 0.5 lots always
    int volume = 50000; // 0.5 standard lot for a currency with 100k contract
    ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, "MyBot");
    // NinjaScript: fixed 100 shares (lot equivalent) per entry
    int qty = 100;
    EnterLong(qty);

    These examples show different sizing approaches. Note that CFI’s tutorial mentions position size “determined according to risk appetite”, underscoring that sizing logic should match the trader’s risk tolerance.