MQL4 - automated forex trading   /  

Forum

Read Financial Magazines in MetaTrader 4 and MetaTrader 5!

XML

Back to topics list To post a new topic, please log in or register
avatar
4
An Insight Into Accumulation/Distribution And Where It Can Get You

An Insight Into Accumulation/Distribution And Where It Can Get You

The Accumulation/Distribution (A/D) Indicator has one interesting feature - a breakout of the trend line plotted in this indicator chart suggests, with a certain degree of probability, a forthcoming breakout of the trend line in the price chart. This article will be useful and interesting for those who are new to programming in MQL4. Having this in view, I have tried to present the information in an easy to grasp manner and use the simplest code structures.

avatar
Moderator
1937
BarrowBoy 2009.03.15 13:19 #
 

Not sure what your aim is?

MQL is a subset of C, not SGML or XML

Chart data can be output to CSV, from which Excel should be able to convert to XML?

-BB-

 
avatar
723
c0d3 2009.03.16 05:11 #
 
tm20:

Hi does anyone know of a good lightweight XML parser that can be used with MQL?

Thanks

Tony

You would have to write your own parser for XML in MQL4

avatar
Moderator
2029
gordon 2010.01.04 08:51 #
 

I'm looking for this functionality as well. The main aim is to be able to read/write simple and relatively small xml files. They will be used for custom 'set' files and as a means to write/read memory dumps for expert persistence. I know there are plenty of xml parsers out there for different languages but i couldn't find one that could be imported into MQL4 with relative ease, main problem being that all parsers have interfaces involving pointers, structs, etc. and other stuff that cannot be implemented in MQL4. Anybody have any suggestions?

 
avatar
69
phampton 2010.01.05 06:24 #
 
gordon wrote >>
  • I'm looking for this functionality as well. The main aim is to be able to read/write simple and relatively small xml files. They will be used for custom 'set' files and as a means to write/read memory dumps for expert persistence. I know there are plenty of xml parsers out there for different languages but i couldn't find one that could be imported into MQL4 with relative ease, main problem being that all parsers have interfaces involving pointers, structs, etc. and other stuff that cannot be implemented in MQL4. Anybody have any suggestions?

If you look at any of the truly universal XML parsers out there, the coding is amazingly complex. For MQL4 I think the best option is to hard code the XML structure. Here are a few utility functions I have written to read tag data.

Paul

http://paulsfxrandomwalk.blogspot.com/

int g_xmlFileHandle;
bool ReadNNxml()
{
   // note '<' delimiter
   g_xmlFileHandle = FileOpen(e_strXMLfile,FILE_CSV|FILE_READ,'<');
   if (g_xmlFileHandle <= 0)
   {
      Print("ReadNNxml(): ",ErrorDescription(GetLastError())," reading file ",e_strXMLfile);
      return(false);
   }

// Lots of ReadTagData() calls

}
string ReadTagData(string strTag)
{
   string strTagPlusData = FileReadString(g_xmlFileHandle);
   string strData = "";
   int nEndTagPos = StringFind(strTagPlusData,">",1);
   if (nEndTagPos == -1)
   {
      Print("ReadTagData(",strTag,") error - tag end not found in",strTagPlusData);
      return("");
   }
   string strTagExtract = StringSubstr(strTagPlusData,0,nEndTagPos);
   if (strTagExtract == strTag)
   {
     strData = StringSubstr(strTagPlusData,nEndTagPos+1);
   }
   else
   {
      Print("ReadTagData(",strTag,") error - tag does not match tag read: ",strTagExtract);
      return("");
   }
   if(!ReadTagEnd(strTag)) return("");
   return(strData);
}
bool ReadTag(string strTag)
{
   string strTagPlus = FileReadString(g_xmlFileHandle);
   int nEndTagPos = StringFind(strTagPlus,">",1);
   if (nEndTagPos == -1)
   {
      Print("ReadTag("+strTag+") tag end > not found");
      return(false);
   }
   string strTagExtract = StringSubstr(strTagPlus,0,nEndTagPos);
   if (strTagExtract != strTag)
   {
      Print("ReadTag(",strTag,") error - tag does not match tag read: ",strTagExtract);
      return(false);
   }
   return(true);
}
bool ReadTagEnd(string strTag)
{
   return(ReadTag("/"+strTag));
}
 
avatar
Moderator
2029
gordon 2010.01.05 06:52 #
 
phampton:

If you look at any of the truly universal XML parsers out there, the coding is amazingly complex. For MQL4 I think the best option is to hard code the XML structure. Here are a few utility functions I have written to read tag data.

Agree, very complex, which is my main incentive for trying to utilize an external parser. Unfortunately some kind of wrapper would have to be developed for the parser to enable it to interface with MQL4. I simply don't have the time to do that. I have considered expanding the code in the "HTML Walkthrough Using MQL4" article (http://articles.mql4.com/730), but I think the result would be very limited. Your approach is technically much simpler, but has the same limitations. But I guess there are no shortcuts here... Thanks anyway.

 
Back to topics list  

To add comments, please log in or register