Structuring Expert Advisor Rules with Trading Modes
Summary
The article presents a reusable structure for automated strategy logic by separating four actions: initiating long positions, initiating short positions, supporting existing longs, and supporting existing shorts. A moving-average example illustrates why entries and exits should remain distinct: strategies may use different conditions for opening and closing each side, even when a simple crossover system makes them appear symmetrical.
Trading modes are created by selectively calling these action methods. This allows an EA to pause new entries, disable one direction, or manage existing positions independently. The proposed CTradeState component stores allowed modes over time and can represent scheduled changes, such as restricting entries during a chosen market session. The article explains the design and gives illustrative code, but it does not report strategy backtests or evidence that any particular mode improves returns; its contribution is an implementation pattern for organizing and controlling EA behavior.
Key ideas
- Separate long entry, short entry, long management, and short management into distinct rules.
- Keep entry and exit conditions independent because a strategy may use different signals for each.
- Control trading modes by choosing which rule methods the Expert Advisor calls.
- A time-indexed trade state can support scheduled restrictions on strategy actions.
- The article describes software architecture and does 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.