//=============================================================================
// GrabNewsFF.mq4 - hacked up!
// Copyright © 2006, Derk Wehler
// Code derieved from original by: Copyright © 2006, Abhi
// (SCRIPT)
//=============================================================================
#property copyright "Copyright © 2006, Derk Wehler"
#property link "no site"
//
// Ron hacked this up so it can grab
// data from AlterTrader
//
#include <WinInet.mqh>
// it's the symbol + "clo" to get other data
string myUrl = "http://www.altertrader.com/GBPUSDclo.html";
string Outputfile = "altertrade.txt";
int beginning=1;
int start()
{
int handle;
int finalend;
int end;
int i;
string sData;
string xdate,xprice,xpct;
int size;
int endcheck;
GrabWeb(myUrl, sData);
finalend=StringLen(sData);
// let's parse it now and write to csv file
handle = FileOpen(Outputfile,FILE_CSV|FILE_WRITE,",");
// Handle DATE just once
beginning = StringFind(sData,"<BR>",beginning)+4;
end = StringFind(sData,"<",beginning);
//Print("1 B="+beginning+" E="+end);
if ((end-beginning)>0)
{
xdate = StringSubstr(sData,beginning,end-beginning);
}
FileWrite(handle,"Price","Percent ",xdate);
while (beginning < finalend)
{
// Handle PRICE
beginning = StringFind(sData,"align=\"center\">",beginning)+15;
end = StringFind(sData,"<",beginning);
//Print("1 B="+beginning+" E="+end);
if ((end-beginning)>0)
{
xprice = StringSubstr(sData,beginning,end-beginning);
}
// Handle PERCENT
beginning = StringFind(sData,"align=\"center\">",beginning)+15;
end = StringFind(sData,"<",beginning);
//Print("2 B="+beginning+" E="+end);
if ((end-beginning)>0)
{
xpct = StringSubstr(sData,beginning,end-beginning);
}
FileWrite(handle,xprice+","+xpct);
// are we out of data?
endcheck = StringFind(sData,"<tr>", beginning);
if(endcheck<0) break;
beginning=endcheck;
}
FileClose(handle);
Print("-----Parse complete-----");
}
Comments