Scripts: Export trade history to CSV v2

 

Export trade history to CSV v2:

This script will export the trade history from MT5 selected between two dates. The resulting file is CSV that can be opened/imported with any spreadsheet software. Current version 1.0 does not add the takeprofit and stoploss. Any advice to improve this is welcomed.

Author: Fernando Morales

 

Nice script, for sure, useful.

It would be good if there would be a parameter also, for separator (string), like ","

 

It stopped working.

Could you confirm, please?

The script was perfect!

 

Hello,

is it possible to also get position value (margin)?
Thanks in advance

 

Hi very good script. for TP and SL:

  • TakeProfit, data not available using HistoryOrderGetDouble(order_ticket, ORDER_TP)
  • StopLoss, data not available using HistoryOrderGetDouble(order_ticket, ORDER_SL)

i think this information are available from "deal Out".

i use this code.

also remove " Looping through all the ORDERS" for TP and SL .


if ( HistoryDealGetInteger(deal_ticket, DEAL_ENTRY)== DEAL_ENTRY_OUT  ) 
        {
           _sl = HistoryDealGetDouble (deal_ticket, DEAL_SL);
           _tp = HistoryDealGetDouble (deal_ticket, DEAL_TP)
        }
 

Hi,


my output does not seem to be correct.

I get some duplicate rows. It is slightly different with hannibal21 version, but also a few duplicate rows.

I can't say why this happens. The rows have no different values.

Edit:

If I simply remove the duplicate lines, I get the same result like mt5 history.


I added a version with the changes hannibal21 suggested, to show me the initial SL/TP and also changed the delimiter to ";".

Maybe I did something wrong?

 
Thank you ! Works great
 
If have 2 Items/Issue. may be it helps someone testing this 1) Path export file: Windows 10: Programm Files\MQL5\ Files ... under Windows 11 its in user profile AppData\Roaming\MetaQuotes.... 2) in my data, I had error zero divide. (Code Lines 201-205). I not solved. only add // at begin cu
 
Great script, would be better if TP and SL came over accurately.
 

Forum on trading, automated trading systems and testing trading strategies

Magic Numbers Not Matching Between Terminal and DEAL_MAGIC

Bob Ishmial, 2023.11.29 13:33

Hello! 

I have an issue where the Magic Number set by my EAs appears different in the terminal vs what is returned when I use HistoryDealGetInteger(deal_ticket, DEAL_MAGIC); I am using 4 EAs all on the same pair and all with different Magic Numbers.

I am using the scrip from here:  Free download of the 'Export trade history to CSV v2' script by 'Aimak' for MetaTrader 5 in the MQL5 Code Base, 2019.02.17

The screenshots show the Magic number in the Terminal and in a .CSV file in VSCode. Does anybody know why this is? 

It selects the Magic Number with this line:

_magic = HistoryDealGetInteger(deal ticket, DEAL_MAGIC);

Forum on trading, automated trading systems and testing trading strategies

Magic Numbers Not Matching Between Terminal and DEAL_MAGIC

Bob Ishmial, 2023.11.29 14:05

Thanks @Fernando Carreiro!

I have some more information - it appears my EAs are trying to open a trade at the same time. If two or more try to do it, the opening of the trade will be given the Magic from the first EA to fire however, it will be given the Magic of the last EA once the trade closes! 

Trying to figure out a solution now. I am checking the Magic when opening trades btw. 

Posts moved by moderator

Files: