Looking for some Help to create a DLL

 
I have been trying to get the following code into a DLL for use by an Advisor. I am stumped...even after looking through all the error 127 postings on this forum. I am using VS2008 C++ to create the DLL. Below is my C++ Code.

// Genetic Test.cpp : Defines the exported functions for the DLL application.

//

#include "stdafx.h"

#define MT4_EXPFUNC __declspec ( dllexport )

#define TRUNC(x)(((x)>=0) ? floor(x) : ceil(x))

#define C_FPREM (_finite(f[0]/f[1]) ? f[0]-(TRUNC(f[0]/f[1])*f[1]) : f[0]/f[1])

#define C_F2XM1 (((fabs(f[0])<=1) && (!_isnan(f[0]))) ? (pow(2,f[0])-1) : ((!_finite(f[0]) && !_isnan(f[0]) && (f[0]<0)) ? -1 : f[0]))

struct MqlStr

{

int len;

char *string;

};

static int CompareMqlStr( const void *left, const void *right);

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

MT4_EXPFUNC double _stdcall DiscCFunctionSubC0( double v[])

{

long double f[8];

long double tmp = 0;

int cflag = 0;

f[0]=f[1]=f[2]=f[3]=f[4]=f[5]=f[6]=f[7]=0;

L0: f[0]=fabs(f[0]);

L1: f[0]+=f[0];

L2: f[0]=-f[0];.................................

L179: f[0]=cos(f[0]);

L180: tmp=f[0]; f[0]=f[0]; f[0]=tmp;

L181: f[0]*=f[0];

L182:

return f[0];

}

MT4_EXPFUNC double _stdcall DisciCFunction( double v[] /*, double &Threshold, double &ActualOutput, long &NumberOfExamples,

double &Confidence, int &Class1Votes, int &Class0Votes*/ )

{

double Threshold;

double ActualOutput;

long NumberOfExamples;

double Confidence;

int Class1Votes;

int Class0Votes;

double f[1];

double fltTmp;

long lngConfidenceIndex=0;

double dblConfidenceValues[]=

{

0.7444444444444445,

0.8730158730158730,

0.0000000000000000

};

long lngSubsetSize[]= ..................................

NumberOfExamples=lngSubsetSize[lngConfidenceIndex];

ActualOutput=f[0];

if (f[0]>=Threshold)

{

return 1;

}

else

{

return 0;

}

}

I also have have a .def file with

LIBRARY Genetic Test.dll

EXPORTS DisciCFunction

DiscCFunctionSubC0

Any Ideas out there? If I supply the source C code can someone guide me?

Thanks,

T-

 
Troutguy wrote >>
I have been trying to get the following code into a DLL for use by an Advisor. I am stumped...even after looking through all the error 127 postings on this forum. I am using VS2008 C++ to create the DLL. Below is my C++ Code.

Can be lots of reasons. I assume you have a DLL main function something like this:

BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved)
  {
//----
   switch(ul_reason_for_call)
     {
      case DLL_PROCESS_ATTACH: break;
      case DLL_THREAD_ATTACH: break; 
      case DLL_THREAD_DETACH: break; 
      case DLL_PROCESS_DETACH: break;
     }
//----
   return(TRUE);
  }

Is your OS 64 bit? I get error 127 when I try to load a 32 bit DLL on an MT4 running on a 64 bit OS. Does the sample DLL that comes with MT4 work when you compile it yourself?

Paul

http://paulsfxrandomwalk.blogspot.com/

Reason: