Download MetaTrader 5

indicator only compiles if there are comment characters at a certain position

To add comments, please log in or register
tarandus
32
tarandus  

Hi,

I am trying to create my first indicator. I copied an indicator from the MQL4 book (see below). This indicator compiles without any errors. However, when I remove the string "//" from this file, I get this error:

(1,1)  : error 356: event handling function not found

How is it possible for an mql4 file to not compile if comment characters are deleted?

Might this be an encoding problem?

#property indicator_chart_window                                                                                                                   
#property indicator_buffers 2                                                                                                                      
#property indicator_color1 Blue                                                                                                                    
#property indicator_color2 Red //                                                                                                                  
                                                                                                                                                   
double Buf_0[];                                                                                                                                    
double Buf_1[];                                                                                                                                    
                                                                                                                                                   
                                                                                                                                                   
int init() {                                                                                                                                       
                                                                                                                                                   
  SetIndexBuffer(0, Buf_0);                                                                                                                        
  SetIndexStyle(0, DRAW_LINE,STYLE_SOLID, 2);                                                                                                       
  SetIndexBuffer(1, Buf_1);                                                                                                                        
  SetIndexStyle(1, DRAW_LINE,STYLE_DOT, 1);                                                                                                         
  return(0);                                                                                                                                       
}                                                                                                                                                  
                                                                                                                                                   
                                                                                                                                                   
int start() {                                                                                                                                      
                                                                                                                                                   
  int i;                                                                                                                                           
  int Counted_bars;                                                                                                                                
                                                                                                                                                   
  Counted_bars=IndicatorCounted();                                                                                                                 
  i=Bars-Counted_bars-1;                                                                                                                           
                                                                                                                                                   
  while (i >= 0) {                                                                                                                                 
      Buf_0[i] = High[i];                                                                                                                            
      Buf_1[i] = Low[i];                                                                                                                             
      i--;                                                                                                                                         
  }                                                                                                                                                
  return(0);                                                                                                                                       
}                                                                                                                                                  
 
Alain Verleyen
Moderator
32008
Alain Verleyen  
tarandus:

Hi,

I am trying to create my first indicator. I copied an indicator from the MQL4 book (see below). This indicator compiles without any errors. However, when I remove the string "//" from this file, I get this error:

(1,1)  : error 356: event handling function not found

How is it possible for an mql4 file to not compile if comment characters are deleted?

Might this be an encoding problem?

Can you attach the mq4 file, not a copy and paste.
tarandus
32
tarandus  
O.k. It is attached to this post.
Files:
Alain Verleyen
Moderator
32008
Alain Verleyen  
tarandus:
O.k. It is attached to this post.
I can't reproduce your problem.
Keith Watford
Moderator
10372
Keith Watford  

You are talking about if you remove this?

#property indicator_color2 Red //

 No problem with my editor (Build 1035)

tarandus
32
tarandus  
GumRai:

You are talking about if you remove this?

 No problem with my editor (Build 1035)

Yes, I am talking about removing this.

Maybe the problem is that I compile the file with mql.exe (build 916).

tarandus
32
tarandus  
tarandus:

Yes, I am talking about removing this.

Maybe the problem is that I compile the file with mql.exe (build 916).

Unfortunately using a graphical program such as Metaeditor is not an option for me. I do not create and compile mql4 programs manually.
Alain Verleyen
Moderator
32008
Alain Verleyen  
tarandus:
Unfortunately using a graphical program such as Metaeditor is not an option for me. I do not create and compile mql4 programs manually.

Maybe you can say this from the start, so we don't have to lost time.

Which editor and encoding are you using ?

tarandus
32
tarandus  
angevoyageur:

Maybe you can say this from the start, so we don't have to lost time.

Which editor and encoding are you using ?

Sorry for not being more specific. I was expecting that mql.exe would behave in the same way as Metaeditor.

In the program I am developing I do not use an editor. The program creates the indicator and ea files with encoding ascii.

I just found out the source of my problems: I created my sample programs with Emacs under cygwin. The encoding (ascii) wasn't the problem. The problem was the that Emacs does not add a \r at the and of lines, but only a \n. And, obviously, mql.exe does not understand \n as "end of line".

Thanks for you help.

By the way: Will mql.exe be available in the future? Without it or some alternative non-graphical program, it would be very difficult for me to continue my project.

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI  
Why not using MetaEditor?
tarandus
32
tarandus  
deysmacro:
Why not using MetaEditor?
Is there a way to call MetaEditor from a shell and have it compile an mql4 file?
12
To add comments, please log in or register