ExportFunctions

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
ExportFunctions

This script acts as a specialized bridge that allows the MetaTrader platform to communicate with external software libraries. Instead of performing calculations solely within its own environment, this tool enables the trading platform to "reach out" and use advanced processing power from outside sources.

Core Functionality

The primary purpose of this logic is External Integration. It establishes a pathway for the trading platform to exchange information with a Dynamic Link Library (DLL)—a file that contains complex instructions or heavy mathematical models that may be too advanced for the standard trading environment to handle alone.

Key Operations

The script performs several types of interactions with these external tools:

  • Data Conversion and Retrieval: It can send different types of information (such as whole numbers, decimals, or text) to an external program and receive processed results back. This ensures that the platform can "talk" to other software fluently.
  • Advanced Data Organization: The logic includes capabilities to automatically sort and process lists of text. For example, it can take a disorganized list of information and arrange it into a specific order required by an external system.
  • Machine Learning & Prediction Support: The script contains specific commands for "Training" and "Predicting." This suggests it is designed to interface with sophisticated Machine Learning models (specifically Support Vector Machines), where the platform sends current market data to an external model to receive a prediction or trend analysis.
  • Dynamic Array Management: It allows the platform to share complex grids of data—like historical price rates—with external programs, modify those values on the fly, and pull specific pieces of information (such as current closing prices) back into the trading view.

Summary for the User

Think of this script as a translator and courier. It doesn't perform all the "thinking" itself; instead, it gathers your trading data, translates it into a format an external high-powered computer can understand, sends it off to be analyzed by advanced algorithms, and then brings the final results back to your screen.

2 Views
0 Downloads
0 Favorites
ExportFunctions
//+------------------------------------------------------------------+
//|                                              ExportFunctions.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"
//#include <sampledll.mqh>
#import "ExpertSample.dll"
int    GetIntValue(int);
double GetDoubleValue(double);
string GetStringValue(string);
double GetArrayItemValue(double arr[],int,int);
bool   SetArrayItemValue(double& arr[],int,int,double);
double GetRatesItemValue(double rates[][6],int,int,int);
int    SortStringArray(string& arr[],int);
int    ProcessStringArray(string& arr[],int);
int    SVM_Train(string, string);
int    SVM_Predict(int,string, string, string);

#define TIME_INDEX   0
#define OPEN_INDEX   1
#define LOW_INDEX    2
#define HIGH_INDEX   3
#define CLOSE_INDEX  4
#define VOLUME_INDEX 5
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   double ret,some_value=10.5;
   string sret;
   int    cnt;
   string strarray[6]={ "first", "second", "third", "fourth", "fifth" };
//---- simple dll-functions call
   cnt=GetIntValue(some_value);
   Print("Returned value is ",cnt);
   ret=GetDoubleValue(some_value);
   Print("Returned value is ",ret);
   sret=GetStringValue("some string");
   Print("Returned value is ",sret);
//----
   cnt=SortStringArray(strarray,ArraySize(strarray));
   for(int i=0; i<cnt; i++) Print(i," - ",strarray[i]);
   cnt=ProcessStringArray(strarray,ArraySize(strarray));
   for(i=0; i<cnt; i++) Print(i," - ",strarray[i]);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| array functions call                                             |
//+------------------------------------------------------------------+
int start()
  {
   double price;
   double arr[5]={1.5, 2.6, 3.7, 4.8, 5.9 };
   double rates[][6];
//---- get first item from passed array
   price=GetArrayItemValue(arr,5,0);
   Print("Returned from arr[0] ",price);
//---- change second item in the passed array
   if(SetArrayItemValue(arr,5,1,1234.5)==true)
      Print("Changed to ",arr[1]);
//---- get current close
   ArrayCopyRates(rates);
   price=GetRatesItemValue(rates,Bars,0,CLOSE_INDEX);
   Print("Returned from Close ",price);
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments