OrderCheck, OrderSend, filling policy, and trade server retcodes
Build a professional order-submission pipeline that checks requests, submits deliberately, reads retcodes, and explains every rejection.
Lesson outcomes
- Design an OrderCheck to OrderSend pipeline for demo EAs.
- Log trade-server return codes instead of hiding failed requests.
- Understand why filling policy, deviation, price, and symbol rules can change execution results.
Workshop lab
Complete the demo, notebook, platform, or code task before treating the lesson as finished.
Evidence pack
Keep screenshots, exports, logs, calculations, or code versions in a dated learning folder.
Pass standard
You should be able to explain the failure modes, show your work, and name the stop rule.
Free education, not signals. This lesson is part of EarnSouthAfrica's free forex course. It does not tell you what to buy or sell, it does not promise income, and it should be practised on a demo account before any real-money decision.
The difference between a toy EA and a serious EA is often visible in failed orders. A toy EA prints 'order failed' and moves on. A serious EA records the request, the account state, the symbol state, the check result, the send result, the retcode, and the recovery decision.
This lesson is deliberately unglamorous. Retcodes and preflight logs do not sell courses, but they save learners from trusting bots they cannot debug.
What you should be able to do after this lesson
- Design an OrderCheck to OrderSend pipeline for demo EAs.
- Log trade-server return codes instead of hiding failed requests.
- Understand why filling policy, deviation, price, and symbol rules can change execution results.
Submission pipeline
- Build MqlTradeRequest only after signal, risk, symbol, account, spread, and session checks pass.
- Normalize price and volume to symbol rules before checking.
- Call OrderCheck and log the result before calling OrderSend.
- Call OrderSend only when the check result and local risk plan both allow it.
- Read result.retcode, deal/order tickets, comment, bid/ask, and request id where available.
Retcode review table
| Retcode class | Review response |
|---|---|
| Success or placed | Record ticket, expected position state, and wait for lifecycle confirmation. |
| Invalid price/stops/volume | Return to symbol audit and normalization logic. |
| No money/margin | Reduce or reject; never widen risk to force entry. |
| Requote/off quotes/market closed | Do not retry blindly; check spread, session, and connection state. |
Minimal demo skeleton
MqlTradeRequest request = {};
MqlTradeCheckResult check = {};
MqlTradeResult result = {};
// Fill request only after local risk and symbol checks pass.
ResetLastError();
if(!OrderCheck(request, check))
{
Print("OrderCheck failed. error=", GetLastError(), " retcode=", check.retcode);
return;
}
if(!OrderSend(request, result))
{
Print("OrderSend failed. error=", GetLastError(), " retcode=", result.retcode);
return;
}
Print("OrderSend result retcode=", result.retcode, " order=", result.order, " deal=", result.deal);
The skeleton is intentionally incomplete. The paid-course skill is knowing which checks must happen before this block and how the retcode should be reviewed after it.
Academy-grade study plan
This is the production-thinking layer of the course. A serious MT5 system is not a lucky Expert Advisor; it is a documented machine with account preflight, symbol preflight, event handling, risk gates, order checks, logs, recovery rules, and demo evidence for every assumption.
| Course element | What you must produce |
|---|---|
| Primary artifact | EA systems engineering dossier |
| Lesson focus | OrderCheck, OrderSend, filling policy, and trade server retcodes |
| Working environment | Demo account, notebook, exported platform data, or local code sandbox. Never live funds for first practice. |
| Completion standard | You can explain the concept, reproduce the exercise, identify failure modes, and show evidence without relying on a seller's claims. |
Instructor workflow
Use this workflow as if an instructor were marking the lesson. The important question is not whether the topic sounds familiar. The question is whether your notes, screenshots, calculations, logs, or code prove that you can apply ordercheck, ordersend, filling policy, and trade server retcodes under controlled conditions.
- Start every system session by recording account mode, margin mode, symbol specification, trade permissions, spread state, stops level, freeze level, and session/news context.
- Separate signal logic, position sizing, preflight checks, order submission, trade lifecycle tracking, recovery, and observability so failures can be isolated.
- Use MT5 and MQL5 events deliberately: OnTick for market updates, OnTimer for scheduled checks, OnTradeTransaction for lifecycle evidence, and OnBookEvent only when market-book data is subscribed and useful.
- Treat every reject, retcode, skipped trade, stale quote, bad tick, and risk block as useful evidence rather than an annoyance.
Worked case study: The EA refuses to trade for the right reason
A learner runs a demo EA during a volatile session. The signal is true, but the symbol has a widened spread, the requested stop is inside the broker's stop level, and margin would be too tight after the order. A weak bot sends the trade and blames the broker. A professional system logs each preflight result, rejects the order before submission, and records the account state for review.
After reading the scenario, write the decision you would make before checking the suggested workflow above. Then compare your decision with the operating model. The gap between those two answers is the part of the lesson that deserves another demo repetition.
Professional template
Complete this template in your own notebook. A paid course would normally hide this kind of operating document behind worksheets; here it is part of the free lesson.
| Field | Standard |
|---|---|
| Preflight area | Account mode, symbol specification, margin, stops/freeze level, spread, session, and permission state. |
| Event handler | OnTick, OnTimer, OnTradeTransaction, OnBookEvent, OnCalculate, or OnTester responsibility. |
| Safety gate | The exact condition that blocks duplicated, oversized, stale, unfillable, or undocumented trades. |
| Evidence | Journal/Experts log, tester report, exported settings, screenshots, retcode notes, and review memo. |
Failure-mode lab
Paid courses often sell confidence. A serious course teaches you how the idea breaks. Before continuing, test the failure modes below on demo, paper, or code review. If you cannot describe the failure, you are not ready to trust the concept.
- Sending orders before checking broker symbol rules, account mode, filling policy, margin, and stop-distance constraints.
- Using OnTick for every responsibility until the EA becomes impossible to debug.
- Ignoring trade-server retcodes, partial fills, rejects, and asynchronous lifecycle events.
- Optimizing parameters while the underlying execution and risk engine is still unproven.
Evidence pack and pass standard
Do not mark this lesson complete because you read it. Mark it complete only when you can show the evidence below. Keep the files in a dated folder so your learning history survives platform updates, memory gaps, and sales pressure.
- A one-page note explaining ordercheck, ordersend, filling policy, and trade server retcodes without sales language or copied definitions.
- A screenshot, export, calculation, log, or code file that proves the practical work was completed on demo.
- A written stop rule that says when this topic must not be used with real money.
- A system preflight table showing pass/fail results for at least three symbols on demo.
- A log excerpt where the system rejects a tempting but unsafe trade with a clear reason.
Assessment rubric
| Level | What it looks like |
|---|---|
| Not ready | You can repeat the vocabulary but cannot complete the demo task, calculate the risk, explain the failure mode, or show evidence. |
| Course pass | You can complete the practical task on demo, explain the decision rules, show evidence, and name the conditions where the idea must not be used. |
| Strong pass | You can teach the concept to someone else, find edge cases, document a rejected example, and improve the template without weakening risk controls. |
Advanced homework
- Create five deliberately bad trade requests and document exactly where each one should be rejected.
- Build a state diagram for order request, check, send, fill, modification, close, reject, and recovery paths.
- Run the same EA on a demo hedging account and a demo netting account, then document lifecycle differences.
Practical drill
Do this lesson as a controlled exercise, not as a reason to trade live. Open a demo account or notebook, write the lesson title, and record what you changed, clicked, calculated, or checked. If the lesson includes code, compile it only in a demo environment and keep the original version unchanged so you can compare edits safely.
- Write a one-paragraph explanation of ordercheck, ordersend, filling policy, and trade server retcodes in your own words.
- Take one screenshot or note that proves you completed the platform, maths, research, or code task.
- Record one risk rule that would stop you from using this idea with real money.
- If anything feels unclear, repeat the lesson before moving to the next module.
How scammers misuse this topic
Scammers often take real concepts and wrap them in urgency. They may use platform jargon, bot screenshots, copied profit charts, or official-sounding language to make a paid offer feel safe. A real concept is not the same as a safe offer. Before paying anyone, ask whether you can verify the provider, reproduce the calculation, test the claim on demo, understand the risk, and walk away without pressure.
Checkpoint before continuing
- Your order pipeline records request, check result, send result, and retcode.
- You can classify common retcodes into fix, retry, reject, or investigate.
- Your EA never retries failed orders without a written recovery rule.
Official references
These lessons are written as free education. When platform features or rules matter, verify against the official source before using real money.
Risk note: leveraged forex and contracts for difference can lose money quickly. EarnSouthAfrica is an educational publisher, not a broker, adviser, signal provider, or money manager.
Keep exploring
Read the latest guides, take the side-hustle quiz, or contact the editorial desk if you spot a correction.