code

How to Write a Custom MQL5 Indicator with Consistent Buffer Indexing

How to Write a Custom MQL5 Indicator with Consistent Buffer Indexing

Technical revision: 1 October 2026 · Educational materialOn this pageDefine the output and its unitsChoose one array conventionComplete indicator sourceWarm-up, updates and history changesVerify the numbers before interpreting the shapeA useful first custom indicator is the distance between a closing price and its simple moving average. It exposes the central implementation problem: every input array, output buffer and loop must agree on the direction of time. Define the output and its units For each bar, calculate the average of that bar's close and the preceding N-1 closes. Output close - average. A positive value means the close is above its…
Read More
Your First MQL5 Expert Advisor: Closed-Bar Signals and Demo Orders

Your First MQL5 Expert Advisor: Closed-Bar Signals and Demo Orders

Technical revision: 1 October 2026 · Educational materialOn this pageMake the rules explicitRead the execution policyEstimate risk without forcing the minimum lotDo not confuse a request with a fillRun a behavior test before a performance testThis tutorial turns a simple moving-average crossing into a complete educational EA. Follow it at your own pace: installation, compilation and verification take longer when your broker has different symbol specifications. The source is a learning exercise, with no published profitability claim. Make the rules explicit A buy signal occurs when the fast EMA was at or below the slow EMA on bar 2 and…
Read More