прошу помощи

 

//---------------------------------------------------------------------------

#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif

#define MENUCODE -999

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
  return 1;
}
//---------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */




static double Thresholds[] =
{

/* layer 1 */
1.2145040659995765, 3.7150897132033802, 0.59454351593610577, 0.31822673978973876,

/* layer 2 */
1.0261447433298005

};

static double Weights[] =
{

/* layer 1 */
-1.1141264237664898, -1.5504305146313317, 0.73286159338154766, -1.2788684374991517,
-0.61641073399851731,
0.69072562217776923, -0.22241781292722679, 0.71682200719453848, 0.0017560026910527838,
2.1540691697208927,
-0.99116459059236506, -0.054704110029000053, -1.2382645587627006, -2.9685995454576384,
-1.1411725616914337,
-0.043297251827266285, -0.066167428785390461, -0.020875395803372929, -0.11405333458161644,
1.8579545370330088,

/* layer 2 */
-0.97811177652242753, 2.8971789204781668, -1.8332145813941754, 2.2454948857766635

};

static double Acts[20];

__declspec(dllexport) double __stdcall Run( double inputs[], double sd, int outputType )
{
  int i, j, k, u;
  double *w = Weights, *t = Thresholds;

  /* Process inputs - apply pre-processing to each input in turn,
  * storing results in the neuron activations array.
  */

  /* Input 0: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[0] == -9999 )
  Acts[0] = 0.35852063342998086;
  else
  Acts[0] = inputs[0] * 7.2056492289955321 + -6.0600951145698216;

  /* Input 1: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[1] == -9999 )
  Acts[1] = 0.35857336433909737;
  else
  Acts[1] = inputs[1] * 7.204610951008644 + -6.0590778097982696;

  /* Input 2: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[2] == -9999 )
  Acts[2] = 0.35851878147446925;
  else
  Acts[2] = inputs[2] * 7.204610951008644 + -6.0590778097982696;

  /* Input 3: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[3] == -9999 )
  Acts[3] = 0.35847796574053348;
  else
  Acts[3] = inputs[3] * 7.204610951008644 + -6.0590778097982696;

  /* Input 4: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[4] == -9999 )
  Acts[4] = 0.35964573508254105;
  else
  Acts[4] = inputs[4] * 7.231703789412788 + -6.0820075209719429;

  /*
  * Process layer 1.
  */

  /* For each unit in turn */
  for ( u=0; u < 4; ++u )
  {
  /*
  * First, calculate post-synaptic potentials, storing
  * these in the Acts array.
  */

  /* Initialise hidden unit activation to zero */
  Acts[5+u] = 0.0;

  /* Accumulate weighted sum from inputs */
  for ( i=0; i < 5; ++i )
  Acts[5+u] += *w++ * Acts[0+i];

  /* Subtract threshold */
  Acts[5+u] -= *t++;

  /* Now apply the hyperbolic activation function, ( e^x - e^-x ) / ( e^x + e^-x ).
  * Deal with overflow and underflow
  */
  if ( Acts[5+u] > 100.0 )
  Acts[5+u] = 1.0;
  else if ( Acts[5+u] < -100.0 )
  Acts[5+u] = -1.0;
  else
  {
  double e1 = exp( Acts[5+u] ), e2 = exp( -Acts[5+u] );
  Acts[5+u] = ( e1 - e2 ) / ( e1 + e2 );
  }
  }

  /*
  * Process layer 2.
  */

  /* For each unit in turn */
  for ( u=0; u < 1; ++u )
  {
  /*
  * First, calculate post-synaptic potentials, storing
  * these in the Acts array.
  */

  /* Initialise hidden unit activation to zero */
  Acts[9+u] = 0.0;

  /* Accumulate weighted sum from inputs */
  for ( i=0; i < 4; ++i )
  Acts[9+u] += *w++ * Acts[5+i];

  /* Subtract threshold */
  Acts[9+u] -= *t++;

  /* Now apply the logistic activation function, 1 / ( 1 + e^-x ).
  * Deal with overflow and underflow
  */
  if ( Acts[9+u] > 100.0 )
  Acts[9+u] = 1.0;
  else if ( Acts[9+u] < -100.0 )
  Acts[9+u] = 0.0;
  else
  Acts[9+u] = 1.0 / ( 1.0 + exp( - Acts[9+u] ) );
  }

  /* Type of output required - selected by outputType parameter */
  /* Post-process output 0, numeric linear scaling */
  sd = ( Acts[9] - -5.4031700288184421 ) / 6.4841498559077788;

  return (sd);
  }


это код dll компилится без ошибок в борлагд 6



