Skip to content
All library documents

Manual Order Entry with Risk-Based Position Sizing and Validation

Article MQL5 code base

Summary

This manual trading script places market or pending orders from a chart. Pending entries can be set at an absolute price or at a point distance from the current price, and can have an optional expiration. Stop loss can likewise be specified by price or distance; take profit is optional and can be omitted or set by price or distance.

Position size is calculated from the stop-loss distance and a risk budget, defined as a percentage of account balance or a fixed amount in account currency. A maximum risk setting can cap exposure. Before sending an order, the script checks inputs, spread, broker stop-distance rules, and free margin; it also normalizes prices and volume to the symbol and broker constraints. An optional preview shows the order and risk/reward ratio. These are described safeguards for discretionary order placement, not evidence of trading performance; the document provides no backtest results or guarantee that the configured risk will be realized under execution conditions.

Key ideas

  • The script supports market orders and pending entries set by price or distance.
  • Position size is derived from stop-loss distance and a percentage or fixed cash risk budget.
  • A maximum risk setting can limit the configured exposure.
  • Pre-trade checks cover inputs, spread, stop distances, margin, and broker increments.
  • An optional preview displays order details and the risk/reward ratio.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.