Advanced coding with DLL

 

I am trying to create a DLL library with Microsoft Visual Basic 6.

I have written DLL:s for other applications than MT4 with VB6. The problem is that you get forced into a structure that demands that you call the DLL in this fashion (in VB):

Dim someObj

Set someObj = CreateObject("someDLL.SomeCodeModule")

someObj.SomeFunction parm1 parm2.....

As far as I figure this kind of setup is not possible in Metatrader.

I have tried lots of variation to code the DLL inVB6 to allow the simpler calling method that can be used in MT4 but not succeeded.

Anyone done this?

Ingvar

 

What do you want your dll to accomplish?

 

The DLL will act as an intermediate between MT4 and an Excel spreadsheet both delivering data to the spreadsheet and collect data. I have no problem communicating with the spreadsheet. Its communicating with MT4 that is the problem. The structure of the EA:s I have built have all required the calling structure described and that is not suitable for MT4 it seems.

 
ingvar_e:
The DLL will act as an intermediate between MT4 and an Excel spreadsheet both delivering data to the spreadsheet and collect data. I have no problem communicating with the spreadsheet. Its communicating with MT4 that is the problem. The structure of the EA:s I have built have all required the calling structure described and that is not suitable for MT4 it seems.

You may be having a string problem. Are you having mt4 read a double value such as a price quote from Excel? If Excel is returning a string, you may need to convert this to a double in mt4. Not sure if that is your problem or not.

I only have experience reading and writing to .txt or .csv files. Often you have the need to convert a string value to a double or integer for mt4 to make sense of your values.

Some of these mq4 functions may be helpful:

StrToDouble( string value)

StrToInteger( string value)

StrToTime( string value)

Not sure if this is helpful to you or not.

 

Do you Have an Excel to Saxo Trader interface?

@ingvar_e; you said...

I have written DLL:s for other applications than MT4 with VB6....

Have you ever tried an excel interface for Saxo Trader dll's or know anyone who has attempted this? I would be interested in getting a feed similar to the excel command/formula in MT4 for saxo trader e.g. =(MT4|BID!GBPUSD) for the currency pairs they provide plus an interface to place trades on the trade board via excel.

If you know of a past thread etc, I would be very interested in any information you may have as I have all my trade analysis/alerts and back test macros for end of day info that I fat finger in and would like to go to intraday time frames.

And please excuse me for asking this is a MetaTrader thread. I have been searching for this for a while.....

 

I Withdraw My Above Request!

Sorry - for some reason I do not have edit rights to delete my above response. I hereby withdraw the above request on the grounds that it is in breach of the customer agreement.

I am now highly considering closing my account with Saxo....

 

Wolfe wrote:

>You may be having a string problem

No, It is a problem even to get in contact with the DLL since the DLL require you to instanciate the DLL (See sample code for calling the DLL from VB).

I have to rephrase one of my sentences.

The structure of the DLL:s I have built have all required the calling structure described and that is not suitable for MT4 it seems

Ingvar

 

Example code of .ccp:

// Your_dll.cpp : Defines the initialization routines for the DLL.

//

#include "stdafx.h"

#include "Your_dll.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

#define MT4_EXPFUNC __declspec(dllexport)

// CYour_dllApp

BEGIN_MESSAGE_MAP(CYour_dllApp, CWinApp)

//{{AFX_MSG_MAP(CYour_dllApp)

// 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()

/////////////////////////////////////////////////////////////////////////////

// CYour_dllApp construction

CYour_dllApp::CYour_dllApp()

{

// TODO: add construction code here,

// Place all significant initialization in InitInstance

}

/////////////////////////////////////////////////////////////////////////////

// The one and only CYour_dllApp object

CYour_dllApp theApp;

MT4_EXPFUNC void __stdcall Your_Function()

{

// Your Function code here

//

}

[/PHP]

Make sure you declare your export function in the .def file:

[PHP]; Your_dll.def : Declares the module parameters for the DLL.

LIBRARY "Your_dll"

DESCRIPTION 'Your_dll Windows Dynamic Link Library'

EXPORTS

; Explicit exports can go here

Your_Function

Make sure to copy your release dll project to C:\WINDOWS\system32. Mt4 can access your dll there.

 

Thanks Wolfe.

You have to forgive me ignorance. I do not really know what to do with code samples you provided. PHP? Not familiar with PHP at all. Looks more like C yo me.

Like the pupil said after having got a second explanation.

"I am still confused but at a substantial higher level"

 
ingvar_e:
Thanks Wolfe.

You have to forgive me ignorance. I do not really know what to do with code samples you provided. PHP? Not familiar with PHP at all. Looks more like C yo me.

Like the pupil said after having got a second explanation.

"I am still confused but at a substantial higher level"

Sorry, it's not Visual Basic. The examples are in visual C++ 6.0.

Mt4 dll's will work when coded in C++.

 

C++

I suspected that. I have downloaded MS Visual C++ 2008 Express Edition to get started.

Thanks Wolfe

Reason: