基本上我希望我的本地 MetaTrader 5 终端在每次 EUR/USD 货币对的 BID 汇率变化时执行 POST 请求。
我将console.log
在我的 nodejs 服务器中访问它:
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}`);
});
这是我的 MQ5 脚本,编译时没有错误。但是当我运行它时,我的 nodejs 服务器终端中没有看到任何记录。
我Print("Test:",b);
在 Meta Trader 中看到脚本打印Experts Tab
我还在 MetaTrader 5 终端 -> 工具 -> 选项 -> 智能交易系统中添加了
http://localhost:443/fxrates
和
http://localhost/fxrates
http://localhost
MQ5 脚本
//+------------------------------------------------------------------+
//| 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);
}
//+------------------------------------------------------------------+