2017-02-12 9 views
-1

기본적으로 EUR/USD 쌍의 BID 비율이 변경 될 때마다 로컬 MetaTrader 5 Terminal에서 POST 요청을하도록합니다.포트 443의 nodejs 서버에 EURUSD BID 요율을 POST하는 MetaTrader 5 Terminal 스크립트를 만드는 방법은 무엇입니까?

그리고 내 nodejs 서버에 console.log 거기에 갈거야 :

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

또한 메타 트레이더 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); 

} 


//+------------------------------------------------------------------+ 
+0

적어도 ** 파이썬 콘솔에서 http-POST가 래핑 된 트랜잭션의 내용을 기록/표시하기 위해 이전 조언 + 소스 코드를 사용해 보셨습니까? >>> http://stackoverflow.com/a/39966404/3666197 다시 실행하십시오. 출력물을 게시하십시오. 기록 된 내용은 무엇입니까? ** – user3666197

답변

2

왜 모든 것이 잘되어야한다고 생각합니까?
프로그래머로서, 당신은 오류를 잡을 준비가 ...이 시도 :

int res = WebRequest("POST", ...); 
if (res != 200){ 
    Print("failed to send. result=" 
      + (string) res 
      + ", LastError=" 
      + (string) GetLastError() 
      ); 
    return(False);       //+redefine void F(){} into a bool 
} 

그런 다음 우리가 잘못 무슨 일이 일어나고 있는지 보자.

향후 일부 오류가 발생했음을 알기 위해 다른 유형의 알림 (예 : 이메일)을 사용하여 해당 블록을 확장 할 수 있습니다.

지금은 WebRequest() 함수를 확인하십시오. 시간 제한 매개 변수는 NULL입니다.

POST- 방법에는 WebRequest#2이 필요합니다.