Skip to content
All library documents

Building and Using an MQL5 Positions Management Library

Article MQL5 articles

Summary

This practical guide expands an MQL5 EX5 library for managing open positions and shows how to import it into other programs. It explains import declarations, function prototypes, library naming, and common runtime failures caused by mismatched paths or declarations. It also describes redeployment steps when a library changes, including recompiling the binary and updating importing projects when exported prototypes change.

The library adds position-management functions such as a trailing stop loss, which is selected by position ticket and applied when trading is allowed and the requested distance is valid. Two Expert Advisor examples demonstrate integration, including one with a graphical panel. The article is primarily a software implementation guide rather than evidence for a trading strategy: it offers no measured returns or comparative tests, and its examples require further evaluation in the reader’s environment.

Key ideas

  • MQL5 programs import compiled EX5 libraries by declaring the library and matching exported function prototypes.
  • Incorrect paths, function names, parameter types, or return types can cause runtime loading failures despite successful compilation.
  • Library updates require recompiling the binary and revising import declarations when exported interfaces change.
  • A trailing stop function can select a position by ticket and update its stop under specified validity and trading conditions.
  • Expert Advisor examples illustrate library integration but do not establish trading performance.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.