Skip to content
All library documents

Randomized Expert Advisor with Risk-Based Position Sizing

Article MQL5 code base

Summary

This document describes a MetaTrader expert advisor whose trade decisions are driven by a random number generator. It randomizes the position direction, stop loss, and take profit, while calculating lot size from a chosen risk percentage of free margin. Before placing an order, it checks whether the account has enough funds to open the position.

The article provides no performance results, trading rationale, or evidence that the random signals produce an edge. It also does not explain how the random stop and target distances are selected or how the risk percentage is calibrated. The EA is said to work on any timeframe, but that claim does not establish suitability across instruments or market conditions. Its useful lesson is limited to the mechanics of randomized order parameters and margin-aware, risk-based sizing.

Key ideas

  • The EA randomizes trade direction, stop loss, and take profit.
  • Lot size is based on a risk percentage of free margin.
  • A pre-trade funds check helps avoid orders that exceed available margin.
  • The document gives no evidence that random entries have predictive value.

Tags

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