Mt4 to Binary.com
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 = window.location.search.substring(1); 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"); return; } ws = new WebSocket('wss://ws.binaryws.com/websockets/v3'); ws.onopen = function(evt) { onOpen(evt) }; ws.onmessage = function(evt) { onMessage(evt) }; } onOpen = function(evt) { var token = "my token"; ws.send(JSON.stringify({ authorize: token })); } onMessage = function(msg) { var js = JSON.parse(msg.data); if (js.error) { //Just for check for error writeToScreen("Error: " + js.error.message); return; } if (js.msg_type == 'authorize') { var get = parseGetVars(); writeToScreen("Authorized OK:" + " Email: " + js.authorize.email + " Account: " + js.authorize.loginid + "Amount" + get['amount']); ws.send(JSON.stringify({ "buy": "1", "price": "30", "parameters": { "amount":"30", "basis": "payout", "contract_type": "CALL", "currency":"USD", "duration":"60", "duration_unit": "s", "proposal": 1, "symbol": "frxEURUSD" } })); } if (js.msg_type == 'balance') { writeToScreen("Balance: " + js.balance.balance); } } function GetBalance() { if (ws) { ws.send(JSON.stringify({ balance: 1 })); } } function writeToScreen(message) { var pre = document.createElement("p"); pre.style.wordWrap = "break-word"; pre.innerHTML = message; output.appendChild(pre); } </script> </head> <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> </body> </html> `
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?
Comments
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 Binary.com i am happy to inform you that I have a few solutions for:
listening for trades happeining in MT4 and forwarding to Binary.com
listening for alerts in MT4 and automatically place the trade in Binary.com
Listen for Binary.com 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:
alessandro.bernocchi@libero.it
Thank you,
Alessandro.