Ticaret robotlarını ücretsiz olarak nasıl indirebileceğinizi izleyin
Bizi Facebook üzerinde bulun!
Fan sayfamıza katılın
Komut dosyasını ilginç mi buldunuz?
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
Komut dosyasını beğendiniz mi? MetaTrader 5 terminalinde deneyin
Kütüphaneler

XML parser - MetaTrader 5 için kütüphane

Görüntülemeler:
5775
Derecelendirme:
(31)
Yayınlandı:
2011.11.29 13:46
Güncellendi:
2016.11.22 07:32
\MQL5\Include\XML\ \MQL5\Scripts\
Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git

A library for parsing of XML documents. Pure MQL5, it doesn't uses any external libraries.

To use the library, just include it:

#include <Xml\XmlBase.mqh>

Example:

#include <Xml\XmlBase.mqh>

CXmlDocument doc;

void OnStart() 
{
  string file = "File.xml";
  string err;
  if (doc.CreateFromText(file,err))
  {
    CXmlElement * xmlItem = doc.FDocumentElement.GetChild(0);
    for (int i=0; i<xmlItem.GetChildCount(); i++) 
    if (xmlItem.GetChild(i).GetName() == "LAYER")
    {
      CXmlElement* layer = xmlItem.GetChild(i);
      for (int j=0; j<layer.GetChildCount(); ++j) 
      {        
        if (layer.GetChild(j).GetName() == "NEURON")
        {
           /* .... */
        }
      }
    }
  }
}

Notes:

  • The library was written when constuctors in MQL5 were without parameters;
  • Only basic functions of Xml standard is supported;
  • Plese inform me about errors, suggestions and bug fixes.

Main components:

CXmlDocument class provides methods for downloading of XML documents from file/string and save to file.

CreateX functions parses XML documents and create hierarchy of DOM model, the working with it can be done using FDocumentElement 

class CXmlDocument 
{
  private:

    void DoElementTrimText(CXmlElement &aXmlItem) ;
  
  public:
    CXmlElement FDocumentElement;

    void CXmlDocument ();
    void ~CXmlDocument ();
    void Clear();
    void CopyTo (CXmlDocument &xmlDoc);
  
    bool  CreateFromText (const string& xml, string& err);
    bool  CreateFromFile (const string filename, string& err);
    bool  SaveToFile (const string filename);

    string GetXml();
};

 

CXmlElement class is a base interface of any XML document. It provides access to elements, attributes and content

class CXmlElement 
{
  private:
    string         FName;
    CXmlAttribute* FAttributes[];
    CXmlElement   *FElements[];
    string         FText;
    CXmlElement*   FParent;
  public:  
    //--- constructor methods
    void  CXmlElement ();
    void ~CXmlElement ();
    void Init (const string aName, const CXmlElement* aParent=NULL, const string aText="");
    void CopyTo (CXmlElement &aDst);
    virtual void Clear ();
    
    //--- main service methods
    string GetName () const;
    void SetName (const string aName);
    string GetText () const;
    void SetText (const string aText);
    CXmlElement* GetParent () const;
    void SetParent (CXmlElement* aParent);
    
    //--- attribute service methods
    int GetAttributeCount () const;
    int GetAttributeIndex (CXmlAttribute* aAttr) const;
    CXmlAttribute* GetAttribute (const string aName) const;
    CXmlAttribute* GetAttribute (int aPos) const;
    string GetAttributeValue (const string aName) const;
    
    CXmlAttribute* AttributeInsertAt (CXmlAttribute* aAttr, int aPos);
    CXmlAttribute* AttributeAdd (CXmlAttribute* aAttr);
    CXmlAttribute* AttributeInsertAfter (CXmlAttribute* aAfter, CXmlAttribute* aAttr);
    CXmlAttribute* AttributeInsertBefore (CXmlAttribute* aBefore, CXmlAttribute* aAttr);
    CXmlAttribute* AttributeRemove (CXmlAttribute* aAttr);
    CXmlAttribute* AttributeRemove (int aPos);
    void AttributeDelete (CXmlAttribute* aAttr);
    void AttributeDelete (int aPos);
    void AttributeDeleteAll ();
  
    //--- child service methods
    int GetChildCount() const;
    int GetChildIndex (CXmlElement* aElement) const;
    CXmlElement* GetChild (const string aName) const;
    CXmlElement* GetChild (int aPos) const;
    string GetChildText (const string aName) const;

    CXmlElement* ChildInsertAt (CXmlElement* aElement, int aPos);
    CXmlElement* ChildAdd (CXmlElement* aElement);
    CXmlElement* ChildInsertAfter (CXmlElement* aAfter, CXmlElement* aElement);
    CXmlElement* ChildInsertBefore (CXmlElement* aBefore, CXmlElement* aElement);
    CXmlElement* ChildRemove (CXmlElement* aElement);
    CXmlElement* ChildRemove (int aPos);
    void ChildDelete (CXmlElement* aElement);
    void ChildDelete (int aPos);
    void ChildDeleteAll ();
  
    string GetXml(int aLevel);
};

 

CXmlAttribute is a simple class for working with attributes

class CXmlAttribute 
{
  private:
    string FName;
    string FValue;
 public:
    //--- constructor methods
    void CXmlAttribute ();
    void ~CXmlAttribute ();

    void Init (const string aName, const string aValue);
    virtual void Clear ();
    virtual CXmlAttribute* Clone ();
    
    //--- service methods
    string GetName () const;
    void SetName (const string aName);
    string GetValue () const;
    void SetValue (const string aValue);    
};

MetaQuotes Ltd tarafından Rusçadan çevrilmiştir.
Orijinal kod: https://www.mql5.com/ru/code/712

Candles Smoothed HTF Candles Smoothed HTF

The indicator that displays "averaged" candlesticks of a larger timeframe at a smaller one.

Magnified Market Price Magnified Market Price

The indicator shows the current price in one of the chart corners.

Three-Pole Super Smoother Filter Three-Pole Super Smoother Filter

Three-pole super smoother filter from John Ehlers' book "Cybernetic Analysis for Stocks and Futures: Cutting-Edge DSP Technology to Improve Your Trading" is used in this indicator for moving average calculation.

JFatlSpeed HTF JFatlSpeed HTF

This indicator shows the direction of the acceleration of JFatlSpeed price from a larger timeframe at a smaller one.