DinexSpace Position Book Library
- librerie
- Versione: 1.0
- Attivazioni: 5
DinexSpace Position Book Library is a library for MetaTrader 5 (MT5) that takes a snapshot of the open positions of your account and lets any program read them by index. One call refreshes the snapshot; the other functions return one value each.
How it works
- Call DxPbRefresh. The library reads the open positions that match the filter and stores them in a table.
- Read each position by index: ticket, symbol, type, volume, open price, stop loss, take profit, profit, swap, magic number and open time.
- The values stay the same until you refresh again, so every number you read belongs to the same moment.
What you get
- Snapshot by ticket, with the common position fields.
- Filters: symbol, magic number, buy or sell.
- Totals: net volume of a symbol (buy minus sell) and total profit of the snapshot.
- Stop loss check: one call tells you whether a position has a stop loss.
- Status codes with plain-English texts: a wrong index returns an empty value and a status you can read.
- Light: read-only. No DLLs, no web requests, no Sleep.
How to use it
- Copy DinexPositionBook.ex5 to MQL5\Libraries.
- Add the import block with the functions you use (shown in the images and in the example EA).
- Call DxPbSetFilter if you want a filter, then DxPbRefresh, then read the values.
- Call DxPbRefresh again after positions open or close.
Example EA (included in the description images)
The example opens small sample positions in the Strategy Tester, takes a snapshot on every new bar and reads every function. At the end it prints the number of snapshots and failed checks.
Notes
- The library reports what is open now. It gives no entries or exits and does not predict anything.
- Library state belongs to each program that uses it.
Requirements
- MetaTrader 5, any symbol and timeframe.
