TAYU Academy course material · MQL5 EA Programming Intro
Course Notes
1. Understand the core idea of “Moving average EA development” and explain it in your own words
2. Master this module's focus: EA trading logic
3. Complete the assignment on your own and check it against the reference answer
SMA EA is developed in two layers: signals and execution. This course delivers a read-only signal EA and a paper-based execution state machine; it is not a fully automated trading robot that can be directly invested with funds.
A common approach is to calculate signals only when new K lines appear, to avoid placing multiple orders for each quote. Before placing an order, check for existing positions, ensure the spread is not too wide, and confirm the lot size is appropriate for the minimum step size of the underlying instrument. Also handle the return codes for failed order placements.
Record the time of the previous candle; only cross judgment of SMA is made when the time changes; do not place orders when the spread exceeds 3 pips; use `SymbolInfoDouble` to read `SYMBOL_VOLUME_STEP` to standardize the lot size.
Building on the example, list the fast/slow SMA → define a closing cross above → evaluate only once per new bar → log the signal → verify with a paper order table; never add real keys.
Given a fast line of 99/102 and a slow line of 100/101, determine if the fast line crosses above the slow line. Then, given a fast line of 101/102 and a slow line of 100/101, determine if the fast line crosses above the slow line again.
Previous group from fast ≤ slow to fast > slow, satisfied; the second group was already above the line before, not a new penetration. Result must be bound to the closing time of the previous candle, log signals do not equal actual transactions.
Receive 20 ticks in the same minute, cross signals should only be registered once according to the predetermined logic of "once per new bar". If the account already has positions from other strategies, do not modify or close them solely because the product is the same. Output signal.csv first, validate the duplicates, and then discuss the simulation execution adapter.
Course Examples deliberately do not use OrderSend; additional execution code requires separate simulation testing and platform verification.
The companion .mq5 file only logs signals and never submits orders. Below is a terminal checklist; having the source on the web does not mean it has compiled or run in your terminal. Without a terminal, complete the state machine on paper and record which steps were not run.
1. Download AcademySmaSignal.mq5
2. Open and compile it in MT5 MetaEditor; save the version and diagnostics
3. Watch new-bar signal logs on a demo chart or in the Strategy Tester only
4. Check CopyBuffer failures, duplicate new-bar events and resource release on exit
5. Do not enable live trading; verify the order state machine on paper1. Evaluate signals only on a new candle
2. Run several checks before placing an order
3. Handle failure return codes
Risk warning: leveraged trading in forex, precious metals and similar products carries a high level of risk and you may lose all of your capital, or more. This course is for education only. It is not investment advice and does not promise any return. Example prices and contract specifications are teaching assumptions; always use what your own platform discloses. Past performance and backtests do not indicate future results.
All values, prices, accounts and cases in this course are teaching assumptions; the fixed materials can be reproduced offline. Marking a lesson complete only records your study. It is not a certification, a service approval or a promise of returns. Workbooks and answer files are currently provided in Chinese.
SMA EA is developed in two layers: signals and execution. This course delivers a read-only signal EA and a paper-based execution state machine; it is not a fully automated trading robot that can be directly invested with funds.
Record your work and compare the reference result. Self-checks are not verified competence.
Completion records your own study, not verified competence. Exercises use fictional data; no real account or deposit is required.