Algorex Equity Publisher: help, server files and FAQ

23 November 2026, 01:43
Daniel Schwoerer
0
11

Help for Algorex Equity Publisher: setup, all inputs, the server files and answers to frequent questions. Download: MetaTrader 5, MetaTrader 4.

Algorex Equity Publisher sends your account to your own website: balance, equity, drawdown and every closed deal. It reports every hour and five seconds after each trade, so the page on your server stays current without manual exports.

Demo and live accounts. No trading function: it never opens, modifies or closes a position.

What it sends

  • Balance, equity, margin, floating result and open positions
  • Peak equity, current drawdown and maximum drawdown in percent
  • Closed deals with time, symbol, direction, volume, price, profit, commission, swap and fee
  • Account label, server, broker, currency and leverage (the account number is sent only to your endpoint for the allowlist)

Security

  • Every request is signed with HMAC-SHA256 (headers X-Algorex-Account, X-Algorex-Timestamp, X-Algorex-Signature)
  • Your server accepts only listed accounts and requests no older than 300 seconds
  • Data goes only to the address you enter. Nothing is sent to Algorex or any third party

Your page

The self-host package for any PHP web space contains the receiving script, a one-time setup page and an account statement page with equity curve, drawdown chart and trade list in English and German. The page loads only with your private view key and is not indexed by search engines.

Setup

  • Upload the package to your web space and open the setup page once: it creates the secret key and the view key
  • In MetaTrader: Tools > Options > Expert Advisors > Allow WebRequest for listed URL, add your domain
  • Attach the Publisher to any chart of the account, enter the endpoint URL and the secret key
  • Dry run writes the JSON to the log without sending, for a first check

Inputs

  • Endpoint URL (HTTPS), secret key (32 to 128 hex characters), account label shown on the website
  • Regular send interval in minutes (5 to 1440, default 60), delay after a trade (default 5 seconds), maximum deals per request
  • Language / Sprache: Auto, English or Deutsch; status line on the chart; dry run

One copy on any chart covers the whole account. In the Strategy Tester the Publisher stays inactive, because WebRequest does not run there. Also available for MetaTrader 4 and ATAS.

Server files

The files below form the self-host package. Save them under httpdocs/equity/ on your web space, create the folder private one level above httpdocs, then open setup.php once (see Setup).

httpdocs/equity/api.php

<?php
/*
 * Algorex Equity Publisher: receiving endpoint, self-host edition v1.01 (22.11.2026)
 * POST: accepts data from the Algorex Equity Publisher (MT4, MT5, ATAS), HMAC-SHA256, 300 s window, account allowlist
 * GET : returns public data for equity/index.html (without account number), only with ?v=<view_key>
 * Configuration: ../../private/equity_config.php (outside httpdocs), fallback equity/_data/equity_config.php
 */
declare(strict_types=1);

const MAX_BODY = 262144;
const MAX_SKEW = 300;
const MAX_SERIES = 50000;
const OUT_SERIES = 1500;

ini_set('serialize_precision', '-1');
header('X-Content-Type-Options: nosniff');

function out(int $code, array $data): void {
    http_response_code($code);
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
    exit;
}
function storeDir(): string {
    $priv = dirname(__DIR__, 2) . '/private';
    if (is_dir($priv) && is_writable($priv)) {
        $d = $priv . '/equity';
        if (!is_dir($d)) @mkdir($d, 0750);
        if (is_dir($d) && is_writable($d)) return $d;
    }
    $d = __DIR__ . '/_data';
    if (!is_dir($d)) @mkdir($d, 0750);
    return $d;
}
function config(): array {
    foreach ([dirname(__DIR__, 2) . '/private/equity_config.php', __DIR__ . '/_data/equity_config.php'] as $f) {
        if (is_file($f)) { $c = include $f; if (is_array($c)) return $c; }
    }
    return [];
}
$CFG = config();
function secret(): ?string {
    global $CFG;
    $s = trim((string)($CFG['secret'] ?? ''));
    return preg_match('/^[0-9a-fA-F]{32,128}$/', $s) ? $s : null;
}
function viewKey(): string { global $CFG; return (string)($CFG['view_key'] ?? ''); }
function allowAccounts(): array { global $CFG; return array_map('strval', (array)($CFG['accounts'] ?? [])); }
function acct($v): string { $s = (string)$v; return preg_match('/^[A-Za-z0-9._\-]{1,48}$/', $s) ? $s : ''; }
function readJson(string $f, $def) {
    if (!is_file($f)) return $def;
    $j = json_decode((string)file_get_contents($f), true);
    return $j === null ? $def : $j;
}
function writeJson(string $f, $data): bool {
    $tmp = $f . '.tmp' . getmypid();
    if (file_put_contents($tmp, json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)) === false) return false;
    return rename($tmp, $f);
}
function num($v): float { return is_numeric($v) ? (float)$v : 0.0; }
function str($v, int $max = 64): string { return mb_substr(preg_replace('/[\x00-\x1F\x7F]/u', '', (string)$v) ?? '', 0, $max); }
function ts($iso): int { $t = strtotime((string)$iso); return $t === false ? 0 : $t; }

$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';

/* ---------- GET: öffentliche Ausgabe ---------- */
if ($method === 'GET' || $method === 'HEAD') {
    if (viewKey() === '' || !hash_equals(viewKey(), (string)($_GET['v'] ?? ''))) out(404, ['ok' => false]);
    header('Cache-Control: private, max-age=60');
    header('X-Robots-Tag: noindex, nofollow');
    $dir = storeDir();
    $state = readJson($dir . '/state.json', null);
    if (!$state) out(200, ['ok' => true, 'empty' => true]);
    $deals = array_values(readJson($dir . '/deals.json', []));
    usort($deals, fn($a, $b) => $a['t'] <=> $b['t'] ?: strcmp((string)$a['ticket'], (string)$b['ticket']));
    $series = readJson($dir . '/series.json', []);
    $n = count($series);
    if ($n > OUT_SERIES) {               // ausdünnen, letzten Punkt behalten
        $step = $n / OUT_SERIES; $s2 = [];
        for ($i = 0; $i < OUT_SERIES; $i++) $s2[] = $series[(int)floor($i * $step)];
        $s2[] = $series[$n - 1];
        $series = $s2;
    }
    $pub = [];
    foreach ($deals as $d) {
        $pub[] = ['t' => $d['t'], 'symbol' => $d['symbol'], 'type' => $d['type'], 'entry' => $d['entry'],
                  'volume' => $d['volume'], 'price' => $d['price'], 'pos' => (string)($d['position'] ?? ''), 'pl' => round($d['profit'] + $d['commission'] + $d['swap'] + $d['fee'], 2)];
    }
    out(200, ['ok' => true, 'account' => $state['account'], 'last' => $state['last'], 'updated' => $state['updated'],
              'series' => $series, 'deals' => $pub]);
}

/* ---------- POST: Empfang vom EA ---------- */
if ($method !== 'POST') { header('Allow: GET, POST'); out(405, ['ok' => false, 'error' => 'method']); }

$len = (int)($_SERVER['CONTENT_LENGTH'] ?? 0);
if ($len > MAX_BODY) out(413, ['ok' => false, 'error' => 'size']);
$raw = (string)file_get_contents('php://input', false, null, 0, MAX_BODY + 1);
if (strlen($raw) > MAX_BODY || $raw === '') out(413, ['ok' => false, 'error' => 'size']);

$acc = acct($_SERVER['HTTP_X_ALGOREX_ACCOUNT'] ?? '');
$tsH = (string)($_SERVER['HTTP_X_ALGOREX_TIMESTAMP'] ?? '');
$sig = strtolower((string)($_SERVER['HTTP_X_ALGOREX_SIGNATURE'] ?? ''));
if ($acc === '' || !in_array($acc, allowAccounts(), true)) out(403, ['ok' => false, 'error' => 'account']);
if (!ctype_digit($tsH) || abs(time() - (int)$tsH) > MAX_SKEW) out(401, ['ok' => false, 'error' => 'time']);

