How to Automatically Export Trade Data as JSON or CSV in Real-Time When Trades Open or Close?

 
Hi everyone,

I’m looking for the best way to automatically export trade data in real-time whenever a trade is opened or closed. I would like to export the data in either JSON or CSV format.

This is specifically for my students, as I want to track their trades and analyze them on my own platform. Ideally, I need a solution that allows:

Real-time export of trade data immediately when a trade is executed (both open and close events).
Export fields such as symbol, order type (buy/sell), entry/exit price, stop-loss, take-profit, commission, swap, and timestamps.
The ability to send the data via WebRequest to a remote API or save it locally as a CSV file.
Should I develop an Expert Advisor (EA) for this, or is there an existing feature or script that could achieve this?

I appreciate any suggestions or examples you can share!

Thanks in advance!
 
tradingprozess: Should I develop an Expert Advisor (EA) for this, or is there an existing feature or script that could achieve this?
  1. It doesn't need to be an EA. You can only have EA one on a chart. An indicator would work just as well.
  2. Do your own research.
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
tradingprozess:
Hi everyone …
First, detect a trade event using OnTradeTransaction .
Next, write the trade details to a CSV file using FileWrite .
Here a list of available Network functions.



William Roeder #:
  1. It doesn't need to be an EA. You can only have EA one on a chart. An indicator would work just as well.
You can have multiple charts running an EA on the same symbol.
 
William Roeder #: It doesn't need to be an EA. You can only have EA one on a chart. An indicator would work just as well.

Given the OP's requirement for the use of WebRequest, an Indicator would not work.

tradingprozess: Should I develop an Expert Advisor (EA) for this, or is there an existing feature or script that could achieve this?

I personality would recommend the use of a Service instead of an EA, because it will work independently of charts are open or not.

You can look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). 

To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Book and Documentation

You also have the option to hire a programmer in the Freelance section.

 
tradingprozess:
Hi everyone,

I’m looking for the best way to automatically export trade data in real-time whenever a trade is opened or closed. I would like to export the data in either JSON or CSV format.

This is specifically for my students, as I want to track their trades and analyze them on my own platform. Ideally, I need a solution that allows:

Real-time export of trade data immediately when a trade is executed (both open and close events).
Export fields such as symbol, order type (buy/sell), entry/exit price, stop-loss, take-profit, commission, swap, and timestamps.
The ability to send the data via WebRequest to a remote API or save it locally as a CSV file.
Should I develop an Expert Advisor (EA) for this, or is there an existing feature or script that could achieve this?

I appreciate any suggestions or examples you can share!

Thanks in advance!

EA 100% , if you go the API route , and its not a google docs API but your own server , you could also allow them to have an in chart real time "ranking" of all the students.

If you wanted to "gamify" it a bit and would not mind each student seeing what everyone else is trading.