TAYU Academy course material · MQL5 EA Programming Intro
Course Notes
1. Understand the core idea of “Syntax exercise” and explain it in your own words
2. Master this module's focus: MQL5 basics
3. Complete the assignment on your own and check it against the reference answer
Syntax exercises should first be done with read-only programs that review the SMA status, without OrderSend/CTrade, and without requiring real trading permissions.
The main event functions of an Expert Advisor (EA) include OnInit (initialization), OnTick (on each quote trigger), and OnDeinit (release resources on exit). Indicators need to first create a handle (such as iMA), then use CopyBuffer to read the values, and check if the return value was successful.
Example: In OnInit, handle = iMA(_Symbol, PERIOD_H1, 20, 0, MODE_SMA, PRICE_CLOSE); In OnTick, use CopyBuffer(handle, 0, 0, 3, buf) to read the most recent 3 values, and return directly if unsuccessful.
Example → Compile → Record Errors/Warnings → Observe New Bar Logs on Simulated Chart → Clearly List Unrun Items.
Please provide the event structure explanation and the static compilation record. If MetaEditor is not available, please include static analysis results and note any gaps. Do not fabricate successful screenshot.
It should be able to identify OnInit/OnTick/OnDeinit and their lifecycle. An application without a terminal is neither compiled nor running; source code provided on a website is not for terminal acceptance.
Assuming the `CopyBuffer` request returns 1 value out of 3, it cannot read the last two elements to calculate a cross. Using a shift of `bar.shift = 1` can avoid treating the current bar, which is still being calculated, as the final value. However, it is still important to clarify the order of the array and the meaning of the indicator buffer.
Don't rebuild indicator handles on every tick; by default the current bar and closed bars are not the same information set.
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. Master the three main event functions
2. Create the indicator handle first, then read the buffer
3. Check every return value
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.
Syntax exercises should first be done with read-only programs that review the SMA status, without OrderSend/CTrade, and without requiring real trading permissions.
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.