$secret = secret();
if ($secret === null) out(503, ['ok' => false, 'error' => 'not configured']);
if (!preg_match('/^[0-9a-f]{64}$/', $sig) || !hash_equals(hash_hmac('sha256', $tsH . '.' . $raw, $secret), $sig))
    out(401, ['ok' => false, 'error' => 'signature']);

$p = json_decode($raw, true);
if (!is_array($p) || (int)($p['v'] ?? 0) !== 1) out(400, ['ok' => false, 'error' => 'payload']);
if ((string)($p['account']['login'] ?? '') !== $acc) out(400, ['ok' => false, 'error' => 'login mismatch']);

$dir = storeDir();
$lock = fopen($dir . '/.lock', 'c');
if (!$lock || !flock($lock, LOCK_EX)) out(500, ['ok' => false, 'error' => 'lock']);

// Deals: eindeutig nach Ticket, Wiederholungen überschreiben
$deals = readJson($dir . '/deals.json', []);
$okTypes = ['buy','sell','balance','credit','charge','correction','commission','other'];
$okEntry = ['in','out','inout','out_by'];
$added = 0;
foreach (($p['deals'] ?? []) as $d) {
    if (!is_array($d)) continue;
    $tk = preg_replace('/[^A-Za-z0-9._:\-]/', '', (string)($d['ticket'] ?? ''));
    if ($tk === '' || $tk === '0' || strlen($tk) > 64) continue;
    if (!isset($deals[$tk])) $added++;
    $deals[$tk] = [
        'ticket' => $tk, 't' => ts($d['time'] ?? ''), 'symbol' => str($d['symbol'] ?? '', 32),
        'type' => in_array($d['type'] ?? '', $okTypes, true) ? $d['type'] : 'other',
        'entry' => in_array($d['entry'] ?? '', $okEntry, true) ? $d['entry'] : 'in',
        'volume' => num($d['volume'] ?? 0), 'price' => num($d['price'] ?? 0), 'profit' => num($d['profit'] ?? 0),
        'commission' => num($d['commission'] ?? 0), 'swap' => num($d['swap'] ?? 0), 'fee' => num($d['fee'] ?? 0),
        'magic' => (int)($d['magic'] ?? 0), 'position' => str($d['position'] ?? '', 64),
    ];
}

// Snapshot an die Reihe hängen: [Unix, Saldo, Equity, DD %]
$series = readJson($dir . '/series.json', []);
$t = ts($p['sent_at'] ?? '') ?: time();
$snap = [$t, round(num($p['balance'] ?? 0), 2), round(num($p['equity'] ?? 0), 2), round(num($p['dd_pct'] ?? 0), 3)];
$lastT = $series ? end($series)[0] : 0;
if ($t >= $lastT) $series[] = $snap;
if (count($series) > MAX_SERIES) $series = array_slice($series, -MAX_SERIES);

$a = $p['account'] ?? [];
$state = [
    'account' => ['label' => str($a['label'] ?? 'Demo', 48), 'server' => str($a['server'] ?? '', 48), 'company' => str($a['company'] ?? '', 64),
                  'currency' => str($a['currency'] ?? 'USD', 8), 'leverage' => (int)($a['leverage'] ?? 0), 'demo' => (bool)($a['demo'] ?? false)],
    'last' => ['t' => $t, 'event' => str($p['event'] ?? '', 16), 'balance' => $snap[1], 'equity' => $snap[2],
               'margin' => round(num($p['margin'] ?? 0), 2), 'floating' => round(num($p['floating'] ?? 0), 2),
               'open_positions' => (int)($p['open_positions'] ?? 0), 'peak_equity' => round(num($p['peak_equity'] ?? 0), 2),
               'dd_pct' => round(num($p['dd_pct'] ?? 0), 3), 'max_dd_pct' => round(num($p['max_dd_pct'] ?? 0), 3)],
    'ea_version' => str($p['ea_version'] ?? '', 16), 'platform' => str($p['platform'] ?? 'mt5', 8),
    'updated' => time(),
];

