Skip to content
All library documents

Random-Entry Expert Advisor with Trailing Stops and Martingale Sizing

Article MQL5 code base

Summary

This document describes an expert advisor that opens positions pseudorandomly without custom indicators. It can apply a stop loss, take profit, and trailing stop, and it tracks closed deals to identify losses caused by stop-loss execution. When a qualifying loss occurs, the next position size is increased according to a Martingale ratio. Position size can instead be set manually or calculated from a risk input, and a maximum lot limit is available.

The document explains how the program detects stop-loss closures through trade transaction data and lists its main inputs. Its only reported test outcome is that testing stopped when the reference lot exceeded the configured maximum. No evidence of profitability or risk-adjusted performance is given. Martingale sizing can make exposure grow after losses, so the described controls do not establish that the approach is safe or effective.

Key ideas

  • The advisor opens positions pseudorandomly and does not rely on custom indicators.
  • A trailing stop can modify the stop loss on open positions.
  • The advisor increases position size after a qualifying losing stop-out using a Martingale ratio.
  • It detects stop-loss closures from transaction history and offers a maximum lot setting.
  • The reported test ended after the reference lot exceeded that limit, with no profitability evidence presented.

Tags

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