Download MetaTrader 5

Unresolved import function call from My Library code

To add comments, please log in or register
Write articles, help other developers and make money
Aadarsh Podiya
226
Aadarsh Podiya 2015.10.28 10:40 

Dear

I wrote a simple Library code. I can't import function. it show "cannot find 'order' in 'test.ex4'



Import code:

#property copyright "capiltaFX.com"
#property link      "http://www.capiltaFX.com"
//#property strict


#import    "test.ex4"
   int order(string Sym, int type,double Lots,double price,double stoploss);
   int OpenOrder(string Sym, int type,double Lots,double price,double stoploss);
#import


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() 
  {


   st=true;
   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit() 
  {
   return (0);
  }


bool st = true;

int start()
  {
   
   
   if(st){
    //OpenOrder(_Symbol, OP_BUY,0.01,Ask, 0);
   int st =  order(_Symbol, OP_BUY,0.01,Ask, 0);
    
    st=true;
   }

   return (0);
 }



library code:

//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property library
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//#property strict




int order(string Sym, int type,double Lots,double price,double stoploss) export 
 {
    return(0);
 }


int OpenOrder(string Sym, int type,double Lots,double price,double stoploss) export 
 {
   int ticket=0; string mFormat="", ErrorMessage="";
   double sl=0, tp=0; int LastError=0;
   string MT; bool DobuleLimitsSL=false; bool DobuleLimitsTP=false;
   
   double takeprofit;
   int expire;
   color clr;
   string comment; 
              int MagicNumber; bool ECN;
   
   double    _points;
   datetime  G_datetime_152;
   
   //Alert(_Point);
   
   
   if(stoploss==0 && takeprofit==0) {DobuleLimitsSL=false; DobuleLimitsTP=false;}
   else
   {
      if(stoploss!=0)   DobuleLimitsSL = stoploss-MathFloor(stoploss)>0;
      if(takeprofit!=0) DobuleLimitsTP = takeprofit-MathFloor(takeprofit)>0;
   }  
   
   if(type==OP_BUY || type==OP_BUYSTOP || type==OP_BUYLIMIT){
     if(DobuleLimitsSL){if(stoploss>0) sl=NormalizeDouble(stoploss,Digits);}
     else{if(stoploss>0) sl=price-stoploss*_points;}
     if(DobuleLimitsTP){if(takeprofit>0) tp=NormalizeDouble(takeprofit,Digits);}
     else{if(takeprofit>0) tp=price+takeprofit*_points;}
      MT="BUY";
   }
   
   if(type==OP_SELL || type==OP_SELLSTOP || type==OP_SELLLIMIT){
     if(DobuleLimitsSL){if(stoploss>0)   sl=NormalizeDouble(stoploss,Digits);}
     else{if(stoploss>0)   sl=price+stoploss*_points;}
     if(DobuleLimitsTP){if(takeprofit>0) tp=NormalizeDouble(takeprofit,Digits);
     }else{if(takeprofit>0) tp=price-takeprofit*_points;}
      MT="SELL";
   }
   
   
   ResetLastError();
   uint time0=GetTickCount();
   if(ECN){
      ticket=OrderSend(Sym,type,Lots,NormalizeDouble(price,Digits),10,0,0,comment,MagicNumber,expire,clr);
      if(OrderSelect(ticket, SELECT_BY_TICKET) && (sl>0 || tp>0)){
                   bool st=OrderModify(OrderTicket(),OrderOpenPrice(),sl,tp,expire,clr);         
      }
   }else{
      ticket=OrderSend(Sym,type,Lots,NormalizeDouble(price,Digits),10,sl,tp,comment,MagicNumber,expire,clr);
   }

   if(ticket>0)
   {
      if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {
       G_datetime_152 = iTime(NULL, 0, 0);
       double slip= MathRound((OrderOpenPrice()-price)/_points);
       mFormat = "Opening "+MT+" Order :: OP: "+DoubleToStr(OrderOpenPrice(),Digits)+" | TCK: "+DoubleToStr(ticket,0)
                 +" | Speed: "+DoubleToStr((GetTickCount()-time0),0)+" ms | Slippage: "+ DoubleToStr(slip,1);
       Print(mFormat);
       //if(EmailAlert) SendMail(mFormat,"New "+MT+" Order Open"); 
       //if(PushAlert)  SendNotification(mFormat);  
      }  
   } 
   else
   {
      LastError = GetLastError();
      ErrorMessage = ErrorMessage(LastError);
      mFormat = MT+" Send Error Code: " + DoubleToStr(LastError,0) + " Message: " + ErrorMessage + " LT: " + DoubleToStr(Lots, 2) + " OP: " + DoubleToStr(price, Digits) + " SL: " +
                     DoubleToStr(sl, Digits) + " Bid: " + DoubleToStr(Bid, Digits) + " Ask: " + DoubleToStr(Ask, Digits);
      Print(mFormat);
      //if(EmailAlert) SendMail(mFormat,MT+" Send Error ");
      //if(PushAlert)  SendNotification(mFormat);
   }    

   return(ticket);
}
Trinh Dat
37203
Trinh Dat 2015.10.28 11:03  
you need compile "test.mq4" to make "test.ex4"
To add comments, please log in or register