Very useful and straight forward to use tool to retreive MT5 data to Excel. Here is some code to get it to retreive several data types from multiple assets simultaneously
voidOnTimer()
{
// Retrieve the current bid, ask, high, low, and last volume for the symbol of the chartdouble bidPrice = 0.0;
double askPrice = 0.0;
double highPrice = 0.0;
double lowPrice = 0.0;
double lastVolume = 0.0;
string symbol = _Symbol; // Gets the symbol of the chart where the EA is attachedif(SymbolInfoDouble(symbol, SYMBOL_BID, bidPrice) &&
SymbolInfoDouble(symbol, SYMBOL_ASK, askPrice) &&
SymbolInfoDouble(symbol, SYMBOL_HIGH, highPrice) &&
SymbolInfoDouble(symbol, SYMBOL_LOW, lowPrice) &&
SymbolInfoDouble(symbol, SYMBOL_VOLUME_REAL, lastVolume))
{
// Unique DDE topics for each symbolstring bidTopic = symbol + "_BID";
string askTopic = symbol + "_ASK";
string highTopic = symbol + "_HIGH";
string lowTopic = symbol + "_LOW";
string volumeTopic = symbol + "_VOLUME";
// Check & Add Items DDE for each data point with symbol nameif(!CheckItem("PRICE", bidTopic)) AddItem("PRICE", bidTopic);
if(!CheckItem("PRICE", askTopic)) AddItem("PRICE", askTopic);
if(!CheckItem("PRICE", highTopic)) AddItem("PRICE", highTopic);
if(!CheckItem("PRICE", lowTopic)) AddItem("PRICE", lowTopic);
if(!CheckItem("PRICE", volumeTopic)) AddItem("PRICE", volumeTopic);
// Set DDE items with the data
SetItem("PRICE", bidTopic, DoubleToString(bidPrice, _Digits));
SetItem("PRICE", askTopic, DoubleToString(askPrice, _Digits));
SetItem("PRICE", highTopic, DoubleToString(highPrice, _Digits));
SetItem("PRICE", lowTopic, DoubleToString(lowPrice, _Digits));
SetItem("PRICE", volumeTopic, DoubleToString(lastVolume, 0)); // Volume is usually an integer
}
else
{
// Handle the error if any price information cannot be retrievedAlert("Error retrieving price information for " + symbol);
}
}
// rest of the existing code ...
trade.PositionOpen(_Symbol, ORDER_TYPE_BUY_LIMIT, 0.1, nOPPrice, 0, 0, "Commentyup"); I use the trade.mqh library on MT5..... and for buy and sell the execution runs normally.. but there are no open positions for buylimit and selllimit.... is there anyone here who can help me?
I have reprogrammed it so that I receive live tick (bid and ask) data directly in excel/libreoffice. Exactly the same as with MT4. No difference at all. Thanks for that!
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
finaly i got it!!!!!
for the next people who come along and can't get it to work, my problem was solved, just opening everything in logical sequence.
first the dde server, then meta trader 5, put the robot in the pair I wanted, authorize all meta trader 5 dlls, and only then open excel.
my mistake was leaving excel open before opening all the other programs... here's the tip.
Very useful and straight forward to use tool to retreive MT5 data to Excel. Here is some code to get it to retreive several data types from multiple assets simultaneously
I have reprogrammed it so that I receive live tick (bid and ask) data directly in excel/libreoffice. Exactly the same as with MT4. No difference at all. Thanks for that!