Skip to content
All library documents

SAR Trading Example with Loss-Based Position Sizing

Article MQL5 code base

Summary

This document presents a basic automated trading example built around a stop-and-reverse indicator, alongside a function for adjusting trade size from the strategy's order history. The sizing routine scans closed orders associated with a particular strategy identifier and examines their profit or loss and lot sizes. Depending on the recent sequence, it can return the base lot size, reuse a prior lot size, or add lot sizes from losing trades. The material is aimed at developers examining an implementation rather than at traders seeking a validated system.

The author explicitly says the example is not profitable and describes it as a simple coding illustration. It supplies no market, instrument, parameter settings, test period, transaction cost assumptions, or backtest results, so its performance and risk cannot be assessed from the document. The code also does not explain the intended sizing rationale or safeguards against escalating exposure after losses. Treat the mechanism as an example to inspect and test carefully, not as evidence for a trading edge.

Key ideas

  • The trading example uses a stop-and-reverse indicator to generate its basic approach.
  • The money management function examines historical orders linked to a strategy identifier.
  • After losses, the function can accumulate prior lot sizes for subsequent sizing decisions.
  • The author identifies the example as unprofitable and intended for coding practice.
  • No performance evidence or safeguards for increasing exposure are provided.

Tags

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