Loading…

Scale In Ladder

Scaling into a zone instead of entering at one price is a normal technique: several smaller orders across the area, an average entry somewhere in the middle. Placing the rungs by hand is slow and error-prone, and the arithmetic most people do in their head for the sizing is wrong in a specific way. The wrong way is to size each rung as if it were its own trade. Risk one percent per rung across four rungs and the position that exists after the zone is swept risks four percent - the plan multiplied itself without asking. This script sizes the whole ladder as one position: in risk mode, the loss when EVERY rung has filled and the shared stop is hit is the asked percentage of equity, computed per rung from its own distance to the stop using tick-value arithmetic (Point arithmetic mis-sizes metals and indices by the tick-to-point ratio). The distribution rule is total divided by N, floored to the broker's lot step per rung, with the remainder added to the first rung. That rule has a subtle consequence in risk mode: the remainder lands on the rung furthest from the stop, where a lot costs the most, so the honest worst case can end up slightly OVER the asked risk. The script recomputes the worst case after distributing and shaves the first rung back a step at a time until it fits. Risk honesty beats volume fidelity; the confirmation prompt shows the exact final figure. Each rung's order type is derived from its side of the market, so a zone that straddles the current price legally mixes limits and stops - the rungs beyond the market become stops, the ones behind it limits, and that is correct, not a bug. Rungs the broker cannot accept (inside its minimum stop distance, or exactly at the market) are skipped and reported individually, never silently nudged to a price you did not choose. Without a stop the risk of a zone-sweep is unbounded, so risk mode refuses to run stopless, and lots mode says "NO STOP LOSS" in capitals in the prompt. Notes and limitations - The rungs are independent orders once placed. Filling one does not modify the others; deleting the ladder later is a manual act (or a pending-delete script). - Order types are fixed at survey time, from where the market was when you confirmed. If price crosses rungs while the script is still placing, those sends are rejected by the broker and reported - the script does not re-derive types mid-flight, because that would place a different plan than the one you confirmed. - The worst-case risk figure assumes the stop is hit with every rung filled at its rung price, with no slippage and no gap. A weekend gap through the stop loses more; no script can promise otherwise. - In lots mode the total you typed is honoured exactly (after flooring); in risk mode a step or two of volume may be shaved off the first rung to keep the worst case at or under the asked risk. - A broker-side limit on simultaneous orders can refuse late rungs; the refusal is reported as-is. - Skipped is not failed: a skipped rung was impossible at survey time and was never sent; a failed rung was sent and refused.

Script · MT5 · v1.0 · Free

About Scale In Ladder

Scale In Ladder is an expert advisor (trading robot) for MetaTrader 5. It opens a grid of orders at fixed price steps, places pending buy/sell stop or limit orders and can size trades from your balance and risk percent. It has 12 settings, such as Direction, Start price and End price. MQL source code included.

Files in the download: ScaleInLadder.ex5, ScaleInLadder.mq5, ScaleInLadder.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
DirectionDIR_BUYTrade direction
Start price0.0First rung price
End price0.0Last rung price
Rungs3Number of rungs (pending orders)
Sizing modeSIZE_RISK_PERCENTHow the total size is set
Risk percent1.0Risk if all rungs fill and stop is hit, % of equity
Total lots0.30Total volume across all rungs (lots mode)
Stop price0.0Shared stop loss beyond the far end (0 = none)
Magic0Magic number written on the orders
Max retries5Attempts per order before giving up
Retry wait ms500Pause between attempts, milliseconds
Confirm firsttrueAsk for confirmation before placing

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Grid · Pending Orders · Risk & Lot Size · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria