Contract Sizer: A Risk Management Tool with Ladder, Floor, and Breaker Protections
Info
The Contract Sizer: A Risk Management Tool with Ladder, Floor, and Breaker Protections is a Script for MetaTrader 5 that contract sizer is a tool that sizes contracts based on the account balance, providing three separate protections: a ladder, a floor, and a breaker. These protections work together to manage risk.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Script works exclusively on MetaTrader 5 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL5/Scripts folder via File ? Open Data Folder in MetaTrader 5.
How to Install and Use Contract Sizer: A Risk Management Tool with Ladder, Floor, and Breaker Protections
1. Installation: Move your script file into the MQL/Scripts directory and restart the platform.
2. Execution: Drag the script onto a chart; it will perform a one-time action, such as closing all open orders or clearing chart objects.
3. Editing: Use MetaEditor (F4) to modify code, click "Compile," and verify no errors appear in the terminal before running.
4. Removing: Scripts stop automatically, but you can remove them manually by right-clicking the chart and choosing "Remove Script."
Frequently Asked Questions
Q: How are scripts different from EAs? A: Scripts execute a single action and then stop; EAs monitor the market and trade continuously.
Q: Can I assign a hotkey to a script? A: Yes, right-click the script in the Navigator, select "Set Hotkey," and define your preferred keyboard shortcut.
Q: Why did my script stop? A: Scripts are designed to stop immediately after finishing their programmed command; this is normal behavior.
What this tool does
Contract Sizer is a tool that sizes contracts based on the account balance, providing three separate protections: a ladder, a floor, and a breaker.
Typical Use Case
This Script excels in automated trading and technical analysis on MetaTrader 5.
Compatible Platform & Setup
This Script works on MetaTrader 5. Place the file in the MQL5/Scripts folder and restart the terminal.
Description & Settings
Related: Server Clock Synchronization for MetaTrader - another powerful script for MetaTrader 5 traders.
Contract Sizer is a tool that sizes contracts based on the account balance, providing three separate protections: a ladder, a floor, and a breaker.Also recommended: Write Integer Data to File - similar script with strong performance on MetaTrader 5.
These protections work together to manage risk. The ladder protection allows for one contract per factor of balance, with a cap to prevent over-trading. The floor protection ensures that no trading occurs below the minimum capital required. The breaker protection stops trading at a fraction of the balance peak and does not rearm automatically.
Deposits and withdrawals are taken into account by reading the deal history, and the peak balance is adjusted accordingly. This means that a deposit made during a drawdown will not hide the drawdown. The peak balance is persisted in the MQL5\Files directory and survives a terminal restart.
The constructor for Contract Sizer is initialized with the following parameters: factor, maxContracts, minContracts, minCapital, maxDD, and peakFile. To use Contract Sizer, call the ContractsToday function on every tick, as it recomputes only at the day change. The CapByBalance function ensures that the contract size is adjusted based on the account balance, even with manual lots. The Rearm function allows for manual decision-making.
Demo inputs are available to test Contract Sizer, including InpBalancePerContract, InpMinCapital, InpMaxDrawdown, and InpDemoDeposit. The demo prints a 12-day simulated path, including balance, peak, drop, contracts, and event, with a deposit at the bottom of the drawdown. It then runs the real class on the open account.
It is important to note that position sizing does not create an edge, but rather multiplies the existing edge. Contract Sizer does not trade itself, but rather provides a risk management tool to help traders manage their positions.
You may also like: group transfer stop loss - excellent alternative for script users on MetaTrader 5.
Source Code
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property script_show_inputs
#include "ContractSizer.mqh"
input double InpBalancePerContract = 3000.0;
input double InpMinCapital = 1500.0;
input double InpMaxDrawdown = 0.20;
input bool InpDemoDeposit = true;
struct State
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.