how to call .ex4 file ? please.

 

I want to study call .ex4 file in library folder. but i failed, please help,thank you !

first I create a library file test1.mq4 as below

test1.ex4 in library folder

//+------------------------------------------------------------------+
//|                                                        test1.mq4 |
//|                       Copyright ?2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

void DrawRectangle(string name)
{
   datetime t1,t2; 
   double p1,p2;
   t1 = iTime(NULL,1440,1);
   p1 = iHigh(NULL,1440,1);
   t2 = iTime(NULL,1440,0);
   p2= iLow(NULL,1440,0);
   if(ObjectFind(name) !=0)
   {
   ObjectCreate(name,OBJ_RECTANGLE,0,t1,p1,t2,p2);
   ObjectSet(name,OBJPROP_COLOR,Yellow);
   }
   else 
   { ObjectMove(name,0,t1,p1);
     ObjectMove(name,1,t2,p2);   
   }

}
 

Secondly,I create a mqh file "includetest1.mqh" to import test1.ex4

includetest1.mqh saved in include folder

codes as below

//+------------------------------------------------------------------+
//|                                                 includetest1.mq4 |
//|                       Copyright ?2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#import "test1.ex4"
   void DrawRectangle(string name);
#import

 

Thirdly, I create an indictor to call the function void DrawRectangle(string name) defined in test1.ex4

//+------------------------------------------------------------------+
//|                                               studycalltest1.mq4 |
//|                       Copyright ?2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#include <includetest1.mqh>

int init()
  {
   return(0);
  }

int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   DrawRectangle("daily retangle");
//----
   return(0);
  }
//+------------------------------------------------------------------+

 

I tested the indicator,but it did not draw rectangle as i hope.

Please give some advice,thanks !

 

2011.06.25 16:56:12 Cannot open file 'D:\Program Files\MetaTrader - Alpari UK\experts\test1.ex4' on the EURUSD,M15
2011.06.25 16:56:12 studycalltest1 EURUSD,M15: cannot load external expert 'test1'

 
Don't install in program files... on Vista/Win7
 
WHRoeder:
Don't install in program files... on Vista/Win7

XP
 
sergery:
2011.06.25 16:56:12 Cannot open file 'D:\Program Files\MetaTrader - Alpari UK\experts\test1.ex4' on the EURUSD,M15
Does the file actually exist?
 
WHRoeder:
Does the file actually exist?

Thanks you,WHRoeder.

I found the error, the below code should be added in test1.mq4

#property library

Reason: