Loading…

Error 130 Doctor

Error 130 ("invalid stops") is one error code standing in for at least four unrelated causes: a stop loss placed on the wrong side of entry, a stop too close to price for MODE_STOPLEVEL, a later modification too close to price for the separate MODE_FREEZELEVEL, or a price with more decimals than the symbol actually uses. The platform gives no hint which one applied - the order is simply refused. This script checks all four against the symbol's real, live broker limits, never a hardcoded pip distance. Wrong-side and stop-level checks apply to the order as typed; a MODE_FREEZELEVEL note is printed separately, because freeze level does not block the initial send at all - it only blocks a LATER OrderModify() on the resulting ticket once price has moved within that distance of the stop being changed, which is a common source of "it opened fine but I can't move the stop" confusion distinct from error 130 on open. Where a check fails, the script prints the nearest value that would actually be accepted, computed from the same MODE_STOPLEVEL distance rather than a guessed round number. Notes and limitations This script never sends, modifies or closes an order - it only evaluates the numbers you type against the live limits reported by MarketInfo(). It checks correctness at the moment it runs; broker limits (especially MODE_STOPLEVEL and MODE_FREEZELEVEL) can widen during volatile news windows, so a value that passes here can still be rejected moments later if conditions change. It does not check margin, symbol trade mode or connection state - those are covered by a separate "why will it not trade" diagnostic; this script is scoped to the specific error-130 stop-distance family of failures only.

Script · MT5 · v1.0 · Free

About Error 130 Doctor

Error 130 Doctor is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Symbol, Is buy and Entry price. MQL source code included.

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

Settings

SettingDefaultWhat it does
SymbolSymbol to check (blank = current chart symbol)
Is buytrueProposed order side: true = buy, false = sell
Entry price0.0Proposed entry price (0 = use current market price)
Stop loss0.0Proposed stop loss (0 = none)
Take profit0.0Proposed take profit (0 = none)

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria