Can't open include mqh file or Libraries

 

Hi,

 

i create mqh. file with Statistical formulas which I want to use in my EA or script. At first I try to tested them and I include my Statistical.mqh into my script. But without success. I have an error "can't open "C:\Program Files\MetaTrader 5 \MQL5\Scripts\Statistical.mqh" include file test.mq5"

 

test.mq5 is script, and  Statistical.mqh is my new header file. it is the same problem when I use Statistical library. I can see my .mqh file in windows Program files system and when I double click it open me in a MetaEditor. 

 

Also I tried this with Object.mqh  which is included in MetaEditor by installation and result is the same.

 

 

Please help.  

 

Thank you 


 

Hi

Your "Statistical.mqh" file is in the wrong directory map, you should put it in the "include" folder.

A "mqh" file should be put in the "include" folder and not in "scripts".

 
snelle_moda:

Hi

Your "Statistical.mqh" file is in the wrong directory map, you should put it in the "include" folder.

A "mqh" file should be put in the "include" folder and not in "scripts".

 

My Statistical.mqh is in include folder.  

 
Finnaly I success. i don't know why but program immidietly put itself in Script folder. i must put complete path to include file. Why do i need to do this? In this way libraries and include headers don't make sense. if i must put mqh file or library into folder where is my script. Path which i need put in #include function is big and doesn't make sense.
 
chevanton1988:
Finnaly I success. i don't know why but program immidietly put itself in Script folder. i must put complete path to include file. Why do i need to do this? In this way libraries and include headers don't make sense. if i must put mqh file or library into folder where is my script. Path which i need put in #include function is big and doesn't make sense.
#include <Statistical.mqh>

Please read the documentation.

Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
Documentation on MQL5: Language Basics / Preprocessor / Including Files (#include)
  • www.mql5.com
Language Basics / Preprocessor / Including Files (#include) - Reference on algorithmic/automated trading language for MetaTrader 5
 
angevoyageur:

Please read the documentation.

Thanks Angevoyageur,

If is your header file in the same folder like your program (script, EA or indicator) then include file must have quotation marks (#include "Statistical.mqh"). if is it in another folder (include or libraries) then it must be in angle brackets (#include <Statistical.mqh>).

 

can't open "C:\Users\oDEVL\AppData\Roaming\MetaQuotes\Terminal\CF48736A04CB4E277F336167170AB43B\MQL4\Include\Devlin_Trade.mqh" include file. 

I am having the same problem even though my mqh file is in the correct folder can anyone help.

#include <Include\Devlin_Trade.mqh>


 
oDEVLINo1o #: can't open "C:\Users\oDEVL\AppData\Roaming\MetaQuotes\Terminal\CF48736A04CB4E277F336167170AB43B\MQL4\Include\Devlin_Trade.mqh" include file. I am having the same problem even though my mqh file is in the correct folder can anyone help.#include <Include\Devlin_Trade.mqh>
#include <Devlin_Trade.mqh>
 
Is there anyway to include a file in a different folder than "Include"?
 
Satoshi Asakura #: Is there anyway to include a file in a different folder than "Include"?

Read #4
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
Satoshi Asakura #: Is there anyway to include a file in a different folder than "Include"?

Yes, use "" instead of <> and specify a relative path to the file. Use either "/" or "\\" for the directory separator.

#include "..\\myfolder\\myinclude.mqh"

#include "../myfolder/myinclude.mqh"