//+------------------------------------------------------------------+
//| nero.mq4 |
//| Evgenio |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Evgenio"
#property link "http://www.metaquotes.net"
#import "2.dll"
double Run( double inputs[], double sd, int outputType );
#import
double sd;
int outputType;
double inputs[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
  {
//----
 double inputs[4]={0.5235,0.3254,0.21422,0.32123,0.32156};  
//----
  return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
  return(0);
  }
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
  {
//----
  
  
  double d=Run( inputs, sd, outputType );
  Print (d);
  
//----
  return(0);
  }
//+------------------------------------------------------------------+


код советника который его вызывает 



2009.08.07 20:38:48 2009.08.06 00:00 nero EURGBP,M15: cannot call function 'Run' from dll '2.dll' (error 127)


лог тестера ??

почему?

все компилится без ошибок, в терминале везде включена загрузка dll 

хелп ********


 
evgenio писал(а) >>



//+------------------------------------------------------------------+
//| nero.mq4 |
//| Evgenio |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Evgenio"
#property link "http://www.metaquotes.net"
#import "2.dll"
double Run( double inputs[], double sd, int outputType );
#import
double sd;
int outputType;
double inputs[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
double inputs[4]={0.5235,0.3254,0.21422,0.32123,0.32156};
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----


double d=Run( inputs, sd, outputType );
Print (d);

//----
return(0);
}
//+------------------------------------------------------------------+

код советника который его вызывает



2009.08.07 20:38:48 2009.08.06 00:00 nero EURGBP,M15: cannot call function 'Run' from dll '2.dll' (error 127)

лог тестера ??

почему?

все компилится без ошибок, в терминале везде включена загрузка dll

хелп ********

мож проблема, потому что глобальный массив не имеет размера и данные не определены!?

 
а какой массив, все вроде определены ??
 
evgenio писал(а) >>
а какой массив, все вроде определены ??

глобальный не определён, который учавствует в старте!

double inputs[];

у тя в инете локалный определён, но для старта он не виден и ваще зачем одинаковые имена давать для глобала и локала !

double inputs[4]={0.5235,0.3254,0.21422,0.32123,0.32156};

определи глобальный, как определял локальный и мож тогда бут те сщастье!? а локальный ваще выкинь он те погоду не делает!

но мож я чёт и не допонял!

 

1. Невозможность вызова функции из dll объясняется декорированием имен ф-й С++ компилятором.

Решения:

- либо использовать def файл в dll проекте (предпочтительно, т.к. дает независимость от специфики конкретного компилятора);

- либо использовать конструкцию extern "C" { ... } для прототипов экспорт. ф-й в С++ коде.


2. Грубая ошибка в mq4 коде. Объявлен глобальный массив double inputs[] без указания размерности, массив double inputs[4] = ... в init() является локальным!

(О! На вторую ошибку уже указано.)

 
OneDepo >>:

1. Невозможность вызова функции из dll объясняется декорированием имен ф-й С++ компилятором.

Решения:

- либо использовать def файл в dll проекте (предпочтительно, т.к. дает независимость от специфики конкретного компилятора);

- либо использовать конструкцию extern "C" { ... } для прототипов экспорт. ф-й в С++ коде.


2. Грубая ошибка в mq4 коде. Объявлен глобальный массив double inputs[] без указания размерности, массив double inputs[4] = ... в init() является локальным!

(О! На вторую ошибку уже указано.)

Насколько я знаю, def файлы используются в visyal C++. Т.е. вы рекомендуете использовать visyal C++ ???

 

что же такое то ????????????????

сделал все как написано в Архангельском 

создал DLL

//---------------------------------------------------------------------------

#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "UMyDLL.h"

#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif

#define MENUCODE -999

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
  return 1;
}

static double Thresholds[] =
{

/* layer 1 */
1.2145040659995765, 3.7150897132033802, 0.59454351593610577, 0.31822673978973876,

/* layer 2 */
1.0261447433298005

};

static double Weights[] =
{

/* layer 1 */
-1.1141264237664898, -1.5504305146313317, 0.73286159338154766, -1.2788684374991517,
-0.61641073399851731,
0.69072562217776923, -0.22241781292722679, 0.71682200719453848, 0.0017560026910527838,
2.1540691697208927,
-0.99116459059236506, -0.054704110029000053, -1.2382645587627006, -2.9685995454576384,
-1.1411725616914337,
-0.043297251827266285, -0.066167428785390461, -0.020875395803372929, -0.11405333458161644,
1.8579545370330088,

/* layer 2 */
-0.97811177652242753, 2.8971789204781668, -1.8332145813941754, 2.2454948857766635

};

static double Acts[20];

