Basically I want my local MetaTrader 5 Terminal to do POST-requests everytime an EUR/USD pair's BID-rate changes.
And I'm going to console.log
it in my nodejs server:
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const path = require('path');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
let env = process.env.NODE_ENV || 'development';
const port = 443;
const connection = 'mongodb://localhost:27017/db';
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, 'public')));
mongoose.connect(connection)
.then((db) => {
console.log('MongoDB up and running!');
app.post('/fxrates', (req, res) => {
console.log(req);
});
// MY ROUTES for the client
})
.catch(console.log);
http.listen(port, () => {
console.log(`listening on ${port}`);
});
Here is my MQ5 script which is compiled without errors. But when I run it, I don't see anything logged in my nodejs server terminal.
And I see Print("Test:",b);
script printing inside Meta Trader Experts Tab
I have also added in MetaTrader 5 Terminal -> Tools -> Options -> Expert Advisors
http://localhost:443/fxrates
and
http://localhost/fxrates
http://localhost
MQ5 script
//+------------------------------------------------------------------+
//| fxrates.mq5 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//- string headers;
string headers;
char data[], result[];
string str = "data=value"; // post data variables to send
StringToCharArray(str,data);
string b = CharArrayToString(data);
Print("Test:",b); // just test if good ... it is.
WebRequest("POST","http://localhost:443/fxrates",NULL,NULL,3000,data,ArraySize(data),result,headers);
}
//+------------------------------------------------------------------+