Below are the required files to use the MML Data Bridge
- Purchase the bridge here: https://www.mql5.com/en/market/product/152143?source=Site+Market+Product+Page#
- User Set Up Manual: https://www.mql5.com/en/blogs/post/766374
- Common Issues and Resolves: https://www.mql5.com/en/blogs/post/766376
- MML Data Bridge Code Structure and MQL5 Programing Challenges: https://www.mql5.com/en/blogs/post/766520
#ifndef dataStructs #define dataStructs //input a defined length for char array #define CHAR_FIELD_WIDTH 128 //leave name as is, used as char field width for the bridge //Define your data structures below //Example 1 struct DIRECTION { datetime time; int signal; }; //Example 2 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 <dataStructs.mqh> // Make sure this matches the .ex5 name in MQL5/Libraries #import "MMLDataBridge.ex5" // These exactly match your exported functions: void initializeBridge_internal(string eaName); void shutdownBridge_internal(); // bool getRecordBytes_internal(const string csvFileName, uchar &out[]); // exported above string CStrFromCharArray(const char &arr[], int max_len = CHAR_FIELD_WIDTH); #import // ---- Public API #1b: initializeBridge(eaName) ---- void initializeBridge(string eaName){ initializeBridge_internal(eaName); } // ---- Public API #2: shutDownBridge() ---- void shutDownBridge() { shutdownBridge_internal(); } // ---- Public API #3: CharArrayToStr() ---- string CharArrayToStr(const char &arr[]) { return CStrFromCharArray(arr); } // ---- Public API #4: returnData<T>() ---- // Pull raw bytes from the bridge and map them into a POD struct T. // Templated wrapper that preserves your original returnData signature template<typename T> bool returnData(const string csvFileName, T &out) { // Ask bridge for the raw bytes (bridge will size 'bytes' correctly) 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"); // Size mismatch means the struct doesn't match the data - fail to prevent reading corrupted data 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"); // If BIN has fewer bytes than struct, we can't fill it -> fail. return false; } } // Correct order: struct first, bytes second return CharArrayToStruct(out, bytes, 0); }