Run( double inputs[] )
{
  int i, j, k, u;
  double *w = Weights, *t = Thresholds;

  /* Process inputs - apply pre-processing to each input in turn,
  * storing results in the neuron activations array.
  */

  /* Input 0: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[0] == -9999 )
  Acts[0] = 0.35852063342998086;
  else
  Acts[0] = inputs[0] * 7.2056492289955321 + -6.0600951145698216;

  /* Input 1: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[1] == -9999 )
  Acts[1] = 0.35857336433909737;
  else
  Acts[1] = inputs[1] * 7.204610951008644 + -6.0590778097982696;

  /* Input 2: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[2] == -9999 )
  Acts[2] = 0.35851878147446925;
  else
  Acts[2] = inputs[2] * 7.204610951008644 + -6.0590778097982696;

  /* Input 3: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[3] == -9999 )
  Acts[3] = 0.35847796574053348;
  else
  Acts[3] = inputs[3] * 7.204610951008644 + -6.0590778097982696;

  /* Input 4: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[4] == -9999 )
  Acts[4] = 0.35964573508254105;
  else
  Acts[4] = inputs[4] * 7.231703789412788 + -6.0820075209719429;

  /*
  * Process layer 1.
  */

  /* For each unit in turn */
  for ( u=0; u < 4; ++u )
  {
  /*
  * First, calculate post-synaptic potentials, storing
  * these in the Acts array.
  */

  /* Initialise hidden unit activation to zero */
  Acts[5+u] = 0.0;

  /* Accumulate weighted sum from inputs */
  for ( i=0; i < 5; ++i )
  Acts[5+u] += *w++ * Acts[0+i];

  /* Subtract threshold */
  Acts[5+u] -= *t++;

  /* Now apply the hyperbolic activation function, ( e^x - e^-x ) / ( e^x + e^-x ).
  * Deal with overflow and underflow
  */
  if ( Acts[5+u] > 100.0 )
  Acts[5+u] = 1.0;
  else if ( Acts[5+u] < -100.0 )
  Acts[5+u] = -1.0;
  else
  {
  double e1 = exp( Acts[5+u] ), e2 = exp( -Acts[5+u] );
  Acts[5+u] = ( e1 - e2 ) / ( e1 + e2 );
  }
  }

  /*
  * Process layer 2.
  */

  /* For each unit in turn */
  for ( u=0; u < 1; ++u )
  {
  /*
  * First, calculate post-synaptic potentials, storing
  * these in the Acts array.
  */

  /* Initialise hidden unit activation to zero */
  Acts[9+u] = 0.0;

  /* Accumulate weighted sum from inputs */
  for ( i=0; i < 4; ++i )
  Acts[9+u] += *w++ * Acts[5+i];

  /* Subtract threshold */
  Acts[9+u] -= *t++;

  /* Now apply the logistic activation function, 1 / ( 1 + e^-x ).
  * Deal with overflow and underflow
  */
  if ( Acts[9+u] > 100.0 )
  Acts[9+u] = 1.0;
  else if ( Acts[9+u] < -100.0 )
  Acts[9+u] = 0.0;
  else
  Acts[9+u] = 1.0 / ( 1.0 + exp( - Acts[9+u] ) );
  }

  /* Type of output required - selected by outputType parameter */
  /* Post-process output 0, numeric linear scaling */
  double sd = ( Acts[9] - -5.4031700288184421 ) / 6.4841498559077788;

  return (sd);
 }

при компиляции нет ошибок

создал заголовочный файл 

#ifndef _UMYDLL_H
#define _UMYDLL_H

#ifdef __DLL__
# define DLL_EI __declspec (dllexport)
#else
# define DLL_EI __declspec (dllimport)
#endif

extern "C" double DLL_EI Run( double inputs[], double sd, int outputType );

#endif

нет ошибок

а тестер опять пишет 

2009.08.08 09:50:38 2009.08.07 00:00 nero EURGBP,M15: cannot call function 'Run' from dll 'MyDLL.dll' (error 127)


сто делать ???

 

ну у кого-нибудь есть идеи ????

 

люди спецы ну ПОЖАЛУЙСТА помогите

сделайте кому не жалко работоспособную DLL из этого кода

//---------------------------------------------------------------------------

#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>


#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif

#define MENUCODE -999

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
  return 1;
}
//---------------------------------------------------------------------------
/* ------------------------------------------------------------------------- */




static double Thresholds[] =
{

/* layer 1 */
1.2145040659995765, 3.7150897132033802, 0.59454351593610577, 0.31822673978973876,

/* layer 2 */
1.0261447433298005

};

static double Weights[] =
{

/* layer 1 */
-1.1141264237664898, -1.5504305146313317, 0.73286159338154766, -1.2788684374991517,
-0.61641073399851731,
0.69072562217776923, -0.22241781292722679, 0.71682200719453848, 0.0017560026910527838,
2.1540691697208927,
-0.99116459059236506, -0.054704110029000053, -1.2382645587627006, -2.9685995454576384,
-1.1411725616914337,
-0.043297251827266285, -0.066167428785390461, -0.020875395803372929, -0.11405333458161644,
1.8579545370330088,

/* layer 2 */
-0.97811177652242753, 2.8971789204781668, -1.8332145813941754, 2.2454948857766635

};

