Back to course
Lesson 31Copy trading build labAdvanced135 min

Provider EA with OnTradeTransaction

Use the OnTradeTransaction event to understand how a provider EA can observe trade changes without guessing from ticks.

Lesson outcomes

  • Understand why trade transactions are event-driven.
  • Draft a provider EA that logs trade events for a demo copier.
  • Avoid assumptions about event order and one-request-one-event logic.

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.

A weak copier watches prices and guesses what happened. A better educational copier watches trade events. In MQL5, OnTradeTransaction is designed for handling trade transaction events, including manual actions and programmatic requests.

The official documentation also warns that a single trade request can lead to multiple trade events and that arrival order is not something you should oversimplify. That warning is exactly why copier code needs careful sequence handling.

What you should be able to do after this lesson

  • Understand why trade transactions are event-driven.
  • Draft a provider EA that logs trade events for a demo copier.
  • Avoid assumptions about event order and one-request-one-event logic.

What the provider should record

  • Transaction type, such as order add, deal add, history add, or position change.
  • Symbol, order id, deal id, position id, side, volume, price, stop-loss, and take-profit when available.
  • A monotonically increasing local sequence number.
  • A timestamp from the provider terminal.
  • A provider identifier that does not reveal private credentials.

The provider should not send passwords, investor passwords, bank details, ID documents, or personal data. A copier only needs trade-event information and consent from the account owner.

Provider skeleton

void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
{
   if(trans.symbol == "") return;
   // Demo lab idea: normalize the transaction into a small event record.
   // Write only non-sensitive trade fields for the receiver to inspect.
}

This is intentionally a skeleton, not a plug-and-play money machine. The lesson is architecture. A finished copier still needs filtering, duplicate handling, receiver-side risk controls, logging, and weeks of demo observation.

Event order caution

Do not assume one button click equals one event. A market order can create request, order, deal, history, and position changes. Provider code should either write normalized final states or write raw events with enough sequence data for the receiver to reconcile safely.

Academy-grade study plan

A copier is not a secret bot; it is a distributed risk system. A paid-course standard design defines events, permissions, symbol mapping, receiver risk, stale-event rules, duplicate handling, and logs before any demo order is copied.

Course elementWhat you must produce
Primary artifactCopier event contract
Lesson focusProvider EA with OnTradeTransaction
Working environmentDemo account, notebook, exported platform data, or local code sandbox. Never live funds for first practice.
Completion standardYou 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 provider ea with ontradetransaction under controlled conditions.

  • Design provider output and receiver decisions as separate responsibilities.
  • Keep sensitive information out of event files, API payloads, and logs.
  • Make receiver-side risk controls local so a provider or server fault cannot force unsafe size.
  • Test event rejection as carefully as event copying.

Worked case study: Receiver rejects a dangerous provider event

A provider event arrives late, maps to a symbol with a different suffix, and implies too much risk for the follower account. A weak copier copies anyway. A professional receiver logs the event, rejects it, explains why, and leaves the account unchanged.

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.

FieldStandard
Event fieldProvider id, sequence, action, symbol, side, volume, stop, take-profit, timestamp, and version.
Receiver mappingLocal symbol, contract check, lot step, max volume, and account-risk calculation.
Rejection ruleToo old, duplicate, unmapped, high spread, excessive risk, disabled provider, or invalid stop.
Audit logAccepted, rejected, reason, local ticket, account state, and settings version.

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.

  • Copying volume instead of risk.
  • Assuming provider and receiver brokers use identical symbols and contract sizes.
  • Not storing processed event ids, causing duplicate orders.
  • Sending passwords or private account data through copier infrastructure.

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 provider ea with ontradetransaction 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 documented event schema with examples of accepted and rejected events.
  • A receiver risk table showing how copied size changes across follower account balances.

Assessment rubric

LevelWhat it looks like
Not readyYou can repeat the vocabulary but cannot complete the demo task, calculate the risk, explain the failure mode, or show evidence.
Course passYou 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 passYou 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 bad provider events and prove your receiver design rejects each one.
  • Write a symbol mapping table for two brokers with suffix differences.
  • Design an observe-only mode that logs decisions without trading.

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 provider ea with ontradetransaction 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

  • You can explain why OnTradeTransaction is useful for copier providers.
  • You do not assume one trade request creates one simple event.
  • Your provider design excludes sensitive personal data.

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.