Skip to content
All library documents

ATR-Based Stops and Risk-Sized Trade Volume

Article MQL5 code base

Summary

The document explains a MetaTrader trade function that sizes positions from a risk budget and sets stop distance using the asset’s average true range. It calculates the allowed risk as a percentage of free margin, converts an ATR multiple into stop-loss points, and uses the value per point to determine lot size. A take-profit can be set as a multiple of the stop distance, expressed in units of R.

The described function accepts the symbol, timeframe, order direction, slippage, risk percentage, ATR period and multiplier, and reward-to-risk multiple. Example scripts use a 21-bar ATR period and provide buy and sell variants, with or without a confirmation prompt. The document gives implementation settings rather than performance evidence: it contains no backtest or live-trading results. Risk percentages and reward-to-risk choices are configurable, and the suggested values are not evidence that a trade will be profitable or that the calculated risk will be realized under all execution conditions.

Key ideas

  • Position size is calculated from the risk budget, stop distance, and point value of the traded asset.
  • The risk budget is defined as a percentage of free margin.
  • Stop distance is set as a configurable multiple of ATR over a selected timeframe.
  • Take-profit distance can be specified as a multiple of the stop-loss distance.
  • The document describes implementation parameters but provides no strategy performance evidence.

Tags

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