static double Acts[20];

Run( double inputs[] )
{
  int i, j, k, u;
  double *w = Weights, *t = Thresholds;

  /* Process inputs - apply pre-processing to each input in turn,
  * storing results in the neuron activations array.
  */

  /* Input 0: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[0] == -9999 )
  Acts[0] = 0.35852063342998086;
  else
  Acts[0] = inputs[0] * 7.2056492289955321 + -6.0600951145698216;

  /* Input 1: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[1] == -9999 )
  Acts[1] = 0.35857336433909737;
  else
  Acts[1] = inputs[1] * 7.204610951008644 + -6.0590778097982696;

  /* Input 2: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[2] == -9999 )
  Acts[2] = 0.35851878147446925;
  else
  Acts[2] = inputs[2] * 7.204610951008644 + -6.0590778097982696;

  /* Input 3: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[3] == -9999 )
  Acts[3] = 0.35847796574053348;
  else
  Acts[3] = inputs[3] * 7.204610951008644 + -6.0590778097982696;

  /* Input 4: standard numeric pre-processing: linear shift and scale. */
  if ( inputs[4] == -9999 )
  Acts[4] = 0.35964573508254105;
  else
  Acts[4] = inputs[4] * 7.231703789412788 + -6.0820075209719429;

  /*
  * Process layer 1.
  */

  /* For each unit in turn */
  for ( u=0; u < 4; ++u )
  {
  /*
  * First, calculate post-synaptic potentials, storing
  * these in the Acts array.
  */

  /* Initialise hidden unit activation to zero */
  Acts[5+u] = 0.0;

  /* Accumulate weighted sum from inputs */
  for ( i=0; i < 5; ++i )
  Acts[5+u] += *w++ * Acts[0+i];

  /* Subtract threshold */
  Acts[5+u] -= *t++;

  /* Now apply the hyperbolic activation function, ( e^x - e^-x ) / ( e^x + e^-x ).
  * Deal with overflow and underflow
  */
  if ( Acts[5+u] > 100.0 )
  Acts[5+u] = 1.0;
  else if ( Acts[5+u] < -100.0 )
  Acts[5+u] = -1.0;
  else
  {
  double e1 = exp( Acts[5+u] ), e2 = exp( -Acts[5+u] );
  Acts[5+u] = ( e1 - e2 ) / ( e1 + e2 );
  }
  }

  /*
  * Process layer 2.
  */

  /* For each unit in turn */
  for ( u=0; u < 1; ++u )
  {
  /*
  * First, calculate post-synaptic potentials, storing
  * these in the Acts array.
  */

  /* Initialise hidden unit activation to zero */
  Acts[9+u] = 0.0;

  /* Accumulate weighted sum from inputs */
  for ( i=0; i < 4; ++i )
  Acts[9+u] += *w++ * Acts[5+i];

  /* Subtract threshold */
  Acts[9+u] -= *t++;

  /* Now apply the logistic activation function, 1 / ( 1 + e^-x ).
  * Deal with overflow and underflow
  */
  if ( Acts[9+u] > 100.0 )
  Acts[9+u] = 1.0;
  else if ( Acts[9+u] < -100.0 )
  Acts[9+u] = 0.0;
  else
  Acts[9+u] = 1.0 / ( 1.0 + exp( - Acts[9+u] ) );
  }

  /* Type of output required - selected by outputType parameter */
  /* Post-process output 0, numeric linear scaling */
  double sd = ( Acts[9] - -5.4031700288184421 ) / 6.4841498559077788;

  return (sd);
  }

и вот такой простой эксперт

//+------------------------------------------------------------------+
//| nero.mq4 |
//| Evgenio |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Evgenio"
#property link "http://www.metaquotes.net"
#import "MyDLL.dll"
double Run( double inputs[] );
#import
double sd;
int outputType;
double inputs[4]={0.5235,0.3254,0.21422,0.32123,0.32156};
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
  return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
  return(0);
  }
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
  {
//----
  
  double d=Run( inputs );
  Print (d);
  
//----
  return(0);
  }
//+------------------------------------------------------------------+


уже всю голову сломал не знаю что делать ????

ХЕЛП ????????

 

double inputs[4]={

if ( inputs[4] == -9999 )

у тя кажись максимум можно inputs[3]

 

double inputs[4]={0.5235,0.3254,0.21422,0.32123,0.32156};


Замени на

double inputs[5]={0.5235,0.3254,0.21422,0.32123,0.32156};


Это как вариант