Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Hi Guys
I'm Trying To Send HTTP-Post request with metatrader.
i tried to write a dll for this action but it doesn't..
when i call the request(); function in dll, the Script/Indicator Will stop working...
here is the source code
PHP Code:
// pasargad.cpp : Defines the initialization routines for the DLL.
//
//
// Note!
//
// If this DLL is dynamically linked against the MFC
// DLLs, any functions exported from this DLL which
// call into MFC must have the AFX_MANAGE_STATE macro
// added at the very beginning of the function.
//
// For example:
//
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// // normal function body here
// }
//
// It is very important that this macro appear in each
// function, prior to any calls into MFC. This means that
// it must appear as the first statement within the
// function, even before any object variable declarations
// as their constructors may generate calls into the MFC
// DLL.
//
// Please see MFC Technical Notes 33 and 58 for additional
// details.
//
BEGIN_MESSAGE_MAP(CPasargadApp, CWinApp)
//{{AFX_MSG_MAP(CPasargadApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPasargadApp construction
CPasargadApp::CPasargadApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPasargadApp object
CPasargadApp theApp;
using namespace std;
MT4_EXPFUNC int request (char* hostname, char* api, char* parameters, string& message)
{
WSADATA WsaData;
WSAStartup (0x0101, &WsaData);
//If you need to send a basic authorization
//string Auth = "username:password";
//Figureout a way to encode test into base64 !
//string AuthInfo = base64_encode(reinterpret_cast<const unsigned char*>(Auth.c_str()),Auth.length());
//string sPassReq = "Authorization: Basic " + AuthInfo;
//SEND_RQ(sPassReq.c_str());
one of my friends suggested me to use cURL Library ..
i try to but i couldn't i think i have to write a DLL using cURL to send request with a single function and just use that function in meta ...
any suggestion?
Here is what i use ( Visual Studio 2008 - C++ DLL )
PHP Code:
Code:
//---- You need to add these includes at the top of your code
//---- #include <wininet.h>
//---- #include <atlstr.h>
MT4_EXPFUNC int __stdcall Sample( int Whatever )
{
//---- Declare Return Value
CHAR buffer[2048] ;
CString m_strContents;
DWORD dwRead;
/* Connect to the internet */
HINTERNET hiNet = InternetOpen(
L"InetURL/1.0",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0
);
/* if connection fails throw error */
if( !hiNet ) { return( -1010 ); }
/* Connect to a site */
HINTERNET hConnection = InternetConnect(
hiNet,
L"www.yoursite.com",
INTERNET_DEFAULT_HTTP_PORT,
NULL,
NULL,
INTERNET_SERVICE_HTTP,
0,
0
);
/* if connetion to site failed */
if( !hConnection )
{
InternetCloseHandle(hiNet);
return( -1020 );
} // COULD NOT CONNECT TO WEBSITE
/* Get Data */
HINTERNET hData = HttpOpenRequest( hConnection, L"GET", L"/yourpage.php", NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION, 0 );
if ( !hData )
{
InternetCloseHandle(hConnection);
InternetCloseHandle(hiNet);
return( -1030 ); // PAGE NOT FOUND
}
Guys, there is much more simple way, you can write your request to file, then throw alert - and in metatrader properties - event tab - choose instead of wav file - your bat file, then construct bat file in the way that will read the requrest from txt file.
Simple and works allways - without any DLL's
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................ http://www.fxservice.eu/
........................................