Download MetaTrader 5

[Solved] Unable to import functions from .ex4

To add comments, please log in or register
enjoysmath
64
enjoysmath  

Here's the importing hello world indicator:

//+------------------------------------------------------------------+
//|                                          MyLangTestingGround.mq4 |
//|                                                  Daniel Donnelly |
//|                                             enjoysmath@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Daniel Donnelly"
#property link      "enjoysmath@gmail.com"
#property version   "1.00"
#property strict

#import "MiUtilities.ex4"
   string MiTimeToStr(datetime dateTime);
#import

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots   4

//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrLightCoral
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Label2
#property indicator_label2  "Label2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrMediumPurple
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot Label3
#property indicator_label3  "Label3"
#property indicator_type3   DRAW_LINE
#property indicator_color3  clrDodgerBlue
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
//--- plot Label4
#property indicator_label4  "Label4"
#property indicator_type4   DRAW_LINE
#property indicator_color4  clrGold
#property indicator_style4  STYLE_SOLID
#property indicator_width4  1
//--- indicator buffers
double         Label1Buffer[];
double         Label2Buffer[];
double         Label3Buffer[];
double         Label4Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+


int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer);
   SetIndexBuffer(1,Label2Buffer);
   SetIndexBuffer(2,Label3Buffer);
   SetIndexBuffer(3,Label4Buffer);
   
   string dateTimeStr = MiTimeToStr(TimeCurrent());
   Comment(dateTimeStr);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+

 

And here's my library in /Libraries/MiUtilities.mq4:

//+------------------------------------------------------------------+
//|                                                       MiUtil.mq4 |
//|                          (Copyright 2015) Mechanikos Investments |
//|                                          Author: Daniel Donnelly |
//|                                             enjoysmath@gmail.com |
//+------------------------------------------------------------------+
#property library
#property copyright "Daniel Donnelly"
#property link      "enjoysmath@gmail.com"
#property version   "1.00"
#property strict

//+------------------- Time To String Conversion --------------------+                       
//| Converts datetime to string in full form: YYYY.MM.DD HH:MM:SS    |
//+------------------------------------------------------------------+
string MiTimeToStr(datetime dateTime) {
   return TimeToString(dateTime, TIME_DATE | TIME_MINUTES | TIME_SECONDS);
}

 

When running the importing indicator, it just crashes, no comment is printed. 

Ex Ovo Omnia
3356
Ex Ovo Omnia  

When compiling libraries in the strict mode, the export modifier should be added for each exported function, otherwise the function will not be accessible from outside.

 https://docs.mql4.com/basis/function/export 

enjoysmath
64
enjoysmath  
@Ovo, thank you friend!!!!!
To add comments, please log in or register