1. Go to this page and download the library: Download alisafirzadeh/php-mt5 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alisafirzadeh / php-mt5 example snippets
use Tarikh\PhpMeta\Entities\Trade;
use Tarikh\PhpMeta\LaravelMt5;
use Tarikh\PhpMeta\MetaTraderClient;
use Tarikh\PhpMeta\Entities\User;
use Tarikh\PhpMeta\src\Lib\MTEnDealAction;
$server = "SERVER_MT4_IP";
$port = 443;
$login = "MANAGER LOGIN";
$password = "API PASSWORD";
$exampleLogin = 21001480007;
$client = new MetaTraderClient($server, $port, $login, $password);
$trade = new Trade();
$trade->setLogin(6000189);
$trade->setAmount(100);
$trade->setComment("Deposit");
$trade->setType(Trade::DEAL_BALANCE);
$result = $client->trade($trade);
use Tarikh\PhpMeta\MetaTraderClient;
$server = "SERVER_MT4_IP";
$port = 443;
$login = "MANAGER LOGIN";
$password = "API PASSWORD";
$exampleLogin = 21001480007;
$client = new MetaTraderClient($server, $port, $login, $password);
// symbol — comma separated symbols, the prices of which should be received. The value length must not exceed 4096 characters. You may use the mask "*" and the negation sign "!" to specify groups of symbols. Example.
// symbol=EURUSD,USDJPY — get quotes for symbols EURUSD and USDJPY.
// symbol=Forex\Major*, GOLD — get quotes of all symbols from the Major subgroup and quotes of GOLD.
// symbol=Forex\Crosses*,!AUDUSD — get quotes of all symbols of the Crosses subgroup except AUDUSD.
// symbol=Forex\Major\EUR* — get quotes of all symbols with the basic currency EUR from the Major subgroup.
$ticks = $client->getLastTick("AUDCAD");
foreach ($ticks as $key => $tick) {
echo "{$tick->Symbol} BID {$tick->Bid} {$tick->Ask}\n";
}
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.