подготовка массива для передачи в DLL

 
Здравствуйте,

Я пытаюсь передать массив в dll используя известный пример опубликованный на

http://www.mistigrifx.com/tools/writing-basic-mt4-dll


Dll yспешно компилируется с VS++2008, вот код дллки:


#define WIN32_LEAN_AND_MEAN
#define MT4_EXPFUNC __declspec(dllexport)
//+-----------------------------------------------------------------------------------------------------------------------------+
//| MT4 DATA STRUCT |
//+-----------------------------------------------------------------------------------------------------------------------------+
#pragma pack(push,1)
struct RateInfo { unsigned int ctm; double open; double low; double high; double close; double vol; };
struct MqlStr { int len; char * string; };
#pragma pack(pop)
//+-----------------------------------------------------------------------------------------------------------------------------+
MT4_EXPFUNC double _stdcall GetCloseValue( RateInfo* Rates,int MaximumRecords, int Iteration )
{
return( Rates[MaximumRecords-Iteration-1].close );
}
MT4_EXPFUNC double _stdcall GetHighValue( RateInfo* Rates,int MaximumRecords, int Iteration )
{
return( Rates[MaximumRecords-Iteration-1].high );
}
MT4_EXPFUNC void _stdcall GetSMAArray( RateInfo* Rates, int MaximumRecords, int Period, double Result[] )
{
for( int i = 0; i < MaximumRecords; i++)
{
double Sum = 0.0;
for( int k = 0; k < Period ; k++ )
{
Sum += Rates[MaximumRecords-i-1-k].close;
}
Result[MaximumRecords-i-1] = Sum / Period ;
}
}


Первые 2 функции нормально работают, 1:1 с видео автора.

А вот при попытке использовать третью функцию падает терминал.



Exception : C0000005
Address : 77C36FA3
Access Type : read


вот include:

#property copyright "Copyright © 2008, Mistigri"
#property link "http://www.MistigriFX.com"
//+------------------------------------------------------------------+
#import "MistigriFX Sample.dll"
double GetCloseValue( double Rates[][6],int MaximumRecords, int z );
double GetHighValue( double Rates[][6],int MaximumRecords, int z );
void GetSMAArray( double Rates[][6],int MaximumRecords, int Periods, double& OutPut[]);
#import


вот сам индикатор:

#property copyright "Copyright © 2008, Mistigri"
#property link "http://www.MistigriFX.com"
#include <Mistigri Sample Library.mqh>
#property indicator_chart_window

//---- Buffer
double OutPut[];
extern int Periods = 10;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer( 0, OutPut );
SetIndexStyle( 0, DRAW_LINE, 0, 1, Red);
SetIndexLabel( 0, "Sample Debug" );
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

double Rates[][6];
int MaximumRecords = ArrayCopyRates( Rates, Symbol(), 0 );
for( int z = MaximumRecords; z >= 0; z-- ) { OutPut[z] = EMPTY; }
GetSMAArray( Rates, MaximumRecords, Periods, OutPut );
return(0);
}


Мое подозрение что массив OutPut[] неправильно инициализирован, помогите разобратся!
 
Опа, сам разрулил, терминал падал, т.к. количество баров в чарте было слишком большое в настройках терминала...

Сменил количество баров на 800 и все стало пахать!
Причина обращения: