Best way to get Account and Trade History Data from MQL4 / MQL5 to website?
Rohin Stirling Dufty:
Hello friends!
I am building a NextJS project to improve my full stack skills and am wanting to know how to get trade/account history to display on a dashboard?
Much like MyFXBook and FXBlue do it! How do they do it? haha
I know MYFXBOOK must use some kind of api as you can enter a username and investor password and it grabs data from the broker somehow, this would be ideal but I think there might be some decent costs around it?
FXBlue use the EA method.
So far I have created an EA that sends JSON data via a POST request to an API I built, I can get current account data and trade history but no account history. I'll paste the code I've put together so far below.
Account history would be great so I can create some graphs of the balance over time, and will enable me to put together portfolios.
So basically, below in the ea, it has 2 functions, getHistory and sendHistory.
SendHistory is just the post function which I've omitted because that works fine, the timer can be set to post every x seconds passed into EventSetTimer
getHistory does the work to get the data, create arrays of objects and serializes the data
So in the below, what would be the best way to get account history?
Do I need to loop over history, and somehow get the initial balance and then balances every week or something?
I know I'm close, I hope this code can help anyone else on this mission and we can all learn together!
Peace, Rohin.
Hello friends!
I am building a NextJS project to improve my full stack skills and am wanting to know how to get trade/account history to display on a dashboard?
Much like MyFXBook and FXBlue do it! How do they do it? haha
I know MYFXBOOK must use some kind of api as you can enter a username and investor password and it grabs data from the broker somehow, this would be ideal but I think there might be some decent costs around it?
FXBlue use the EA method.
So far I have created an EA that sends JSON data via a POST request to an API I built, I can get current account data and trade history but no account history. I'll paste the code I've put together so far below.
Account history would be great so I can create some graphs of the balance over time, and will enable me to put together portfolios.
So basically, below in the ea, it has 2 functions, getHistory and sendHistory.
SendHistory is just the post function which I've omitted because that works fine, the timer can be set to post every x seconds passed into EventSetTimer
getHistory does the work to get the data, create arrays of objects and serializes the data
So in the below, what would be the best way to get account history?
Do I need to loop over history, and somehow get the initial balance and then balances every week or something?
I know I'm close, I hope this code can help anyone else on this mission and we can all learn together!
Peace, Rohin.
To understand you better, maybe we need your json script...
This creates a json object with account data and trade data, not sure what script you are referring to
You can then write the object to a file or send via post req to your api endpoint.
This works but I need account equity history with each trade so I can plot it on a chart
I am building a NextJS project to improve my full stack skills and am wanting to know how to get trade/account history to display on a dashboard?
Much like MyFXBook and FXBlue do it! How do they do it? haha
I know MYFXBOOK must use some kind of api as you can enter a username and investor password and it grabs data from the broker somehow, this would be ideal but I think there might be some decent costs around it?
FXBlue use the EA method.
So far I have created an EA that sends JSON data via a POST request to an API I built, I can get current account data and trade history but no account history. I'll paste the code I've put together so far below.
Account history would be great so I can create some graphs of the balance over time, and will enable me to put together portfolios.
So basically, below in the ea, it has 2 functions, getHistory and sendHistory.
SendHistory is just the post function which I've omitted because that works fine, the timer can be set to post every x seconds passed into EventSetTimer
getHistory does the work to get the data, create arrays of objects and serializes the data
So in the below, what would be the best way to get account history?
Do I need to loop over history, and somehow get the initial balance and then balances every week or something?
I know I'm close, I hope this code can help anyone else on this mission and we can all learn together!
Peace, Rohin.