$ok = writeJson($dir . '/deals.json', $deals) && writeJson($dir . '/series.json', $series) && writeJson($dir . '/state.json', $state);
flock($lock, LOCK_UN); fclose($lock);
if (!$ok) out(500, ['ok' => false, 'error' => 'write']);
out(200, ['ok' => true, 'deals_new' => $added, 'deals_total' => count($deals)]);

httpdocs/equity/setup.php

<?php
/*
 * Algorex Equity Publisher: one-time setup (self-host edition 1.01)
 * Open https://{{DOMAIN}}/equity/setup.php?account=YOUR_ACCOUNT once. It writes ../../private/equity_config.php
 * with a new secret key and view key, shows both once, and deletes itself.
 */
declare(strict_types=1);
header('Cache-Control: no-store');
header('X-Robots-Tag: noindex, nofollow');
header('Referrer-Policy: no-referrer');
header('Content-Type: text/html; charset=utf-8');

$acc = (string)($_GET['account'] ?? '');
if (!preg_match('/^[A-Za-z0-9._\-]{1,48}$/', $acc)) { http_response_code(400); exit('<p style="font:16px sans-serif">Add ?account=YOUR_ACCOUNT_NUMBER to the address.</p>'); }

$priv = dirname(__DIR__, 2) . '/private';
$targets = [$priv . '/equity_config.php', __DIR__ . '/_data/equity_config.php'];
if (!is_dir(__DIR__ . '/_data')) @mkdir(__DIR__ . '/_data', 0750);
$key = bin2hex(random_bytes(32));
$view = bin2hex(random_bytes(6));
$php = "<?php\nreturn ['secret' => '" . $key . "', 'accounts' => ['" . $acc . "'], 'view_key' => '" . $view . "'];\n";
$ok = false; $where = '';
foreach ($targets as $f) {
    if (is_dir(dirname($f)) && is_writable(dirname($f)) && file_put_contents($f, $php, LOCK_EX) !== false) { @chmod($f, 0640); $ok = true; $where = $f; break; }
}
if (!$ok) { http_response_code(500); exit('<p style="font:16px sans-serif">The configuration could not be written. Create private/equity_config.php by hand.</p>'); }
@unlink(__FILE__);
$page = 'index.html#v=' . $view;
?><!doctype html><html><head><meta charset="utf-8"><meta name="robots" content="noindex,nofollow"><title>Algorex Equity Publisher setup</title></head>
<body style="font:16px/1.5 system-ui,sans-serif;max-width:760px;margin:40px auto;padding:0 20px;color:#16243A">
<h1 style="font-size:24px">Algorex Equity Publisher: setup done</h1>
<p>Shown only once; this page has deleted itself. Store the key safely.</p>
<p><b>Secret key</b> (EA / ATAS input «Secret key»):<br><input value="<?= htmlspecialchars($key) ?>" readonly onclick="this.select()" style="width:100%;font:15px monospace;padding:8px"></p>
<p><b>Your page</b>: <a href="<?= htmlspecialchars($page) ?>"><?= htmlspecialchars($page) ?></a></p>
<p>Allowed account: <code><?= htmlspecialchars($acc) ?></code>. Stored in <code><?= htmlspecialchars(basename(dirname($where)) . '/' . basename($where)) ?></code>.</p>
</body></html>

httpdocs/equity/index.html

<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="robots" content="noindex, nofollow, noarchive"><meta name="referrer" content="no-referrer">
<title>Account statement</title>
<style>
:root{--navy:#0F2340;--ink:#16243A;--slate:#55657A;--mist:#8A97A8;--line:#E3E8EF;--paper:#F7F9FC;--gain:#1E7A4C;--loss:#B8433A;--gold:#E0A126}
*{box-sizing:border-box}body{margin:0;font:15px/1.55 system-ui,-apple-system,"Segoe UI",Inter,sans-serif;color:var(--ink);background:#fff}
.wrap{max-width:1080px;margin:0 auto;padding:28px 20px 60px}h1{font-size:28px;margin:0 0 6px;color:var(--navy)}
.lead{color:var(--slate);margin:0 0 22px}.top{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap}
.top a{color:var(--slate);font-size:14px}
.ldkpi{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:0 0 26px}
.ldk{background:var(--paper);border:1px solid var(--line);border-radius:8px;padding:12px 14px}
.ldk span{display:block;font-size:13px;color:var(--slate);margin-bottom:4px}.ldk b{font-size:19px;color:var(--navy)}
.gain{color:var(--gain)!important}.loss{color:var(--loss)!important}
.ldc{border:1px solid var(--line);border-radius:8px;padding:10px 8px 4px;margin:0 0 10px;background:#fff}
.ldc svg text{font:12px system-ui,sans-serif;fill:var(--mist)}
h2{font-size:18px;margin:26px 0 10px;color:var(--navy)}
.ldt{width:100%;border-collapse:collapse;font-size:14px}.ldt th,.ldt td{padding:7px 8px;border-bottom:1px solid var(--line);text-align:left;white-space:nowrap}
.ldt th{color:var(--slate);font-weight:600}.ldt .n{text-align:right;font-variant-numeric:tabular-nums}
.ldtw{overflow-x:auto}.btn{margin-top:14px;font:600 14px system-ui,sans-serif;padding:8px 14px;border-radius:6px;border:1.5px solid var(--navy);background:#fff;cursor:pointer}
.ldupd{color:var(--mist);font-size:13px;margin:-14px 0 22px}.ldmsg{padding:18px;border:1px dashed var(--line);border-radius:8px;color:var(--slate)}
.foot{margin-top:34px;color:var(--mist);font-size:12px}
</style></head>
<body><main class="wrap"><section id="ld" data-api="api.php">
<div class="top"><h1 id="ld-h1">Account statement</h1><a href="#" id="ld-lang">Deutsch</a></div>
<p class="lead" id="ld-lead"></p>
<div class="ldmsg" id="ld-msg">…</div>
<div id="ld-body" hidden>
<p class="ldupd" id="ld-upd"></p>
<div class="ldkpi" id="ld-kpi"></div>
<h2 id="ld-h-eq"></h2><div class="ldc" id="ld-eq"></div>
<h2 id="ld-h-dd"></h2><div class="ldc" id="ld-dd"></div>
<h2 id="ld-h-tr"></h2><div class="ldtw" id="ld-tbl"></div>
</div>
<p class="foot" id="ld-foot"></p>
</section></main>
<script src="equity.js?v=101" defer></script></body></html>

httpdocs/equity/equity.js

/* Algorex Equity Publisher, self-host page v1.01: equity curve, drawdown, trade list */
(function(){
  var root=document.getElementById('ld'); if(!root) return;
  var qs=new URLSearchParams(location.search), hs=new URLSearchParams(location.hash.replace(/^#/,''));
  var view=hs.get('v')||qs.get('v')||'';
  var lang=(hs.get('lang')||qs.get('lang')||(navigator.language||'en')).slice(0,2)==='de'?'de':'en';
  var api=root.getAttribute('data-api')+'?v='+encodeURIComponent(view);
  var TT={de:{h1:'Kontoauszug',lead:'Saldo, Equity und abgeschlossene Trades, direkt aus der Handelsplattform übertragen. Die Seite lädt alle fünf Minuten neu.',
    empty:'Noch keine Daten. Die Übertragung startet in Kürze.',err:'Die Daten konnten nicht geladen werden.',nov:'Adresse ohne Zugangsschlüssel (#v=…).',
    bal:'Saldo',eq:'Equity',ret:'Ergebnis seit Einzahlung',mdd:'Max. Drawdown',tr:'Abgeschlossene Trades',wr:'Trefferquote',pf:'Gewinnfaktor',open:'Offene Positionen',
    upd:'Stand',tin:'Einstieg (UTC)',tout:'Ausstieg (UTC)',sym:'Instrument',dir:'Richtung',vol:'Volumen',pl:'Ergebnis',long:'Long',short:'Short',
    more:'Alle Trades anzeigen',less:'Weniger anzeigen',eqc:'Equity-Kurve',ddc:'Drawdown',trs:'Trades',dep0:'Einzahlung',demo:'Demokonto, virtuelles Geld.',
    foot:'Vergangene Ergebnisse sind kein Hinweis auf künftige Ergebnisse. Keine Anlageberatung.',other:'English'},
   en:{h1:'Account statement',lead:'Balance, equity and closed trades, transmitted straight from the trading platform. The page reloads every five minutes.',
    empty:'No data yet. Transmission starts shortly.',err:'The data could not be loaded.',nov:'Address without access key (#v=…).',
    bal:'Balance',eq:'Equity',ret:'Result since deposit',mdd:'Max. drawdown',tr:'Closed trades',wr:'Win rate',pf:'Profit factor',open:'Open positions',
    upd:'As of',tin:'Entry (UTC)',tout:'Exit (UTC)',sym:'Instrument',dir:'Direction',vol:'Volume',pl:'Result',long:'Long',short:'Short',
    more:'Show all trades',less:'Show fewer',eqc:'Equity curve',ddc:'Drawdown',trs:'Trades',dep0:'Deposit',demo:'Demo account, virtual money.',
    foot:'Past results are no indication of future results. Not investment advice.',other:'Deutsch'}};
  var T=TT[lang], loc=lang==='de'?'de-CH':'en-GB';
  function el(id){return document.getElementById(id);}
  document.documentElement.lang=lang; document.title=T.h1;
  el('ld-h1').textContent=T.h1; el('ld-lead').textContent=T.lead; el('ld-h-eq').textContent=T.eqc; el('ld-h-dd').textContent=T.ddc; el('ld-h-tr').textContent=T.trs;
  el('ld-foot').textContent=T.foot; el('ld-msg').textContent='…';
  var sw=el('ld-lang'); sw.textContent=T.other; sw.onclick=function(e){e.preventDefault(); hs.set('lang',lang==='de'?'en':'de'); location.hash=hs.toString(); location.reload();};
  function f(n,d){return Number(n).toLocaleString(loc,{minimumFractionDigits:d==null?2:d,maximumFractionDigits:d==null?2:d});}
  function dt(t){return new Date(t*1000).toISOString().slice(0,16).replace('T',' ');}
  function esc(s){return String(s).replace(/[&<>"]/g,function(c){return{'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c];});}

  function build(d){
    var cur=d.account.currency||'USD', deals=d.deals||[], pts=[], bal=0, dep=0, trades=[], open={};
    deals.forEach(function(x){
      if(x.type==='balance'||x.type==='credit'||x.type==='correction'||x.type==='charge'){bal+=x.pl; if(x.type==='balance'&&x.pl>0) dep+=x.pl; pts.push([x.t,bal]); return;}
      bal+=x.pl;
      if(x.type==='buy'||x.type==='sell'){
        var k=x.symbol+'|'+(x.pos||'');
        if(x.entry==='in'){ if(!open[k]) open[k]={t:x.t,type:x.type,pl:x.pl}; else open[k].pl+=x.pl; }
        else { var en=open[k]||null; trades.push({tin:en?en.t:null,t:x.t,symbol:x.symbol,long:en?en.type==='buy':x.type==='sell',volume:x.volume,pl:x.pl+(en?en.pl:0)}); delete open[k];
               if(x.entry==='inout') open[k]={t:x.t,type:x.type,pl:0}; }
      }
      if(x.entry!=='in'||x.pl!==0) pts.push([x.t,bal]);
    });
    var s=d.series||[], first=s.length?s[0][0]:Infinity;
    var line=pts.filter(function(p){return p[0]<first;}).concat(s.map(function(p){return [p[0],p[2]];}));
    if(!line.length&&d.last) line=[[d.last.t,d.last.equity]];
    var peak=-Infinity, dd=[], mdd=0;
    line.forEach(function(p){if(p[1]>peak)peak=p[1]; var v=peak>0?(p[1]/peak-1)*100:0; if(v<mdd)mdd=v; dd.push([p[0],v]);});
    var wins=0,gw=0,gl=0; trades.forEach(function(x){if(x.pl>0){wins++;gw+=x.pl;}else gl-=x.pl;});
    var L=d.last||{}, res=dep>0?((L.balance||bal)-dep):null;
    var k=[[T.bal,f(L.balance)+' '+cur],[T.eq,f(L.equity)+' '+cur],
      [T.ret,res==null?'–':(res>=0?'+':'')+f(res)+' '+cur+' ('+(res>=0?'+':'')+f(res/dep*100,1)+' %)',res==null?'':(res>=0?'gain':'loss')],
      [T.mdd,f(mdd,1)+' %','loss'],[T.tr,String(trades.length)],[T.wr,trades.length?f(wins/trades.length*100,0)+' %':'–'],
      [T.pf,gl>0?f(gw/gl,2):(gw>0?'∞':'–')],[T.open,String(L.open_positions||0)]];
    el('ld-kpi').innerHTML=k.map(function(x){return '<div class="ldk"><span>'+x[0]+'</span><b class="'+(x[2]||'')+'">'+x[1]+'</b></div>';}).join('');
    el('ld-upd').textContent=T.upd+' '+dt(d.updated||L.t)+' UTC · '+(d.account.label||'')+(d.account.company?' · '+d.account.company:'')+(d.account.demo?' · '+T.demo:'');
    chart('ld-eq',line,false,T.eqc,cur,dep>0?dep:null);
    chart('ld-dd',dd,true,T.ddc,'%');
    table(trades);
  }
  function chart(id,data,isDD,title,unit,ref){
    var box=el(id), W=box.clientWidth||900, H=isDD?160:300, P={l:64,r:14,t:14,b:26};
    if(data.length<2){box.innerHTML='';return;}
    var x0=data[0][0],x1=data[data.length-1][0]; if(x1===x0)x1=x0+1;
    var ys=data.map(function(p){return p[1];}), y0=Math.min.apply(null,ys), y1=Math.max.apply(null,ys);
    if(!isDD&&ref){y0=Math.min(y0,ref);y1=Math.max(y1,ref);}
    if(isDD){y1=0; if(y0>-0.5)y0=-0.5;} else {var pad=(y1-y0)*0.08||Math.abs(y1)*0.01||1; y0-=pad; y1+=pad;}
    function X(t){return P.l+(t-x0)/(x1-x0)*(W-P.l-P.r);} function Y(v){return P.t+(y1-v)/(y1-y0)*(H-P.t-P.b);}
    var d='';data.forEach(function(p,i){d+=(i?'L':'M')+X(p[0]).toFixed(1)+' '+Y(p[1]).toFixed(1);});
    var base=isDD?Y(0):H-P.b, area=d+'L'+X(x1).toFixed(1)+' '+base+'L'+X(x0).toFixed(1)+' '+base+'Z';
    var col=isDD?'var(--loss)':'var(--navy)', fill=isDD?'rgba(184,67,58,.14)':'rgba(224,161,38,.16)';
    var g='';for(var i=0;i<=4;i++){var v=y0+(y1-y0)*i/4,y=Y(v);g+='<line x1="'+P.l+'" x2="'+(W-P.r)+'" y1="'+y+'" y2="'+y+'" stroke="var(--line)"/><text x="'+(P.l-8)+'" y="'+(y+4)+'" text-anchor="end">'+f(v,isDD?1:0)+'</text>';}
    var nx=W<600?2:4;for(var j=0;j<=nx;j++){var t=x0+(x1-x0)*j/nx;g+='<text x="'+X(t)+'" y="'+(H-6)+'" text-anchor="'+(j===0?'start':j===nx?'end':'middle')+'">'+new Date(t*1000).toISOString().slice(0,10)+'</text>';}
    if(!isDD&&ref){var yr=Y(ref).toFixed(1);g+='<line x1="'+P.l+'" x2="'+(W-P.r)+'" y1="'+yr+'" y2="'+yr+'" stroke="var(--slate)" stroke-width="1.5" stroke-dasharray="6 5"/><text x="'+(W-P.r-4)+'" y="'+(yr-6)+'" text-anchor="end" style="fill:var(--slate)">'+T.dep0+' '+f(ref,0)+'</text>';}
    box.innerHTML='<svg viewBox="0 0 '+W+' '+H+'" width="100%" height="'+H+'" role="img" aria-label="'+title+' ('+unit+')">'+g+'<path d="'+area+'" fill="'+fill+'"/><path d="'+d+'" fill="none" stroke="'+col+'" stroke-width="2" stroke-linejoin="round"/></svg>';
  }
  var showAll=false;
  function table(tr){
    var all=tr.slice().reverse();
    var rows=(showAll?all:all.slice(0,25)).map(function(x){
      return '<tr><td>'+(x.tin?dt(x.tin):'–')+'</td><td>'+dt(x.t)+'</td><td>'+esc(x.symbol)+'</td><td>'+(x.long?T.long:T.short)+'</td><td class="n">'+f(x.volume)+'</td><td class="n '+(x.pl>=0?'gain':'loss')+'">'+(x.pl>=0?'+':'')+f(x.pl)+'</td></tr>';
    }).join('');
    el('ld-tbl').innerHTML='<table class="ldt"><thead><tr><th>'+T.tin+'</th><th>'+T.tout+'</th><th>'+T.sym+'</th><th>'+T.dir+'</th><th class="n">'+T.vol+'</th><th class="n">'+T.pl+'</th></tr></thead><tbody>'+rows+'</tbody></table>'+
      (all.length>25?'<button type="button" class="btn" id="ld-more">'+(showAll?T.less:T.more)+'</button>':'');
    var b=el('ld-more'); if(b) b.onclick=function(){showAll=!showAll;table(tr);};
  }
  var last=null;
  function load(){
    if(!view){el('ld-msg').textContent=T.nov;return;}
    fetch(api,{cache:'no-store'}).then(function(r){if(!r.ok) throw 0; return r.json();}).then(function(d){
      if(!d||d.empty){el('ld-msg').textContent=T.empty;el('ld-msg').hidden=false;return;}
      el('ld-msg').hidden=true; el('ld-body').hidden=false; last=d; build(d);
    }).catch(function(){el('ld-msg').textContent=T.err;el('ld-msg').hidden=false;});
  }
  load(); setInterval(load,300000);
  var rt; window.addEventListener('resize',function(){clearTimeout(rt);rt=setTimeout(function(){if(last)build(last);},200);});
})();

httpdocs/equity/.htaccess

<IfModule mod_headers.c>
Header set X-Robots-Tag "noindex, nofollow, noarchive"
</IfModule>
Options -Indexes
<FilesMatch "^\.">
Require all denied
</FilesMatch>

httpdocs/equity/_data/.htaccess

Require all denied
Deny from all

private/equity_config.example.php

<?php
// Algorex Equity Publisher, configuration (self-host edition 1.01)
// Copy to equity_config.php in this folder (outside httpdocs). equity/setup.php can create it for you.
return [
    'secret'   => '{{SECRET_HEX64}}',      // 32-128 hex characters, same value as "Secret key" in the EA / ATAS strategy
    'accounts' => ['{{ACCOUNT_ID}}'],      // allowed accounts: MT4/MT5 login number or ATAS account ID, e.g. ['12345678', 'DEMO1B112']
    'view_key' => '{{VIEW_KEY}}',          // random string; the page reads data only with ?v=VIEW_KEY
];

Frequent questions

HTTP 401 signature or time
The secret key in the Publisher differs from the server, or the computer clock is off by more than 300 seconds.

HTTP 403 account
The account number is missing in accounts in equity_config.php.

HTTP 503 not configured
The server finds no valid configuration. Run setup.php or create equity_config.php by hand.

Error 4014 or URL not allowed
Your domain is missing in Tools > Options > Expert Advisors > Allow WebRequest for listed URL.

Is my key visible?
MetaTrader writes all inputs, including the key, into its own log. Only you can see that log.

Support

Questions, bug reports and requests: write in the Comments tab of the product page or in the channel Algorex Support. We answer there.