I think there is a problem when we call the iCustom function with a string parameter and when this parameter is an empty string ("").
In this case, Metatrader will not respond. I join 2 very simple programs to reproduce this problem. As these examples are very simple, Metatrader does not respond during 10 seconds, but in more complex indicator, it does not respond for much more.
To reproduce the bug, copy "A" an "B" programs in indicator section.
1) Display "A" (with default input parameters) in Metatrader. You will note that Metatrader is frozen during 10 seconds.
2) remove "A" from the chart and display it again but this time, fill the user parameter <e_input_data> (which is a string type) with something (what you want). In this case, Metatrader does not freeze.
The problem in 1) comes from the iCustom call that takes the <e_input_data> parameter which is an empty string (""). And I do not konw why, but iCustom does not like these empty strings...
Program "A.mq4" :
//+---------------------------------------------------------+
//| A.mq4
//|
//|
//| This program shows a bug in Metatrader 4 build 201:
//| we call the program "B" through a iCustom call with
//| an empty string parameter.
//|
//+---------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
//************************************************************
// Input parameters
//************************************************************
extern int e_period = 14;
extern int e_type_ma = MODE_SMA;
extern int e_type_data = PRICE_CLOSE;
extern string e_input_data = "";
//---- output buffer
double ExtOutputBuffer[];
int init()
{
IndicatorBuffers( 1 );
SetIndexBuffer( 0, ExtOutputBuffer );
SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 2 );
IndicatorShortName( "A" );
SetIndexLabel( 0, "A" );
return( 0 );
}
int deinit()
{
return(0);
}
int start()
{
int countedBars=IndicatorCounted();
//---- check for possible errors
if( countedBars < 0 )
{
return(-1);
}
_computeLastNbBars( Bars - countedBars - 1 );
return( 0 );
}
void _computeLastNbBars( int lastBars )
{
int pos;
for( pos = lastBars; pos >= 0; pos-- )
ExtOutputBuffer[pos] = iCustom( NULL, 0, "B", e_period, e_type_ma, e_type_data, e_input_data, 0, pos );
}
Program "B.mq4" :
//+---------------------------------------------------------+
//| B.mq4
//|
//|
//| This program shows a bug in Metatrader 4 build 201:
//| we call the program "B" through a iCustom call with
//| an empty string parameter.
//|
//|
//+---------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- output buffer
double ExtOutputBuffer[];
//************************************************************
// Input parameters
//************************************************************
extern int e_period = 14;
extern int e_type_ma = MODE_SMA;
extern int e_type_data = PRICE_CLOSE;
extern string e_input_data = "";
int init()
{
IndicatorBuffers( 1 );
SetIndexBuffer( 0, ExtOutputBuffer );
SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 2 );
IndicatorShortName( "B" );
SetIndexLabel( 0, "B" );
return( 0 );
}
int deinit()
{
return(0);
}
int start()
{
int countedBars=IndicatorCounted();
//---- check for possible errors
if( countedBars < 0 )
{
return(-1);
}
_computeLastNbBars( Bars - countedBars - 1 );
return( 0 );
}
void _computeLastNbBars( int lastBars )
{
int pos;
for( pos = lastBars; pos >= 0; pos-- )
ExtOutputBuffer[pos] = iMA( NULL, 0, e_period, 0, e_type_ma, e_type_data, pos);
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Metaeditor build 200
I think there is a problem when we call the iCustom function with a string parameter and when this parameter is an empty string ("").
In this case, Metatrader will not respond. I join 2 very simple programs to reproduce this problem. As these examples are very simple, Metatrader does not respond during 10 seconds, but in more complex indicator, it does not respond for much more.
To reproduce the bug, copy "A" an "B" programs in indicator section.
1) Display "A" (with default input parameters) in Metatrader. You will note that Metatrader is frozen during 10 seconds.
2) remove "A" from the chart and display it again but this time, fill the user parameter <e_input_data> (which is a string type) with something (what you want). In this case, Metatrader does not freeze.
The problem in 1) comes from the iCustom call that takes the <e_input_data> parameter which is an empty string (""). And I do not konw why, but iCustom does not like these empty strings...
Program "A.mq4" :
//+---------------------------------------------------------+ //| A.mq4 //| //| //| This program shows a bug in Metatrader 4 build 201: //| we call the program "B" through a iCustom call with //| an empty string parameter. //| //+---------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Blue //************************************************************ // Input parameters //************************************************************ extern int e_period = 14; extern int e_type_ma = MODE_SMA; extern int e_type_data = PRICE_CLOSE; extern string e_input_data = ""; //---- output buffer double ExtOutputBuffer[]; int init() { IndicatorBuffers( 1 ); SetIndexBuffer( 0, ExtOutputBuffer ); SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 2 ); IndicatorShortName( "A" ); SetIndexLabel( 0, "A" ); return( 0 ); } int deinit() { return(0); } int start() { int countedBars=IndicatorCounted(); //---- check for possible errors if( countedBars < 0 ) { return(-1); } _computeLastNbBars( Bars - countedBars - 1 ); return( 0 ); } void _computeLastNbBars( int lastBars ) { int pos; for( pos = lastBars; pos >= 0; pos-- ) ExtOutputBuffer[pos] = iCustom( NULL, 0, "B", e_period, e_type_ma, e_type_data, e_input_data, 0, pos ); }Program "B.mq4" :
//+---------------------------------------------------------+ //| B.mq4 //| //| //| This program shows a bug in Metatrader 4 build 201: //| we call the program "B" through a iCustom call with //| an empty string parameter. //| //| //+---------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 Red //---- output buffer double ExtOutputBuffer[]; //************************************************************ // Input parameters //************************************************************ extern int e_period = 14; extern int e_type_ma = MODE_SMA; extern int e_type_data = PRICE_CLOSE; extern string e_input_data = ""; int init() { IndicatorBuffers( 1 ); SetIndexBuffer( 0, ExtOutputBuffer ); SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 2 ); IndicatorShortName( "B" ); SetIndexLabel( 0, "B" ); return( 0 ); } int deinit() { return(0); } int start() { int countedBars=IndicatorCounted(); //---- check for possible errors if( countedBars < 0 ) { return(-1); } _computeLastNbBars( Bars - countedBars - 1 ); return( 0 ); } void _computeLastNbBars( int lastBars ) { int pos; for( pos = lastBars; pos >= 0; pos-- ) ExtOutputBuffer[pos] = iMA( NULL, 0, e_period, 0, e_type_ma, e_type_data, pos); }