Soft Manager

MML Data Bridge Required Files


Below are the required files to use the MML Data Bridge

dataStructs.mqh

#ifndef dataStructs
#define dataStructs


#define CHAR_FIELD_WIDTH 128 




struct DIRECTION {
    datetime time;
    int signal;
};


struct BTC_DATA {
    datetime time;
    double actual_price;
    double predicted_price;
    double price_residual;
    double price_error_pct;
    double actual_return;
    double predicted_return;
    double return_residual;
    double direction_correct;
    char dataset_name[CHAR_FIELD_WIDTH];
};

#endif 


MMLUtility.mqh

#property strict
#include 



#import "MMLDataBridge.ex5"
  
  void initializeBridge_internal(string eaName);  
  void shutdownBridge_internal();  
 bool getRecordBytes_internal(const string csvFileName, uchar &out[]); 
  string CStrFromCharArray(const char &arr[], int max_len = CHAR_FIELD_WIDTH);
#import




void initializeBridge(string eaName){
 initializeBridge_internal(eaName);
}


void shutDownBridge() { 
  shutdownBridge_internal();
}


string CharArrayToStr(const char &arr[]) { 
  return CStrFromCharArray(arr); }




templatetypename T>
bool returnData(const string csvFileName, T &out) {
   
   uchar bytes[];
   if (!getRecordBytes_internal(csvFileName, bytes))
      return false;

   const int need = sizeof(out);
   const int have = ArraySize(bytes);

   if (have != need) {
      if (have > need) {
         PrintFormat("MML Data Bridge: Struct size mismatch for '%s'", csvFileName);
         Print("   Your struct is missing %d field(s) or has incorrect field types.");
         PrintFormat("   Solution: Add missing field(s) to your struct or check field data types");
         
         return false;
      } else {
         PrintFormat("MML Data Bridge: Struct size mismatch for '%s'", csvFileName);
         PrintFormat("   This means your struct has %d extra field(s) or incorrect field types");
         PrintFormat("   Solution: Remove extra field(s) from your struct or check field data types");
         
         return false;
      }
   }

   
   return CharArrayToStruct(out, bytes, 0);
}



Source link

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *