Mt4 to

edited September 2016

Good morning
I made a code in javascript that open position when i visit the page from browser.

< htm l>
< hea d >
< sc ri p t typ e="t ext/ja vascript">
var output;

  function parseGetVars()
   var args = new Array();
  var query =;
  if (query)
      var strList = query.split('&');
       for(str in strList)
          var parts = strList[str].split('=');
         args[unescape(parts[0])] = unescape(parts[1]);
  return args;

    function Connect() {
        output = document.getElementById("debug");
        var token = " my token";
        if (token == '') {
            alert("You must add an API Token");

        ws = new WebSocket('wss://');
        ws.onopen = function(evt) {
        ws.onmessage = function(evt) {

    onOpen = function(evt) {
        var token = "my token";
            authorize: token


    onMessage = function(msg) {
        var js = JSON.parse(;

        if (js.error) { //Just for check for error
            writeToScreen("Error: " + js.error.message);

        if (js.msg_type == 'authorize') {
            var get = parseGetVars();
            writeToScreen("Authorized OK:" + "  Email: " + + "  Account: " + js.authorize.loginid + "Amount" + get['amount']);
            "buy": "1",
  "price": "30",
  "parameters": {
       "basis": "payout",
       "contract_type": "CALL",
        "duration_unit": "s",
       "proposal": 1,
        "symbol": "frxEURUSD"

        if (js.msg_type == 'balance') {
            writeToScreen("Balance: " + js.balance.balance);


    function GetBalance() {
        if (ws) {
                balance: 1

    function writeToScreen(message) {
        var pre = document.createElement("p"); = "break-word";
        pre.innerHTML = message;


<body OnLoad="Connect()">

API TOKEN:<input type="text" id="apitoken" name="apitoken"><br><br>
//<button type="button" onclick=Connect()>Connect</button>
<button type="button" onclick=GetBalance()>GetBalance</button>
<div id="debug"></div>

but when i try to get a webrequest from metatrader it don't work and metatrader confirm that the webrequest is good.
Someone can help me?


  • Hi duddas,
    did you solve the problem with the metatrader webrequest. I´m standing in front of the same problem. The URL works perfect when I´m psting it directly in the browsers adress field. But when I send the same URL with web request from MT4 nothing happened.

  • Hi Guys,
    for those of you wishing to work with MT4 and i am happy to inform you that I have a few solutions for:

    listening for trades happeining in MT4 and forwarding to
    listening for alerts in MT4 and automatically place the trade in
    Listen for trades and replicate them in MT4.
    I am also thinking to do a product to listen for trades happening in one MT4 instance and replicate them in another MT4 instance in the same or another PC. Is anybody interested?

    Email me at:

    Thank you,


Sign In or Register to comment.