Quote:
|
Originally Posted by TheExponential
I'm trying to create a library file (.ex4) file to be used by #import syntax in the main program.
I have a problem in compiling the called library program. when trying to compile it, it complains "Start function not found". What should I do?
Should I also put these library programs in a separate directory?
Thanks!
|
TheExponential,
I'm so sorry for the delay.
The error you have got because (I think) you didn't write this line on the top of your library program:
#property library
To create a library you have to:
1- Use #property library preprocessor directive
on the top of your program (see the example).
2- Compile and save it in "MetaTrader 4\experts\libraries" path.
Example:
PHP Code:
//+------------------------------------------------------------------+
//| Alerts.mq4 |
//| Coders Guru |
//| http://www.forex-tsd.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|Use this code at your risk, I don't guarantee anything. | |
//+------------------------------------------------------------------+
#property copyright "Coders Guru"
#property link "http://www.forex-tsd.com"
#property library
#include <WinUser32.mqh> //for MessageBoxA
#import "kernal32.dll"
//+------------------------------------------------------------------+
//|This function shows dialog box showing the data you passed |
//|Click "Retry if you want to see the messages next time, |
//|and click "Cancel" to disable the messages | |
//+------------------------------------------------------------------+
void Msg(string message)
{
//int MessageBoxA(int hWnd ,string lpText,string lpCaption,int uType);
static bool disable = false;
int result = 0;
if(!disable)
result = MessageBoxA(NULL,message,"Click cancel to disable Alerts!",MB_RETRYCANCEL|MB_ICONINFORMATION);
if(result==IDCANCEL)
disable=true;
}
//+------------------------------------------------------------------+
//|This function rerun trus when line1 cross line2 |
//|and false otherwise |
//|Ex: Print(Crossed (ExtMapBuffer1[0],ExtMapBuffer2[0])); |
//+------------------------------------------------------------------+
bool Crossed (double line1 , double line2 )
{
static string last_direction = "";
string current_dirction = "";
if(line1>line2)current_dirction = "up";
if(line1<=line2)current_dirction = "down";
if(current_dirction != last_direction)
{
//Alert("EMA Cross for "+Symbol()+" on the "+Period()+" minute chart.");
Msg("EMA Cross for "+Symbol()+" on the "+Period()+" minute chart.");
last_direction = current_dirction;
return (true);
}
else
{
return (false);
}
}
//+------------------------------------------------------------------+