-1
基本上我希望我的本地MetaTrader 5終端在每次歐元/美元對的BID費率變化時都執行POST請求。如何使MetaTrader 5終端腳本在端口443上向我的nodejs服務器發送EURUSD BID費率?
而且我要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);
腳本元操盤手裏面打印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);
}
//+------------------------------------------------------------------+
你有沒有至少**嘗試過我以前的建議+源代碼來記錄/顯示在python控制檯中的http-POST-wrapped事務的內容? >>> http://stackoverflow.com/a/39966404/3666197重新運行它+後輸出,記錄什麼,好嗎?** – user3666197