Percentage Of Equity Order
There are two honest ways to size a position and they are constantly confused. Risk sizing answers "how much do I lose if my stop is hit" - that is what the Risk Based Market Order script in this series does. Exposure sizing answers "how large a position am I holding" - what share of the account the position is actually worth, the way a stock investor thinks about being 50 percent invested. This script does the second one, and only the second one. The two produce wildly different positions from the same percentage, which is exactly why the distinction matters. On a 10,000 USD account, 1 percent EXPOSURE is a position worth 100 USD - about 0.001 lots of EURUSD, below most brokers' minimum, a refusal. On the same account, 1 percent RISK with a 20 pip stop is a 100 USD loss budget, which affords roughly 0.50 lots - a position worth over 50,000 USD, five hundred times larger. Anyone who types a familiar "risk style" percentage into an exposure script, or the reverse, gets a position wrong by orders of magnitude. The confirmation dialog therefore states the notional exposure AND, when a stop is set, the money lost at that stop, side by side, so the number you meant and the number you typed can be compared before anything is sent. The notional of one lot is never taken from a remembered contract size. One lot's notional in the quote currency is contract size times price, and the broker's tick value already contains the conversion from quote currency to account currency. Dividing the two cancels the contract size and leaves notional per lot = price * tick value / tick size, which is exact on every symbol the broker quotes - JPY crosses, gold and index CFDs included, precisely the symbols where a hardcoded 100,000 with no currency conversion is silently wrong. The computed volume is floored to the broker's lot step and never rounded up, because rounding up opens more exposure than was authorised. When even the minimum lot carries more notional than the requested share of equity, the script refuses and prints the smallest percentage that would work. An optional stop loss and take profit are placed at fixed pip distances, validated against the broker's stop and freeze levels with fresh quotes on every retry. Notes and limitations - Exposure is computed at the quote available when the script runs; the fill price moves it slightly. The post-fill summary reports the notional recomputed from the actual open price. - Without a stop loss the position's risk is bounded only by the exposure itself. The confirmation says so explicitly rather than hiding it. - Tick value is read from the broker. On symbols the terminal has not synchronised it can be zero, in which case the script refuses and asks you to open the symbol's chart first rather than sizing from garbage. - The script sizes one trade in isolation. It does not add up the exposure already open on the rest of the account. - Margin is checked before sending, but a high exposure percentage on a low-leverage account can still be refused by the broker; the refusal message states the margin arithmetic.
Script · MT4 · v1.0 · Free
About Percentage Of Equity Order
Percentage Of Equity Order is an expert advisor (trading robot) for MetaTrader 4. It can size trades from your balance and risk percent. It has 9 settings, such as Side, Equity percent and Stop pips. MQL source code included.
Files in the download: EquityPercentOrder.ex4, EquityPercentOrder.mq4, EquityPercentOrder.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Side | TRADE_SIDE_BUY | Direction |
| Equity percent | 100.0 | Notional exposure, percent of equity |
| Stop pips | 0.0 | Stop loss, pips (0 = none) |
| Take profit pips | 0.0 | Take profit, pips (0 = none) |
| Magic | 0 | Magic number |
| Slippage pips | 3 | Slippage tolerance, pips |
| Max retries | 5 | Attempts before giving up |
| Retry wait ms | 500 | Pause between attempts, ms |
| Confirm first | true | Ask for confirmation first |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Gold (XAUUSD) · Grid · Volume · Risk & Lot Size · MT4 Script · MQL4 Source Code