Managing Position Indicators During Expert Advisor Changes
Summary
This installment in a market replay and simulation series examines reliability problems when an Expert Advisor (EA) manages position indicators on a MetaTrader chart. It explains how removing the EA or changing the tracked contract can leave misleading indicators behind. The proposed fix handles deinitialization by deleting chart indicators associated with positions in the EA's symbol, and checks that relevant objects are initialized before using them. The article also describes explicitly resetting pointers during initialization because timeframe changes can trigger reinitialization without a fresh program start.
The discussion emphasizes using documentation, logs, and testing to diagnose failures, then introduces average position price as a harder problem, especially on hedging accounts where the platform may have multiple positions with differing directions, volumes, and entry prices. The supplied text cuts off before fully explaining that problem or its solution. The article cautions that the wider EA and position indicator are still unstable and should not yet be trusted on a live account, so its examples are implementation guidance rather than evidence of production readiness.
Key ideas
- Removing or reconfiguring an EA can leave position indicators on a chart unless deinitialization explicitly cleans them up.
- Indicator deletion depends on matching the chart object's identifying name to the position ticket.
- Timeframe changes can reinitialize an EA, so pointers should be reset during initialization before use.
- Logs and documentation can help diagnose behavior that is difficult to inspect in a debugging session.
- On hedging accounts, an average position price is a trader-derived value based on multiple positions, rather than a single server-side position price.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.