DinexSpace Minimum Stop Distance Library
- 라이브러리
- 버전: 1.0
DinexSpace Stop Level and Freeze Level Library is a library for MetaTrader 5 (MT5) that checks and adjusts stop loss, take profit and pending order prices against the rules of the symbol: the minimum distance (stops level), the tick size and the freeze level.
The problem it solves
- A request with a stop too close to the market is refused by the server with the status "invalid stops".
- A position or pending order inside the freeze level cannot be changed or deleted.
- This library checks first, tells you the reason, and can move the price to the nearest allowed value.
How it works
- The minimum distance is the stops level of the symbol plus the extra distance you pass in the call (for example the spread). The extra distance is a parameter, not a fixed number.
- Buy stops are measured from the Bid, sell stops from the Ask. Pending prices are measured from the Ask for buy orders and from the Bid for sell orders.
- Adjusted prices are rounded to the tick size on the safe side, away from the market.
What you get
- Check: stop loss, take profit and pending price, with a status code and a plain-English text for the reason.
- Adjust: one call returns the price moved to the allowed distance.
- Freeze level: tells you whether an open position or a pending order is inside the freeze level now.
- Symbol settings: stops level, freeze level and minimum distance in points or price.
- Light: read-only. No DLLs, no web requests, no Sleep.
How to use it
- Copy DinexStopLevel.ex5 to MQL5\Libraries.
- Add the import block with the functions you use (shown in the images and in the example EA).
- Before sending or modifying an order, call the check or the adjust function and use the result.
Example EA (included in the description images)
The example builds prices that are too close to the market, lets the library adjust them, then asks the server with OrderCheck whether the adjusted request is accepted. It sends no orders.
Notes
- The library does not send, modify or delete orders. It does not decide where to place a stop.
- The freeze level check depends on the server setting; many accounts use 0.
- Library state belongs to each program that uses it.
Requirements
- MetaTrader 5, any symbol and timeframe.
