Download MetaTrader 5
To add comments, please log in or register
Do you want to become a well-known developer? Execute the orders of traders in the Freelance service!
Kima
373
Kima 2013.03.01 13:31 

Ive done some research on the topic. But the only 'recent' thing i could find was a script from 2011.11.29 13:46
https://www.mql5.com/en/code/712

 But it gives me a lot of errors (very a lot) when i load it up to MetaEditor.

So i thought maybe  there is now a standard function implemented to load a XML feed now 2 years later?

 

Edit: to fast to a post.. i can convert it to a csv and then open it in OpenFile() option. This will do i think

/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#

 

But now ive to set arrays to variables. But what is the right way?

// make starting array
double buy_time[];
double buy_type[];

int OnInit()
  {
// set array information

  ArrayResize(buy_time,8);
  ArrayResize(buy_type,8);
  
   ArrayFill(buy_time, 1, 1, "2012.01.19 10:45:00");
   ArrayFill(buy_type, 1, 1, "1"); 

// and so on
// something like, like php..

   buy_time[1] = "2012.01.19 10:45:00";
   buy_type[1] = "2";

   buy_time[2] = "2012.01.20 14:15:00";
   buy_type[2] = "2";

   buy_time[3] = "2012.01.21 08:45:00";
   buy_type[3] = "1";

   buy_time[4] = "2012.01.21 14:15:00";
   buy_type[4] = "2";

   buy_time[5] = "2012.01.21 15:45:00";
   buy_type[5] = "1";

   buy_time[6] = "2012.01.22 09:45:00";
   buy_type[6] = "1";

   buy_time[7] = "2012.01.26 15:45:00";
   buy_type[7] = "2";
}

void OnTick()
  {
         for(int q=1;q<7;q++) 
           {
            if(buy_time[q]>TimeCurrent() -30 && buy_time[q]<TimeCurrent()+30) 
              {
               if(buy_type[q]== "1") 
                 {
                 Print("start long trade");
                    } else {
                 Print("start short trade");
                 }
              }
           }
        }
}



Or total something else?  

XML parser
XML parser
  • votes: 7
  • 2011.11.29
  • yu-sha
  • www.mql5.com
A library for parsing of XML documents. Pure MQL5, it doesn't uses any external libraries.
phi nuts
2184
phi nuts 2013.03.02 09:32  
Kima:

Ive done some research on the topic. But the only 'recent' thing i could find was a script from 2011.11.29 13:46
https://www.mql5.com/en/code/712

 But it gives me a lot of errors (very a lot) when i load it up to MetaEditor.

So i thought maybe  there is now a standard function implemented to load a XML feed now 2 years later?

Edit: to fast to a post.. i can convert it to a csv and then open it in OpenFile() option. This will do i think

/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#

But now ive to set arrays to variables. But what is the right way?


Or total something else?  

1. I haven't check the XML script you gave, so maybe later.

2. Start counting elements of array from zero, not from 1. 

3. In mql5, a datetime is actually an integer of number of second since Jan 1, 1970. So when you do this

TimeCurrent() + 30;

It mean TimeCurrent() plus 30 seconds, NOT plus 30 minutes, or plus 30 hours, but plus 30 seconds. If you want to ad - say 45 minutes to TimeCurrent(), do this :

int forty_five_minutes;

forty_five_minutes = 45*60;

TimeCurrent() + forty_five_minutes;

 4. The result value of your .csv file reading is a string type, so you may assign that value to other string variable or convert the string value into anther type by using some conversion function

// make starting array
datetime buy_time[];
string   buy_type[];

int OnInit()
  {
// set array information

  ArrayResize(buy_time,8);
  ArrayResize(buy_type,8);
  
   //--- ArrayFill(buy_time, 1, 1, "2012.01.19 10:45:00");
   //--- ArrayFill(buy_type, 1, 1, "1"); 

// and so on
// something like, like php..

   buy_time[0] = StringToTime("2012.01.19 10:45:00");
   buy_type[0] = "2";

   buy_time[1] = StringToTime("2012.01.20 14:15:00");
   buy_type[1] = "2";

  

Kima
373
Kima 2013.03.05 23:50  
Thks, it helped me alot. :) 
/
To add comments, please log in or register