How about something a little easier, using the FTP function in MT4
Set your FTP settings in Metatrader under Tools / Options / Publisher.
Then write an EA with something like this:
PHP Code:
//+------------------------------------------------------------------+
//| MistigriFX - OOW.mq4 |
//| Copyright © 2008, Patrick Nouvion |
//| http://www.mistigrifx.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Patrick Nouvion"
#property link "http://www.mistigrifx.com"
//+------------------------------------------------------------------+
//| GlobalVars |
//+------------------------------------------------------------------+
string FileName = "";
datetime CurrTime = 0;
datetime PrevTime = 0;
//+------------------------------------------------------------------+
//| expert init / deinit |
//+------------------------------------------------------------------+
int init()
{
FileName = StringConcatenate( AccountNumber(), "-Trades.php" );
CurrTime = iTime( Symbol(), 1, 1 );
PrevTime = iTime( Symbol(), 1, 2 );
//----
return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
CurrTime = iTime( Symbol(), 1, 1 );
if( CountAll() != 0 && CurrTime != PrevTime )
{
int H1 = FileOpen( FileName , FILE_CSV|FILE_READ|FILE_WRITE, ',' );
if( H1 < 0 ) { Alert( GetLastError() ); return(-1); }
for( int i = 0; i < OrdersTotal(); i++ )
{
OrderSelect( i, SELECT_BY_POS, MODE_TRADES );
string Data = StringConcatenate( OrderSymbol()," ", OrderLots(), " ", OrderProfit() );
FileWrite( H1, Data );
FileWrite( H1, "<br />");
}
FileClose( H1 );
//----
if( !SendFTP(FileName) ) { Print( GetLastError() ); }
PrevTime = CurrTime;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
// CountAll |
//+------------------------------------------------------------------+
int CountAll()
{
int count=0;
for(int i = OrdersTotal()-1; i >=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
int OrdMag = OrderMagicNumber();
int OrdNum = OrderTicket();
if( OrderType() == OP_BUY ) { count++; }
else if( OrderType() == OP_SELL ) { count++; }
}
return(count);
}
//+------------------------------------------------------------------+
On your website write a php page with something like this:
PHP Code:
<div id="bodyPan">
<h2>View Trades</h2>
<?php
$AccountPost = 0;
$AccountGet = 0;
$Account = 0;
$AccountPost = $_POST['Account'];
$AccountGet = $_GET['Account'];
if( $AccountPost != 0 || $AccountGet != 0 )
{
if( $AccountPost != 0 ) { $Account = $AccountPost; }
else { $Account = $AccountGet; }
echo "<p>Account #: $Account </p>";
$FileSta = "./OOW/";
$FileEnd = "-Trades.php";
$myFile = $FileSta . $Account . $FileEnd;
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo "<p>";
echo $theData;
echo "</p>";
}
else
{
?>
<p>
<form name="ViewTrades" method="post" action="">
<label stle="margin-top: 5px;">Account:</label>
<input style="margin-top: 11px; margin-left: 15px;" type="text" name="Account" value="0" />
<input class="submit" type="submit" name="submit" value="Submit" style="background-color: #ffffff; margin-left: 100px; margin-top: 18px;" />
</form>
</p>
<?php
}
?>
</div>
Notice that I upload the file to a OOW folder ... You would obviously have to change that, but in the end the file would be uploaded every minute.
For an example Go to this link :
MistigriFx - View Trades
Enter 123456 for the account number or Click on
MistigriFx - View Trades?Account=123456
Patrick