├── .gitattributes ├── .gitignore ├── Experts └── ejtraderMT.mq5 ├── Include ├── StringToEnumInt.mqh ├── controlerrors.mqh ├── ejtraderMT │ ├── Broker.mqh │ ├── Calendar.mqh │ ├── ChartControl.mqh │ ├── Event.mqh │ ├── HistoryInfo.mqh │ ├── Search.code-search │ ├── StartIndicator.mqh │ └── String.mqh └── json.mqh ├── Indicators └── ejtraderMTIndicator.mq5 ├── LICENSE ├── README.md ├── changelog.md └── clean.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | text *.mq5 eol=CRLF diff=c 5 | text *.mqh eol=CRLF diff=c -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | 4 | *.mq5:CursorPos:$DATA 5 | 6 | *.mq5:LineFlags:$DATA 7 | 8 | *.mqh:CursorPos:$DATA 9 | 10 | *.mqh:LineFlags:$DATA 11 | -------------------------------------------------------------------------------- /Experts/ejtraderMT.mq5: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| ProjectName | 3 | //| Copyright 2020, CompanyName | 4 | //| http://www.companyname.net | 5 | //+------------------------------------------------------------------+ 6 | 7 | 8 | #property copyright "Copyright 2022, ejtrader." 9 | #property link "https://github.com/ejtraderLabs" 10 | #property version "3.04" 11 | #property description "ejtraderMT" 12 | #property description "See github link for documentation" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | // Set ports and host for ZeroMQ 23 | string HOST="*"; 24 | int SYS_PORT=15555; 25 | int DATA_PORT=15556; 26 | int LIVE_PORT=15557; 27 | int STR_PORT=15558; 28 | 29 | // ZeroMQ Connections 30 | Context context("EJTRADERMT"); 31 | Socket sysSocket(context,ZMQ_REP); 32 | Socket dataSocket(context,ZMQ_PUSH); 33 | Socket liveSocket(context,ZMQ_PUSH); 34 | Socket streamSocket(context,ZMQ_PUSH); 35 | 36 | // Load ejtraderMTincludes 37 | // Required: 38 | #include 39 | #include 40 | #include 41 | // Optional: 42 | //#include 43 | //#include 44 | 45 | // Global variables \\ 46 | bool debug = false; 47 | bool liveStream = false; 48 | bool connectedFlag = true; 49 | int deInitReason = -1; 50 | //double chartAttached = ChartID(); // Chart id where the expert is attached to 51 | 52 | // Variables for handling price data stream 53 | struct SymbolSubscription 54 | { 55 | string symbol; 56 | string chartTf; 57 | datetime lastBar; 58 | }; 59 | SymbolSubscription symbolSubscriptions[]; 60 | int symbolSubscriptionCount = 0; 61 | 62 | // Error handling 63 | ControlErrors mControl; 64 | datetime tm; 65 | //+------------------------------------------------------------------+ 66 | //| Bind ZMQ sockets to ports | 67 | //+------------------------------------------------------------------+ 68 | bool BindSockets() 69 | { 70 | sysSocket.setLinger(1000); 71 | dataSocket.setLinger(1000); 72 | liveSocket.setLinger(1000); 73 | streamSocket.setLinger(1000); 74 | #ifdef START_INDICATOR 75 | indicatorDataSocket.setLinger(1000); 76 | #endif 77 | #ifdef CHART_CONTROL 78 | chartDataSocket.setLinger(1000); 79 | chartIndicatorDataSocket.setLinger(1000); 80 | #endif 81 | 82 | // Number of messages to buffer in RAM. 83 | sysSocket.setSendHighWaterMark(1000); 84 | dataSocket.setSendHighWaterMark(1000); 85 | liveSocket.setSendHighWaterMark(1000); 86 | streamSocket.setSendHighWaterMark(1000); 87 | #ifdef START_INDICATOR 88 | indicatorDataSocket.setSendHighWaterMark(1000); 89 | #endif 90 | #ifdef CHART_CONTROL 91 | chartDataSocket.setReceiveHighWaterMark(1000); // TODO confirm settings 92 | chartIndicatorDataSocket.setReceiveHighWaterMark(1000); 93 | #endif 94 | 95 | bool result = false; 96 | result = sysSocket.bind(StringFormat("tcp://%s:%d", HOST,SYS_PORT)); 97 | if(result == false) 98 | { 99 | return result; 100 | } 101 | else 102 | { 103 | Print("Bound 'System' socket on port ", SYS_PORT); 104 | } 105 | result = dataSocket.bind(StringFormat("tcp://%s:%d", HOST,DATA_PORT)); 106 | if(result == false) 107 | { 108 | return result; 109 | } 110 | else 111 | { 112 | Print("Bound 'Data' socket on port ", DATA_PORT); 113 | } 114 | result = liveSocket.bind(StringFormat("tcp://%s:%d", HOST,LIVE_PORT)); 115 | if(result == false) 116 | { 117 | return result; 118 | } 119 | else 120 | { 121 | Print("Bound 'Live' socket on port ", LIVE_PORT); 122 | } 123 | result = streamSocket.bind(StringFormat("tcp://%s:%d", HOST,STR_PORT)); 124 | if(result == false) 125 | { 126 | return result; 127 | } 128 | else 129 | { 130 | Print("Bound 'Streaming' socket on port ", STR_PORT); 131 | } 132 | #ifdef START_INDICATOR 133 | result = indicatorDataSocket.bind(StringFormat("tcp://%s:%d", HOST,INDICATOR_DATA_PORT)); 134 | if(result == false) 135 | { 136 | return result; 137 | } 138 | else 139 | { 140 | Print("Bound 'Indicator Data' socket on port ", INDICATOR_DATA_PORT); 141 | } 142 | #endif 143 | #ifdef CHART_CONTROL 144 | result = chartDataSocket.bind(StringFormat("tcp://%s:%d", HOST,CHART_DATA_PORT)); 145 | if(result == false) 146 | { 147 | return result; 148 | } 149 | else 150 | { 151 | Print("Bound 'Chart Data' socket on port ", CHART_DATA_PORT); 152 | } 153 | result = chartIndicatorDataSocket.bind(StringFormat("tcp://%s:%d", HOST,CHART_INDICATOR_DATA_PORT)); 154 | if(result == false) 155 | { 156 | return result; 157 | } 158 | else 159 | { 160 | Print("Bound 'JsonAPIIndicator Data' socket on port ", CHART_INDICATOR_DATA_PORT); 161 | } 162 | #endif 163 | return result; 164 | } 165 | 166 | //+------------------------------------------------------------------+ 167 | //| Expert initialization function | 168 | //+------------------------------------------------------------------+ 169 | int OnInit() 170 | { 171 | 172 | // Setting up error reporting 173 | mControl.SetAlert(true); 174 | mControl.SetSound(false); 175 | mControl.SetWriteFlag(false); 176 | 177 | /* Bindinig ZMQ ports on init */ 178 | // Skip reloading of the EA script when the reason to reload is a chart timeframe change 179 | if(deInitReason != REASON_CHARTCHANGE) 180 | { 181 | 182 | EventSetMillisecondTimer(1); 183 | 184 | int bindSocketsDelay = 65; // Seconds to wait if binding of sockets fails. 185 | int bindAttemtps = 2; // Number of binding attemtps 186 | 187 | Print("Binding sockets..."); 188 | 189 | for(int i=0; i0) 378 | { 379 | // Pull request to RequestHandler(). 380 | RequestHandler(request); 381 | } 382 | #ifdef CHART_CONTROL 383 | // Publish indicator values for the JsonAPIIndicator indicator 384 | ZmqMsg chartMsg; 385 | chartDataSocket.recv(chartMsg, true); 386 | if(chartMsg.size()>0) 387 | { 388 | double values[]; 389 | // Ensure that all indicators have finished intitailisation 390 | for(int i=0; i 18 | int StringToEnum(string in,ENUM &out) 19 | { 20 | out=-1; 21 | //--- 22 | for(int i=MIN_ENUM_VALUES;i<=MAX_ENUM_VALUES;i++) 23 | { 24 | ENUM enumValue=(ENUM)i; 25 | if(in==EnumToString(enumValue)) 26 | { 27 | out=enumValue; 28 | break; 29 | } 30 | } 31 | //--- 32 | return(out); 33 | } 34 | 35 | 36 | int StringToEnumInt(string indicatorConstantString) 37 | { 38 | int r = -1; 39 | 40 | ENUM_ACCOUNT_INFO_DOUBLE a1; 41 | r = StringToEnum(indicatorConstantString,a1); 42 | //if(debug) Print("ENUM type: ENUM_ACCOUNT_INFO_DOUBLE"); 43 | if(r>=0)return r; 44 | ENUM_ACCOUNT_INFO_INTEGER a2; 45 | r = StringToEnum(indicatorConstantString,a2); 46 | if(r>=0)return r; 47 | ENUM_ACCOUNT_INFO_STRING a3; 48 | r = StringToEnum(indicatorConstantString,a3); 49 | if(r>=0)return r; 50 | ENUM_ACCOUNT_MARGIN_MODE a4; 51 | r = StringToEnum(indicatorConstantString,a4); 52 | if(r>=0)return r; 53 | ENUM_ACCOUNT_STOPOUT_MODE a5; 54 | r = StringToEnum(indicatorConstantString,a5); 55 | if(r>=0)return r; 56 | ENUM_ACCOUNT_TRADE_MODE a6; 57 | r = StringToEnum(indicatorConstantString,a6); 58 | if(r>=0)return r; 59 | ENUM_ALIGN_MODE a7; 60 | r = StringToEnum(indicatorConstantString,a7); 61 | if(r>=0)return r; 62 | ENUM_ANCHOR_POINT a8; 63 | r = StringToEnum(indicatorConstantString,a8); 64 | if(r>=0)return r; 65 | ENUM_APPLIED_PRICE a9; 66 | r = StringToEnum(indicatorConstantString,a9); 67 | if(r>=0)return r; 68 | ENUM_APPLIED_PRICE a10; 69 | r = StringToEnum(indicatorConstantString,a10); 70 | if(r>=0)return r; 71 | ENUM_APPLIED_VOLUME a11; 72 | r = StringToEnum(indicatorConstantString,a11); 73 | if(r>=0)return r; 74 | ENUM_ARROW_ANCHOR a12; 75 | r = StringToEnum(indicatorConstantString,a12); 76 | if(r>=0)return r; 77 | ENUM_BASE_CORNER a13; 78 | r = StringToEnum(indicatorConstantString,a13); 79 | if(r>=0)return r; 80 | ENUM_BOOK_TYPE a14; 81 | r = StringToEnum(indicatorConstantString,a14); 82 | if(r>=0)return r; 83 | ENUM_BORDER_TYPE a15; 84 | r = StringToEnum(indicatorConstantString,a15); 85 | if(r>=0)return r; 86 | ENUM_CALENDAR_EVENT_FREQUENCY a16; 87 | r = StringToEnum(indicatorConstantString,a16); 88 | if(r>=0)return r; 89 | ENUM_CALENDAR_EVENT_IMPACT a17; 90 | r = StringToEnum(indicatorConstantString,a17); 91 | if(r>=0)return r; 92 | ENUM_CALENDAR_EVENT_IMPORTANCE a18; 93 | r = StringToEnum(indicatorConstantString,a18); 94 | if(r>=0)return r; 95 | ENUM_CALENDAR_EVENT_MULTIPLIER a19; 96 | r = StringToEnum(indicatorConstantString,a19); 97 | if(r>=0)return r; 98 | ENUM_CALENDAR_EVENT_SECTOR a20; 99 | r = StringToEnum(indicatorConstantString,a20); 100 | if(r>=0)return r; 101 | ENUM_CALENDAR_EVENT_TIMEMODE a21; 102 | r = StringToEnum(indicatorConstantString,a21); 103 | if(r>=0)return r; 104 | ENUM_CALENDAR_EVENT_TYPE a22; 105 | r = StringToEnum(indicatorConstantString,a22); 106 | if(r>=0)return r; 107 | ENUM_CALENDAR_EVENT_UNIT a23; 108 | r = StringToEnum(indicatorConstantString,a23); 109 | if(r>=0)return r; 110 | ENUM_CHART_EVENT a24; 111 | r = StringToEnum(indicatorConstantString,a24); 112 | if(r>=0)return r; 113 | ENUM_CHART_MODE a25; 114 | r = StringToEnum(indicatorConstantString,a25); 115 | if(r>=0)return r; 116 | ENUM_CHART_POSITION a26; 117 | r = StringToEnum(indicatorConstantString,a26); 118 | if(r>=0)return r; 119 | ENUM_CHART_PROPERTY_DOUBLE a27; 120 | r = StringToEnum(indicatorConstantString,a27); 121 | if(r>=0)return r; 122 | ENUM_CHART_PROPERTY_INTEGER a28; 123 | r = StringToEnum(indicatorConstantString,a28); 124 | if(r>=0)return r; 125 | ENUM_CHART_PROPERTY_STRING a29; 126 | r = StringToEnum(indicatorConstantString,a29); 127 | if(r>=0)return r; 128 | ENUM_CHART_VOLUME_MODE a30; 129 | r = StringToEnum(indicatorConstantString,a30); 130 | if(r>=0)return r; 131 | ENUM_CL_DEVICE_TYPE a31; 132 | r = StringToEnum(indicatorConstantString,a31); 133 | if(r>=0)return r; 134 | ENUM_COLOR_FORMAT a32; 135 | r = StringToEnum(indicatorConstantString,a32); 136 | if(r>=0)return r; 137 | ENUM_CRYPT_METHOD a33; 138 | r = StringToEnum(indicatorConstantString,a33); 139 | if(r>=0)return r; 140 | ENUM_CUSTOMIND_PROPERTY_DOUBLE a34; 141 | r = StringToEnum(indicatorConstantString,a34); 142 | if(r>=0)return r; 143 | ENUM_CHART_PROPERTY_INTEGER a35; 144 | r = StringToEnum(indicatorConstantString,a35); 145 | if(r>=0)return r; 146 | ENUM_CUSTOMIND_PROPERTY_STRING a36; 147 | r = StringToEnum(indicatorConstantString,a36); 148 | if(r>=0)return r; 149 | ENUM_DATABASE_EXPORT_FLAGS a37; 150 | r = StringToEnum(indicatorConstantString,a37); 151 | if(r>=0)return r; 152 | ENUM_DATABASE_FIELD_TYPE a38; 153 | r = StringToEnum(indicatorConstantString,a38); 154 | if(r>=0)return r; 155 | ENUM_DATABASE_OPEN_FLAGS a39; 156 | r = StringToEnum(indicatorConstantString,a39); 157 | if(r>=0)return r; 158 | ENUM_DATABASE_PRINT_FLAGS a40; 159 | r = StringToEnum(indicatorConstantString,a40); 160 | if(r>=0)return r; 161 | ENUM_DATATYPE a41; 162 | r = StringToEnum(indicatorConstantString,a41); 163 | if(r>=0)return r; 164 | ENUM_DAY_OF_WEEK a42; 165 | r = StringToEnum(indicatorConstantString,a42); 166 | if(r>=0)return r; 167 | ENUM_DEAL_ENTRY a43; 168 | r = StringToEnum(indicatorConstantString,a43); 169 | if(r>=0)return r; 170 | ENUM_DEAL_PROPERTY_DOUBLE a44; 171 | r = StringToEnum(indicatorConstantString,a44); 172 | if(r>=0)return r; 173 | ENUM_DEAL_PROPERTY_INTEGER a45; 174 | r = StringToEnum(indicatorConstantString,a45); 175 | if(r>=0)return r; 176 | ENUM_DEAL_PROPERTY_STRING a46; 177 | r = StringToEnum(indicatorConstantString,a46); 178 | if(r>=0)return r; 179 | ENUM_DEAL_REASON a47; 180 | r = StringToEnum(indicatorConstantString,a47); 181 | if(r>=0)return r; 182 | ENUM_DEAL_TYPE a48; 183 | r = StringToEnum(indicatorConstantString,a48); 184 | if(r>=0)return r; 185 | ENUM_DRAW_TYPE a49; 186 | r = StringToEnum(indicatorConstantString,a49); 187 | if(r>=0)return r; 188 | ENUM_DX_BUFFER_TYPE a50; 189 | r = StringToEnum(indicatorConstantString,a50); 190 | if(r>=0)return r; 191 | ENUM_DX_FORMAT a51; 192 | r = StringToEnum(indicatorConstantString,a51); 193 | if(r>=0)return r; 194 | ENUM_DX_HANDLE_TYPE a52; 195 | r = StringToEnum(indicatorConstantString,a52); 196 | if(r>=0)return r; 197 | ENUM_DX_PRIMITIVE_TOPOLOGY a53; 198 | r = StringToEnum(indicatorConstantString,a53); 199 | if(r>=0)return r; 200 | ENUM_DX_SHADER_TYPE a54; 201 | r = StringToEnum(indicatorConstantString,a54); 202 | if(r>=0)return r; 203 | ENUM_ELLIOT_WAVE_DEGREE a55; 204 | r = StringToEnum(indicatorConstantString,a55); 205 | if(r>=0)return r; 206 | ENUM_FILESELECT_FLAGS a56; 207 | r = StringToEnum(indicatorConstantString,a56); 208 | if(r>=0)return r; 209 | ENUM_FILE_POSITION a57; 210 | r = StringToEnum(indicatorConstantString,a57); 211 | if(r>=0)return r; 212 | ENUM_FILE_PROPERTY_INTEGER a58; 213 | r = StringToEnum(indicatorConstantString,a58); 214 | if(r>=0)return r; 215 | ENUM_GANN_DIRECTION a59; 216 | r = StringToEnum(indicatorConstantString,a59); 217 | if(r>=0)return r; 218 | ENUM_INDEXBUFFER_TYPE a60; 219 | r = StringToEnum(indicatorConstantString,a60); 220 | if(r>=0)return r; 221 | ENUM_INDICATOR a61; 222 | r = StringToEnum(indicatorConstantString,a61); 223 | if(r>=0)return r; 224 | ENUM_INIT_RETCODE a62; 225 | r = StringToEnum(indicatorConstantString,a62); 226 | if(r>=0)return r; 227 | ENUM_LICENSE_TYPE a63; 228 | r = StringToEnum(indicatorConstantString,a63); 229 | if(r>=0)return r; 230 | ENUM_LINE_STYLE a64; 231 | r = StringToEnum(indicatorConstantString,a64); 232 | if(r>=0)return r; 233 | ENUM_MA_METHOD a65; 234 | r = StringToEnum(indicatorConstantString,a65); 235 | if(r>=0)return r; 236 | ENUM_MQL_INFO_INTEGER a66; 237 | r = StringToEnum(indicatorConstantString,a66); 238 | if(r>=0)return r; 239 | ENUM_MQL_INFO_STRING a67; 240 | r = StringToEnum(indicatorConstantString,a67); 241 | if(r>=0)return r; 242 | ENUM_OBJECT a68; 243 | r = StringToEnum(indicatorConstantString,a68); 244 | if(r>=0)return r; 245 | ENUM_OBJECT_PROPERTY_DOUBLE a69; 246 | r = StringToEnum(indicatorConstantString,a69); 247 | if(r>=0)return r; 248 | ENUM_OBJECT_PROPERTY_INTEGER a70; 249 | r = StringToEnum(indicatorConstantString,a70); 250 | if(r>=0)return r; 251 | ENUM_OBJECT_PROPERTY_STRING a71; 252 | r = StringToEnum(indicatorConstantString,a71); 253 | if(r>=0)return r; 254 | ENUM_OPENCL_HANDLE_TYPE a72; 255 | r = StringToEnum(indicatorConstantString,a72); 256 | if(r>=0)return r; 257 | ENUM_OPENCL_PROPERTY_INTEGER a73; 258 | r = StringToEnum(indicatorConstantString,a73); 259 | if(r>=0)return r; 260 | ENUM_PLOT_PROPERTY_STRING a74; 261 | r = StringToEnum(indicatorConstantString,a74); 262 | if(r>=0)return r; 263 | ENUM_POINTER_TYPE a75; 264 | r = StringToEnum(indicatorConstantString,a75); 265 | if(r>=0)return r; 266 | ENUM_POSITION_PROPERTY_DOUBLE a76; 267 | r = StringToEnum(indicatorConstantString,a76); 268 | if(r>=0)return r; 269 | ENUM_ORDER_PROPERTY_INTEGER a77; 270 | r = StringToEnum(indicatorConstantString,a77); 271 | if(r>=0)return r; 272 | ENUM_PLOT_PROPERTY_STRING a78; 273 | r = StringToEnum(indicatorConstantString,a78); 274 | if(r>=0)return r; 275 | ENUM_PROGRAM_TYPE a79; 276 | r = StringToEnum(indicatorConstantString,a79); 277 | if(r>=0)return r; 278 | ENUM_SERIESMODE a80; 279 | r = StringToEnum(indicatorConstantString,a80); 280 | if(r>=0)return r; 281 | ENUM_SERIES_INFO_INTEGER a81; 282 | r = StringToEnum(indicatorConstantString,a81); 283 | if(r>=0)return r; 284 | ENUM_SIGNAL_BASE_DOUBLE a82; 285 | r = StringToEnum(indicatorConstantString,a82); 286 | if(r>=0)return r; 287 | ENUM_SIGNAL_BASE_INTEGER a83; 288 | r = StringToEnum(indicatorConstantString,a83); 289 | if(r>=0)return r; 290 | ENUM_SIGNAL_BASE_STRING a84; 291 | r = StringToEnum(indicatorConstantString,a84); 292 | if(r>=0)return r; 293 | ENUM_SIGNAL_INFO_DOUBLE a85; 294 | r = StringToEnum(indicatorConstantString,a85); 295 | if(r>=0)return r; 296 | ENUM_SIGNAL_INFO_INTEGER a86; 297 | r = StringToEnum(indicatorConstantString,a86); 298 | if(r>=0)return r; 299 | ENUM_SIGNAL_INFO_STRING a87; 300 | r = StringToEnum(indicatorConstantString,a87); 301 | if(r>=0)return r; 302 | ENUM_STATISTICS a88; 303 | r = StringToEnum(indicatorConstantString,a88); 304 | if(r>=0)return r; 305 | ENUM_STO_PRICE a89; 306 | r = StringToEnum(indicatorConstantString,a89); 307 | if(r>=0)return r; 308 | ENUM_SYMBOL_CALC_MODE a90; 309 | r = StringToEnum(indicatorConstantString,a90); 310 | if(r>=0)return r; 311 | ENUM_SYMBOL_CHART_MODE a91; 312 | r = StringToEnum(indicatorConstantString,a91); 313 | if(r>=0)return r; 314 | ENUM_SYMBOL_INFO_DOUBLE a92; 315 | r = StringToEnum(indicatorConstantString,a92); 316 | if(r>=0)return r; 317 | ENUM_SYMBOL_INFO_INTEGER a93; 318 | r = StringToEnum(indicatorConstantString,a93); 319 | if(r>=0)return r; 320 | ENUM_SYMBOL_INFO_STRING a94; 321 | r = StringToEnum(indicatorConstantString,a94); 322 | if(r>=0)return r; 323 | ENUM_STATISTICS a95; 324 | r = StringToEnum(indicatorConstantString,a95); 325 | if(r>=0)return r; 326 | ENUM_STO_PRICE a96; 327 | r = StringToEnum(indicatorConstantString,a96); 328 | if(r>=0)return r; 329 | ENUM_SYMBOL_CALC_MODE a97; 330 | r = StringToEnum(indicatorConstantString,a97); 331 | if(r>=0)return r; 332 | ENUM_SYMBOL_CHART_MODE a98; 333 | r = StringToEnum(indicatorConstantString,a98); 334 | if(r>=0)return r; 335 | ENUM_SYMBOL_INFO_DOUBLE a99; 336 | r = StringToEnum(indicatorConstantString,a99); 337 | if(r>=0)return r; 338 | ENUM_SYMBOL_INFO_INTEGER a100; 339 | r = StringToEnum(indicatorConstantString,a100); 340 | if(r>=0)return r; 341 | ENUM_SYMBOL_INFO_STRING a101; 342 | r = StringToEnum(indicatorConstantString,a101); 343 | if(r>=0)return r; 344 | ENUM_SYMBOL_OPTION_MODE a102; 345 | r = StringToEnum(indicatorConstantString,a102); 346 | if(r>=0)return r; 347 | ENUM_SYMBOL_OPTION_RIGHT a103; 348 | r = StringToEnum(indicatorConstantString,a103); 349 | if(r>=0)return r; 350 | ENUM_SYMBOL_ORDER_GTC_MODE a104; 351 | r = StringToEnum(indicatorConstantString,a104); 352 | if(r>=0)return r; 353 | ENUM_SYMBOL_SWAP_MODE a105; 354 | r = StringToEnum(indicatorConstantString,a105); 355 | if(r>=0)return r; 356 | ENUM_SYMBOL_TRADE_EXECUTION a106; 357 | r = StringToEnum(indicatorConstantString,a106); 358 | if(r>=0)return r; 359 | ENUM_SYMBOL_TRADE_MODE a107; 360 | r = StringToEnum(indicatorConstantString,a107); 361 | if(r>=0)return r; 362 | ENUM_TERMINAL_INFO_DOUBLE a108; 363 | r = StringToEnum(indicatorConstantString,a108); 364 | if(r>=0)return r; 365 | ENUM_TERMINAL_INFO_INTEGER a109; 366 | r = StringToEnum(indicatorConstantString,a109); 367 | if(r>=0)return r; 368 | ENUM_TERMINAL_INFO_STRING a110; 369 | r = StringToEnum(indicatorConstantString,a110); 370 | if(r>=0)return r; 371 | ENUM_TIMEFRAMES a111; 372 | r = StringToEnum(indicatorConstantString,a111); 373 | if(r>=0)return r; 374 | ENUM_TRADE_REQUEST_ACTIONS a112; 375 | r = StringToEnum(indicatorConstantString,a112); 376 | if(r>=0)return r; 377 | ENUM_TRADE_TRANSACTION_TYPE a113; 378 | r = StringToEnum(indicatorConstantString,a113); 379 | if(r>=0)return r; 380 | 381 | return(-1); 382 | } 383 | -------------------------------------------------------------------------------- /Include/controlerrors.mqh: -------------------------------------------------------------------------------- 1 | //+------------------------------------------------------------------+ 2 | //| ControlErrors.mqh | 3 | //| Copyright KlimMalgin | 4 | //| The library should be located in directory: | 5 | //| MetaTrader 5/MQL5/Include/ | 6 | //| https://www.mql5.com/en/articles/70 | 7 | //+------------------------------------------------------------------+ 8 | #property copyright "KlimMalgin" 9 | #property link "" 10 | 11 | 12 | 13 | class ControlErrors 14 | { 15 | private: 16 | 17 | // Flags that define what types of reports need to be enabled 18 | bool _PlaySound; // Play or don't play a sound when an error occurs. 19 | bool _PrintInfo; // Add error details to the journal of Expert Advisors 20 | bool _AlertInfo; // Generate Alert with error details 21 | bool _WriteFile; // Record reports on errors into a file or not 22 | 23 | // A structure for storing error data elements that use this structure 24 | struct Code 25 | { 26 | int code; // Error code 27 | string desc; // Description of the error code 28 | }; 29 | Code Errors[]; // Array that contains error codes and their descriptions 30 | Code _UserError; // Stores information about a custome error 31 | Code _Error; // Stores information about the last error of any type 32 | 33 | // Different service properties 34 | short _CountErrors; // Number of errors stored in array Errors[] 35 | string _PlaySoundFile; // File that will be played for an alert sound 36 | string _DataPath; // Path to the log storing directory 37 | 38 | 39 | public: 40 | // Constructor 41 | ControlErrors(void); 42 | 43 | // Methods for setting flags 44 | void SetSound(bool value); // Play or don't play a sound when an error occurs 45 | void SetPrint(bool value); // Enter error data the the journal of Expert Advisors or not 46 | void SetAlert(bool value); // Generate an Alert message or not 47 | void SetWriteFlag(bool flag); // Set the writing flag. true - keep logs, false - do not keep 48 | 49 | // Methods for working with errors 50 | int mGetLastError(); // Returns contents of the system variable _LastError 51 | int mGetError(); // Returns code of the last obtained error 52 | int mGetTypeError(); // Returns error type (Custom = 1 ore predefined = 0) 53 | void mResetLastError(); // Resets the contents of the system variable _LastError 54 | void mSetUserError(ushort value, string desc = ""); // Sets the custom error 55 | void mResetUserError(); // Resets class fields that contain information about the custom error 56 | void mResetError(); // Resets the structure that contains information about the last error 57 | string mGetDesc(int nErr = 0); // Returns error description by the number, or that of the current error of no number 58 | int Check(string st = ""); // Method to check the current system state for errors 59 | 60 | // Alert methods (Alert, Print, Sound) 61 | void mAlert(string message = ""); 62 | void mPrint(string message = ""); 63 | void mSound(); 64 | 65 | // Various service methods 66 | void SetPlaySoundFile(string file); // Method sets the file name to play an sound 67 | void SetWritePath(string path); // Set the path to store logs 68 | int mFileWrite(string message = "");// Record into a file the available information about the last error 69 | }; 70 | 71 | void ControlErrors::ControlErrors(void) 72 | { 73 | SetAlert(false); 74 | SetPrint(false); 75 | SetSound(false); 76 | SetWriteFlag(false); 77 | SetPlaySoundFile("alert.wav"); 78 | SetWritePath("LogErrors.txt"); 79 | 80 | _CountErrors = 150; 81 | 82 | ArrayResize(Errors, _CountErrors); 83 | // Return codes of a trade server 84 | Errors[0].code = 10004;Errors[0].desc = "Requote"; 85 | Errors[1].code = 10006;Errors[1].desc = "Request rejected"; 86 | Errors[2].code = 10007;Errors[2].desc = "Request canceled by trader"; 87 | Errors[3].code = 10008;Errors[3].desc = "Order placed"; 88 | Errors[4].code = 10009;Errors[4].desc = "Request is completed"; 89 | Errors[5].code = 10010;Errors[5].desc = "Request is partially completed"; 90 | Errors[6].code = 10011;Errors[6].desc = "Request processing error"; 91 | Errors[7].code = 10012;Errors[7].desc = "Request canceled by timeout"; 92 | Errors[8].code = 10013;Errors[8].desc = "Invalid request"; 93 | Errors[9].code = 10014;Errors[9].desc = "Invalid volume in the request"; 94 | Errors[10].code = 10015;Errors[10].desc = "Invalid price in the request"; 95 | Errors[11].code = 10016;Errors[11].desc = "Invalid stops in the request"; 96 | Errors[12].code = 10017;Errors[12].desc = "Trade is disabled"; 97 | Errors[13].code = 10018;Errors[13].desc = "Market is closed"; 98 | Errors[14].code = 10019;Errors[14].desc = "There is not enough money to fulfill the request"; 99 | Errors[15].code = 10020;Errors[15].desc = "Prices changed"; 100 | Errors[16].code = 10021;Errors[16].desc = "There are no quotes to process the request"; 101 | Errors[17].code = 10022;Errors[17].desc = "Invalid order expiration date in the request"; 102 | Errors[18].code = 10023;Errors[18].desc = "Order state changed"; 103 | Errors[19].code = 10024;Errors[19].desc = "Too frequent requests"; 104 | Errors[20].code = 10025;Errors[20].desc = "No changes in request"; 105 | Errors[21].code = 10026;Errors[21].desc = "Autotrading disabled by server"; 106 | Errors[22].code = 10027;Errors[22].desc = "Autotrading disabled by client terminal"; 107 | Errors[23].code = 10028;Errors[23].desc = "Request locked for processing"; 108 | Errors[24].code = 10029;Errors[24].desc = "Order or position frozen"; 109 | Errors[25].code = 10030;Errors[25].desc = "Invalid order filling type"; 110 | 111 | // Common Errors 112 | Errors[26].code = 4001;Errors[26].desc = "Unexpected internal error"; 113 | Errors[27].code = 4002;Errors[27].desc = "Wrong parameter in the inner call of the client terminal function"; 114 | Errors[28].code = 4003;Errors[28].desc = "Wrong parameter when calling the system function"; 115 | Errors[29].code = 4004;Errors[29].desc = "Not enough memory to perform the system function"; 116 | Errors[30].code = 4005;Errors[30].desc = "The structure contains objects of strings and/or dynamic arrays and/or structure of such objects and/or classes"; 117 | Errors[31].code = 4006;Errors[31].desc = "Array of a wrong type, wrong size, or a damaged object of a dynamic array"; 118 | Errors[32].code = 4007;Errors[32].desc = "Not enough memory for the relocation of an array, or an attempt to change the size of a static array"; 119 | Errors[33].code = 4008;Errors[33].desc = "Not enough memory for the relocation of string"; 120 | Errors[34].code = 4009;Errors[34].desc = "Not initialized string"; 121 | Errors[35].code = 4010;Errors[35].desc = "Invalid date and/or time"; 122 | Errors[36].code = 4011;Errors[36].desc = "Requested array size exceeds 2 GB"; 123 | Errors[37].code = 4012;Errors[37].desc = "Wrong pointer"; 124 | Errors[38].code = 4013;Errors[38].desc = "Wrong type of pointer"; 125 | Errors[39].code = 4014;Errors[39].desc = "System function is not allowed to call"; 126 | 127 | // Charts 128 | Errors[40].code = 4101;Errors[40].desc = "Wrong chart ID"; 129 | Errors[41].code = 4102;Errors[41].desc = "Chart does not respond"; 130 | Errors[42].code = 4103;Errors[42].desc = "Chart not found"; 131 | Errors[43].code = 4104;Errors[43].desc = "No Expert Advisor in the chart that could handle the event"; 132 | Errors[44].code = 4105;Errors[44].desc = "Chart opening error"; 133 | Errors[45].code = 4106;Errors[45].desc = "Failed to change chart symbol and period"; 134 | Errors[46].code = 4107;Errors[46].desc = "Wrong parameter for timer"; 135 | Errors[47].code = 4108;Errors[47].desc = "Failed to create timer"; 136 | Errors[48].code = 4109;Errors[48].desc = "Wrong chart property ID"; 137 | Errors[49].code = 4110;Errors[49].desc = "Error creating screenshots"; 138 | Errors[50].code = 4111;Errors[50].desc = "Error navigating through chart"; 139 | Errors[51].code = 4112;Errors[51].desc = "Error applying template"; 140 | Errors[52].code = 4113;Errors[52].desc = "Subwindow containing the indicator was not found"; 141 | 142 | // Graphical Objects 143 | Errors[53].code = 4201;Errors[53].desc = "Error working with a graphical object"; 144 | Errors[54].code = 4202;Errors[54].desc = "Graphical object was not found"; 145 | Errors[55].code = 4203;Errors[55].desc = "Wrong ID of a graphical object property"; 146 | Errors[56].code = 4204;Errors[56].desc = "Unable to get date corresponding to the value"; 147 | Errors[57].code = 4205;Errors[57].desc = "Unable to get value corresponding to the date"; 148 | 149 | // MarketInfo 150 | Errors[58].code = 4301;Errors[58].desc = "Unknown symbol"; 151 | Errors[59].code = 4302;Errors[59].desc = "Symbol is not selected in MarketWatch"; 152 | Errors[60].code = 4303;Errors[60].desc = "Wrong identifier of a symbol property"; 153 | Errors[61].code = 4304;Errors[61].desc = "Time of the last tick is not known (no ticks)"; 154 | 155 | // History Access 156 | Errors[62].code = 4401;Errors[62].desc = "Requested history not found"; 157 | Errors[63].code = 4402;Errors[63].desc = "Wrong ID of the history property"; 158 | 159 | // Global_Variables 160 | Errors[64].code = 4501;Errors[64].desc = "Global variable of the client terminal is not found"; 161 | Errors[65].code = 4502;Errors[65].desc = "Global variable of the client terminal with the same name already exists"; 162 | Errors[66].code = 4510;Errors[66].desc = "Email sending failed"; 163 | Errors[67].code = 4511;Errors[67].desc = "Sound playing failed"; 164 | Errors[68].code = 4512;Errors[68].desc = "Wrong identifier of the program property"; 165 | Errors[69].code = 4513;Errors[69].desc = "Wrong identifier of the terminal property"; 166 | Errors[70].code = 4514;Errors[70].desc = "File sending via ftp failed"; 167 | 168 | // Custom Indicator Buffers 169 | Errors[71].code = 4601;Errors[71].desc = "Not enough memory for the distribution of indicator buffers"; 170 | Errors[72].code = 4602;Errors[72].desc = "Wrong indicator buffer index"; 171 | 172 | // Custom Indicator Properties 173 | Errors[73].code = 4603;Errors[73].desc = "Wrong ID of the custom indicator property"; 174 | 175 | // Account 176 | Errors[74].code = 4701;Errors[74].desc = "Wrong account property ID"; 177 | Errors[75].code = 4751;Errors[75].desc = "Wrong trade property ID;"; 178 | Errors[76].code = 4752;Errors[76].desc = "Trading by Expert Advisors prohibited"; 179 | Errors[77].code = 4753;Errors[77].desc = "Position not found"; 180 | Errors[78].code = 4754;Errors[78].desc = "Order not found"; 181 | Errors[79].code = 4755;Errors[79].desc = "Deal not found"; 182 | Errors[80].code = 4756;Errors[80].desc = "Trade request sending failed"; 183 | Errors[81].code = 4757;Errors[81].desc = "Timeout exceeded when selecting (searching) specified data"; 184 | 185 | // Indicators 186 | Errors[82].code = 4801;Errors[82].desc = "Unknown symbol"; 187 | Errors[83].code = 4802;Errors[83].desc = "Indicator cannot be created"; 188 | Errors[84].code = 4803;Errors[84].desc = "Not enough memory to add the indicator"; 189 | Errors[85].code = 4804;Errors[85].desc = "The indicator cannot be applied to another indicator"; 190 | Errors[86].code = 4805;Errors[86].desc = "Error applying an indicator to chart"; 191 | Errors[87].code = 4806;Errors[87].desc = "Requested data not found"; 192 | Errors[88].code = 4807;Errors[88].desc = "Wrong index of the requested indicator buffer"; 193 | Errors[89].code = 4808;Errors[89].desc = "Wrong number of parameters when creating an indicator"; 194 | Errors[90].code = 4809;Errors[90].desc = "No parameters when creating an indicator"; 195 | Errors[91].code = 4810;Errors[91].desc = "The first parameter in the array must be the name of the custom indicator"; 196 | Errors[92].code = 4811;Errors[92].desc = "Invalid parameter type in the array when creating an indicator"; 197 | 198 | // Depth of Market 199 | Errors[93].code = 4901;Errors[93].desc = "Depth Of Market can not be added"; 200 | Errors[94].code = 4902;Errors[94].desc = "Depth Of Market can not be removed"; 201 | Errors[95].code = 4903;Errors[95].desc = "The data from Depth Of Market can not be obtained"; 202 | Errors[96].code = 4904;Errors[96].desc = "Error in subscribing to receive new data from Depth Of Market"; 203 | 204 | // File Operations 205 | Errors[97].code = 5001;Errors[97].desc = "More than 64 files cannot be opened at the same time"; 206 | Errors[98].code = 5002;Errors[98].desc = "Invalid file name"; 207 | Errors[99].code = 5003;Errors[99].desc = "Too long file name"; 208 | Errors[100].code = 5004;Errors[100].desc = "File opening error"; 209 | Errors[101].code = 5005;Errors[101].desc = "Not enough memory for cache to read"; 210 | Errors[102].code = 5006;Errors[102].desc = "File deleting error"; 211 | Errors[103].code = 5007;Errors[103].desc = "A file with this handle was closed, or was not opened at all"; 212 | Errors[104].code = 5008;Errors[104].desc = "Wrong file handle"; 213 | Errors[105].code = 5009;Errors[105].desc = "The file must be opened for writing"; 214 | Errors[106].code = 5010;Errors[106].desc = "The file must be opened for reading"; 215 | Errors[107].code = 5011;Errors[107].desc = "The file must be opened as a binary one"; 216 | Errors[108].code = 5012;Errors[108].desc = "The file must be opened as a text"; 217 | Errors[109].code = 5013;Errors[109].desc = "The file must be opened as a text or CSV"; 218 | Errors[110].code = 5014;Errors[110].desc = "The file must be opened as CSV"; 219 | Errors[111].code = 5015;Errors[111].desc = "File reading error"; 220 | Errors[112].code = 5016;Errors[112].desc = "String size must be specified, because the file is opened as binary"; 221 | Errors[113].code = 5017;Errors[113].desc = "A text file must be for string arrays, for other arrays - binary"; 222 | Errors[114].code = 5018;Errors[114].desc = "This is not a file, this is a directory"; 223 | Errors[115].code = 5019;Errors[115].desc = "File does not exist"; 224 | Errors[116].code = 5020;Errors[116].desc = "File can not be rewritten"; 225 | Errors[117].code = 5021;Errors[117].desc = "Wrong directory name"; 226 | Errors[118].code = 5022;Errors[118].desc = "Directory does not exist"; 227 | Errors[119].code = 5023;Errors[119].desc = "This is a file, not a directory"; 228 | Errors[120].code = 5024;Errors[120].desc = "The directory cannot be removed"; 229 | 230 | // String Casting 231 | Errors[121].code = 5030;Errors[121].desc = "No date in the string"; 232 | Errors[122].code = 5031;Errors[122].desc = "Wrong date in the string"; 233 | Errors[123].code = 5032;Errors[123].desc = "Wrong time in the string"; 234 | Errors[124].code = 5033;Errors[124].desc = "Error converting string to date"; 235 | Errors[125].code = 5034;Errors[125].desc = "Not enough memory for the string"; 236 | Errors[126].code = 5035;Errors[126].desc = "The string length is less than expected"; 237 | Errors[127].code = 5036;Errors[127].desc = "Too large number, more than ULONG_MAX"; 238 | Errors[128].code = 5037;Errors[128].desc = "Invalid format string"; 239 | Errors[129].code = 5038;Errors[129].desc = "Amount of format specifiers more than the parameters"; 240 | Errors[130].code = 5039;Errors[130].desc = "Amount of parameters more than the format specifiers"; 241 | Errors[131].code = 5040;Errors[131].desc = "Damaged parameter of string type"; 242 | Errors[132].code = 5041;Errors[132].desc = "Position outside the string"; 243 | Errors[133].code = 5042;Errors[133].desc = "0 added to the string end, a useless operation"; 244 | Errors[134].code = 5043;Errors[134].desc = "Unknown data type when converting to a string"; 245 | Errors[135].code = 5044;Errors[135].desc = "Damaged string object"; 246 | 247 | // Operations with Arrays 248 | Errors[136].code = 5050;Errors[136].desc = "Copying incompatible arrays. String array can be copied only to a string array, and a numeric array - in numeric array only"; 249 | Errors[137].code = 5051;Errors[137].desc = "The receiving array is declared as AS_SERIES, and it is of insufficient size"; 250 | Errors[138].code = 5052;Errors[138].desc = "Too small array, the starting position is outside the array"; 251 | Errors[139].code = 5053;Errors[139].desc = "An array of zero length"; 252 | Errors[140].code = 5054;Errors[140].desc = "Must be a numeric array"; 253 | Errors[141].code = 5055;Errors[141].desc = "Must be a one-dimensional array"; 254 | Errors[142].code = 5056;Errors[142].desc = "Timeseries cannot be used"; 255 | Errors[143].code = 5057;Errors[143].desc = "Must be an array of type double"; 256 | Errors[144].code = 5058;Errors[144].desc = "Must be an array of type float"; 257 | Errors[145].code = 5059;Errors[145].desc = "Must be an array of type long"; 258 | Errors[146].code = 5060;Errors[146].desc = "Must be an array of type int"; 259 | Errors[147].code = 5061;Errors[147].desc = "Must be an array of type short"; 260 | Errors[148].code = 5062;Errors[148].desc = "Must be an array of type char"; 261 | } 262 | 263 | void ControlErrors::SetAlert(bool value) 264 | { 265 | _AlertInfo = value; 266 | } 267 | 268 | void ControlErrors::SetPrint(bool value) 269 | { 270 | _PrintInfo = value; 271 | } 272 | 273 | void ControlErrors::SetSound(bool value) 274 | { 275 | _PlaySound = value; 276 | } 277 | 278 | void ControlErrors::SetWriteFlag(bool flag) 279 | { 280 | _WriteFile = flag; 281 | } 282 | 283 | void ControlErrors::SetWritePath(string path) 284 | { 285 | _DataPath = path; 286 | } 287 | 288 | void ControlErrors::SetPlaySoundFile(string file) 289 | { 290 | _PlaySoundFile = file; 291 | } 292 | 293 | int ControlErrors::mGetLastError(void) 294 | { 295 | _Error.code = GetLastError(); 296 | _Error.desc = mGetDesc(_Error.code); 297 | return _Error.code; 298 | } 299 | 300 | void ControlErrors::mResetLastError(void) 301 | { 302 | ResetLastError(); 303 | } 304 | 305 | int ControlErrors::mGetError(void) 306 | { 307 | return _Error.code; 308 | } 309 | 310 | void ControlErrors::mResetError(void) 311 | { 312 | _Error.code = 0; 313 | _Error.desc = ""; 314 | } 315 | 316 | int ControlErrors::mGetTypeError(void) 317 | { 318 | if (mGetError() < ERR_USER_ERROR_FIRST) 319 | { 320 | return 0; 321 | } 322 | else if (mGetError() >= ERR_USER_ERROR_FIRST) 323 | { 324 | return 1; 325 | } 326 | return -1; 327 | } 328 | 329 | void ControlErrors::mSetUserError(ushort value, string desc = "") 330 | { 331 | SetUserError(value); 332 | _UserError.code = value; 333 | _UserError.desc = desc; 334 | } 335 | 336 | void ControlErrors::mResetUserError(void) 337 | { 338 | _UserError.code = 0; 339 | _UserError.desc = ""; 340 | } 341 | 342 | string ControlErrors::mGetDesc(int nErr=0) 343 | { 344 | int ErrorNumber = 0; 345 | string ReturnDesc = ""; 346 | 347 | ErrorNumber = (mGetError()>0)?mGetError():ErrorNumber; 348 | ErrorNumber = (nErr>0)?nErr:ErrorNumber; 349 | 350 | if ((ErrorNumber > 0) && (ErrorNumber < ERR_USER_ERROR_FIRST)) 351 | { 352 | for (int i = 0;i<_CountErrors;i++) 353 | { 354 | if (Errors[i].code == ErrorNumber) 355 | { 356 | ReturnDesc = Errors[i].desc; 357 | break; 358 | } 359 | } 360 | } 361 | else if (ErrorNumber > ERR_USER_ERROR_FIRST) 362 | { 363 | ReturnDesc = (_UserError.desc=="")?"Custom error":_UserError.desc; 364 | } 365 | 366 | if (ReturnDesc == ""){return "Unknown error code: "+(string)ErrorNumber;} 367 | return ReturnDesc; 368 | } 369 | 370 | void ControlErrors::mAlert(string message="") 371 | { 372 | if (_AlertInfo == true) 373 | { 374 | if (message == "") 375 | { 376 | if (mGetError() > 0) 377 | { 378 | Alert("Error ",mGetError()," - ",mGetDesc()); 379 | } 380 | } 381 | else 382 | { 383 | Alert(message); 384 | } 385 | } 386 | } 387 | 388 | void ControlErrors::mPrint(string message="") 389 | { 390 | if (_PrintInfo == true) 391 | { 392 | if (message == "") 393 | { 394 | if (mGetError() > 0) 395 | { 396 | Print("Error ",mGetError()," - ",mGetDesc()); 397 | } 398 | } 399 | else 400 | { 401 | Print(message); 402 | } 403 | } 404 | } 405 | 406 | void ControlErrors::mSound(void) 407 | { 408 | if (_PlaySound == true) 409 | { 410 | PlaySound(_PlaySoundFile); 411 | } 412 | } 413 | 414 | int ControlErrors::Check(string st="") 415 | { 416 | int errNum = 0; 417 | errNum = mGetLastError(); 418 | mFileWrite(); 419 | mAlert(st); 420 | mPrint(st); 421 | mSound(); 422 | mResetError(); 423 | mResetLastError(); 424 | mResetUserError(); 425 | return errNum; 426 | } 427 | 428 | int ControlErrors::mFileWrite(string message = "") 429 | { 430 | int handle = 0, 431 | _return = 0; 432 | datetime time = TimeCurrent(); 433 | string text = (message != "")?message:time+" - Error "+mGetError()+" "+mGetDesc(); 434 | 435 | if (_WriteFile == true) 436 | { 437 | handle = FileOpen(_DataPath,FILE_READ|FILE_WRITE|FILE_TXT|FILE_ANSI); 438 | if (handle != INVALID_HANDLE) 439 | { 440 | ulong size = FileSize(handle); 441 | FileSeek(handle,size,SEEK_SET); 442 | _return = FileWrite(handle,text); 443 | FileClose(handle); 444 | } 445 | } 446 | return _return; 447 | } 448 | 449 | 450 | -------------------------------------------------------------------------------- /Include/ejtraderMT/Broker.mqh: -------------------------------------------------------------------------------- 1 | #property copyright "ejtrader" 2 | #property link "https://github.com/ejtraderLabs/MQL5-ejtraderMT" 3 | 4 | 5 | 6 | //+------------------------------------------------------------------+ 7 | //| Fetch positions information | 8 | //+------------------------------------------------------------------+ 9 | void GetPositions(CJAVal &dataObject) 10 | { 11 | CPositionInfo myposition; 12 | CJAVal data, position; 13 | 14 | // Get positions 15 | int positionsTotal=PositionsTotal(); 16 | // Create empty array if no positions 17 | if(!positionsTotal) 18 | data["positions"].Add(position); 19 | // Go through positions in a loop 20 | for(int i=0; i= 0) 204 | { 205 | if(CopyBuffer(indicators[idx].indicatorHandle, i, fromDate, 1, values) < 0) 206 | { 207 | if(mControl.mGetLastError()) 208 | { 209 | CJAVal message; 210 | int lastError = mControl.mGetLastError(); 211 | string desc = mControl.mGetDesc(); 212 | mControl.Check(); 213 | 214 | message["error"]=(bool) true; 215 | message["lastError"]=(string) lastError; 216 | message["description"]=desc; 217 | message["function"]=(string) __FUNCTION__; 218 | string t=message.Serialize(); 219 | if(debug) 220 | Print(t); 221 | InformClientSocket(indicatorDataSocket,t); 222 | } 223 | } 224 | results[i] = DoubleToString(values[0]); 225 | } 226 | } 227 | 228 | CJAVal message; 229 | message["error"]=(bool) false; 230 | message["id"] = (string) id; 231 | message["data"].Set(results); 232 | 233 | string t=message.Serialize(); 234 | if(debug) 235 | Print(t); 236 | InformClientSocket(indicatorDataSocket,t); 237 | 238 | } 239 | //+------------------------------------------------------------------+ 240 | -------------------------------------------------------------------------------- /Include/ejtraderMT/String.mqh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/MQL5-ejtraderMT/331006e5d2504cc8d20a826b3e9247803a18dcfb/Include/ejtraderMT/String.mqh -------------------------------------------------------------------------------- /Include/json.mqh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ejtraderLabs/MQL5-ejtraderMT/331006e5d2504cc8d20a826b3e9247803a18dcfb/Include/json.mqh -------------------------------------------------------------------------------- /Indicators/ejtraderMTIndicator.mq5: -------------------------------------------------------------------------------- 1 |  2 | #property copyright "2021 ejtrader" 3 | #property link "https://github.com/ejtraderLabs" 4 | #property version "1.00" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // Set ports and host for ZeroMQ 11 | string HOST="localhost"; 12 | int CHART_SUB_PORT=15562; 13 | 14 | // ZeroMQ Cnnections 15 | Context context("EJTRADERMT"); 16 | Socket chartSubscriptionSocket(context,ZMQ_SUB); 17 | 18 | //--- input parameters 19 | #property indicator_buffers 31 20 | #property indicator_plots 30 21 | 22 | input string IndicatorId=""; 23 | input string ShortName="ejtraderMTIndicator"; 24 | 25 | //--- indicator settings 26 | double B0[], B1[], B2[], B3[], B4[], B5[], B6[], B7[], B8[], B9[], B10[]; 27 | double B11[], B12[], B13[], B14[], B15[], B16[], B17[], B18[], B19[], B20[]; 28 | double B21[], B22[], B23[], B24[], B25[], B26[], B27[], B28[], B29[]; 29 | bool debug = false; 30 | int activeBufferCount = 0; 31 | long mtChartId = 0; 32 | bool setFormingCandleBlank = true; 33 | 34 | //+------------------------------------------------------------------+ 35 | //| Custom indicator initialization function | 36 | //+------------------------------------------------------------------+ 37 | int OnInit() 38 | 39 | { 40 | // TODO subscribe only to own IndicatorId topic 41 | // Subscribe to all topics 42 | chartSubscriptionSocket.setSubscribe(""); 43 | chartSubscriptionSocket.setLinger(1000); 44 | // https://www.randonomicon.com/zmq/2018/09/19/zmq-bind-vs-connect.html 45 | // Number of messages to buffer in RAM. 46 | // https://dzone.com/articles/zeromq-flow-control-and-other 47 | chartSubscriptionSocket.setReceiveHighWaterMark(1000); 48 | bool result = chartSubscriptionSocket.connect(StringFormat("tcp://%s:%d", HOST, CHART_SUB_PORT)); 49 | if(result == false) 50 | { 51 | Print("Failed to subscrbe on port ", CHART_SUB_PORT); 52 | } 53 | else 54 | { 55 | Print("Accepting Chart Indicator data on port ", CHART_SUB_PORT); 56 | } 57 | 58 | //--- indicator buffers mapping; 59 | ArraySetAsSeries(B0,true); 60 | ArraySetAsSeries(B1,true); 61 | ArraySetAsSeries(B2,true); 62 | ArraySetAsSeries(B3,true); 63 | ArraySetAsSeries(B4,true); 64 | ArraySetAsSeries(B5,true); 65 | ArraySetAsSeries(B6,true); 66 | ArraySetAsSeries(B7,true); 67 | ArraySetAsSeries(B8,true); 68 | ArraySetAsSeries(B9,true); 69 | ArraySetAsSeries(B10,true); 70 | ArraySetAsSeries(B11,true); 71 | ArraySetAsSeries(B12,true); 72 | ArraySetAsSeries(B13,true); 73 | ArraySetAsSeries(B14,true); 74 | ArraySetAsSeries(B15,true); 75 | ArraySetAsSeries(B16,true); 76 | ArraySetAsSeries(B17,true); 77 | ArraySetAsSeries(B18,true); 78 | ArraySetAsSeries(B19,true); 79 | ArraySetAsSeries(B20,true); 80 | ArraySetAsSeries(B21,true); 81 | ArraySetAsSeries(B22,true); 82 | ArraySetAsSeries(B23,true); 83 | ArraySetAsSeries(B24,true); 84 | ArraySetAsSeries(B25,true); 85 | ArraySetAsSeries(B26,true); 86 | ArraySetAsSeries(B27,true); 87 | ArraySetAsSeries(B28,true); 88 | ArraySetAsSeries(B29,true); 89 | 90 | SetIndexBuffer(0,B0,INDICATOR_CALCULATIONS); 91 | SetIndexBuffer(1,B1,INDICATOR_CALCULATIONS); 92 | SetIndexBuffer(2,B2,INDICATOR_CALCULATIONS); 93 | SetIndexBuffer(3,B3,INDICATOR_CALCULATIONS); 94 | SetIndexBuffer(4,B4,INDICATOR_CALCULATIONS); 95 | SetIndexBuffer(5,B5,INDICATOR_CALCULATIONS); 96 | SetIndexBuffer(6,B6,INDICATOR_CALCULATIONS); 97 | SetIndexBuffer(7,B7,INDICATOR_CALCULATIONS); 98 | SetIndexBuffer(8,B8,INDICATOR_CALCULATIONS); 99 | SetIndexBuffer(9,B9,INDICATOR_CALCULATIONS); 100 | SetIndexBuffer(10,B10,INDICATOR_CALCULATIONS); 101 | SetIndexBuffer(11,B11,INDICATOR_CALCULATIONS); 102 | SetIndexBuffer(12,B12,INDICATOR_CALCULATIONS); 103 | SetIndexBuffer(13,B13,INDICATOR_CALCULATIONS); 104 | SetIndexBuffer(14,B14,INDICATOR_CALCULATIONS); 105 | SetIndexBuffer(15,B15,INDICATOR_CALCULATIONS); 106 | SetIndexBuffer(16,B16,INDICATOR_CALCULATIONS); 107 | SetIndexBuffer(17,B17,INDICATOR_CALCULATIONS); 108 | SetIndexBuffer(18,B18,INDICATOR_CALCULATIONS); 109 | SetIndexBuffer(19,B19,INDICATOR_CALCULATIONS); 110 | SetIndexBuffer(20,B20,INDICATOR_CALCULATIONS); 111 | SetIndexBuffer(21,B21,INDICATOR_CALCULATIONS); 112 | SetIndexBuffer(22,B22,INDICATOR_CALCULATIONS); 113 | SetIndexBuffer(23,B23,INDICATOR_CALCULATIONS); 114 | SetIndexBuffer(24,B24,INDICATOR_CALCULATIONS); 115 | SetIndexBuffer(25,B25,INDICATOR_CALCULATIONS); 116 | SetIndexBuffer(26,B26,INDICATOR_CALCULATIONS); 117 | SetIndexBuffer(27,B27,INDICATOR_CALCULATIONS); 118 | SetIndexBuffer(28,B28,INDICATOR_CALCULATIONS); 119 | SetIndexBuffer(29,B29,INDICATOR_CALCULATIONS); 120 | 121 | //--- 122 | IndicatorSetString(INDICATOR_SHORTNAME,ShortName); 123 | 124 | return(INIT_SUCCEEDED); 125 | } 126 | 127 | //+------------------------------------------------------------------+ 128 | //| | 129 | //+------------------------------------------------------------------+ 130 | void OnDeinit(const int reason) 131 | { 132 | // Print("INDI DEINIT ",reason); 133 | } 134 | 135 | 136 | //+------------------------------------------------------------------+ 137 | //| | 138 | //+------------------------------------------------------------------+ 139 | void SetStyle(int bufferIdx, string linelabel, color colorstyle, int linetype, int linestyle, int linewidth) 140 | { 141 | PlotIndexSetString(bufferIdx,PLOT_LABEL,linelabel); 142 | PlotIndexSetInteger(bufferIdx,PLOT_LINE_COLOR,0,colorstyle); 143 | PlotIndexSetInteger(bufferIdx,PLOT_DRAW_TYPE,linetype); 144 | PlotIndexSetInteger(bufferIdx,PLOT_LINE_STYLE,linestyle); 145 | PlotIndexSetInteger(bufferIdx,PLOT_LINE_WIDTH,linewidth); 146 | } 147 | 148 | //+------------------------------------------------------------------+ 149 | //| Custom indicator iteration function | 150 | //+------------------------------------------------------------------+ 151 | int OnCalculate(const int rates_total, 152 | const int prev_calculated, 153 | const datetime &time[], 154 | const double &open[], 155 | const double &high[], 156 | const double &low[], 157 | const double &close[], 158 | const long &tick_volume[], 159 | const long &volume[], 160 | const int &spread[]) 161 | { 162 | 163 | // While a new candle is forming, set the current value to be empty 164 | 165 | 166 | if(rates_total>prev_calculated && setFormingCandleBlank) 167 | { 168 | B0[0] = EMPTY_VALUE; 169 | B1[0] = EMPTY_VALUE; 170 | B2[0] = EMPTY_VALUE; 171 | B3[0] = EMPTY_VALUE; 172 | B4[0] = EMPTY_VALUE; 173 | B5[0] = EMPTY_VALUE; 174 | B6[0] = EMPTY_VALUE; 175 | B7[0] = EMPTY_VALUE; 176 | B8[0] = EMPTY_VALUE; 177 | B9[0] = EMPTY_VALUE; 178 | B10[0] = EMPTY_VALUE; 179 | B11[0] = EMPTY_VALUE; 180 | B12[0] = EMPTY_VALUE; 181 | B13[0] = EMPTY_VALUE; 182 | B14[0] = EMPTY_VALUE; 183 | B15[0] = EMPTY_VALUE; 184 | B16[0] = EMPTY_VALUE; 185 | B17[0] = EMPTY_VALUE; 186 | B18[0] = EMPTY_VALUE; 187 | B19[0] = EMPTY_VALUE; 188 | B20[0] = EMPTY_VALUE; 189 | B21[0] = EMPTY_VALUE; 190 | B22[0] = EMPTY_VALUE; 191 | B23[0] = EMPTY_VALUE; 192 | B24[0] = EMPTY_VALUE; 193 | B25[0] = EMPTY_VALUE; 194 | B26[0] = EMPTY_VALUE; 195 | B27[0] = EMPTY_VALUE; 196 | B28[0] = EMPTY_VALUE; 197 | B29[0] = EMPTY_VALUE; 198 | } 199 | 200 | //--- return value of prev_calculated for next call 201 | return(rates_total); 202 | } 203 | 204 | //+------------------------------------------------------------------+ 205 | //| | 206 | //+------------------------------------------------------------------+ 207 | void SubscriptionHandler(ZmqMsg &chartMsg) 208 | { 209 | CJAVal message; 210 | // Get data from request 211 | string msg=chartMsg.getData(); 212 | if(debug) 213 | Print("Processing:"+msg); 214 | // Deserialize msg to CJAVal array 215 | if(!message.Deserialize(msg)) 216 | { 217 | Alert("Deserialization Error"); 218 | ExpertRemove(); 219 | } 220 | if(message["chartIndicatorId"]==IndicatorId) 221 | { 222 | 223 | if(message["action"]=="PLOT" && message["actionType"]=="DATA") 224 | { 225 | int bufferIdx = message["indicatorBufferId"].ToInt(); 226 | if(bufferIdx == 0) 227 | { 228 | WriteToBuffer(message, B0); 229 | SetIndexBuffer(0,B0,INDICATOR_DATA); 230 | } 231 | if(bufferIdx == 1) 232 | { 233 | WriteToBuffer(message, B1); 234 | SetIndexBuffer(1,B1,INDICATOR_DATA); 235 | } 236 | if(bufferIdx == 2) 237 | { 238 | WriteToBuffer(message, B2); 239 | SetIndexBuffer(2,B2,INDICATOR_DATA); 240 | } 241 | if(bufferIdx == 3) 242 | { 243 | WriteToBuffer(message, B3); 244 | SetIndexBuffer(3,B3,INDICATOR_DATA); 245 | } 246 | if(bufferIdx == 4) 247 | { 248 | WriteToBuffer(message, B4); 249 | SetIndexBuffer(4,B4,INDICATOR_DATA); 250 | } 251 | if(bufferIdx == 5) 252 | { 253 | WriteToBuffer(message, B5); 254 | SetIndexBuffer(5,B5,INDICATOR_DATA); 255 | } 256 | if(bufferIdx == 6) 257 | { 258 | WriteToBuffer(message, B6); 259 | SetIndexBuffer(6,B6,INDICATOR_DATA); 260 | } 261 | if(bufferIdx == 7) 262 | { 263 | WriteToBuffer(message, B7); 264 | SetIndexBuffer(7,B7,INDICATOR_DATA); 265 | } 266 | if(bufferIdx == 8) 267 | { 268 | WriteToBuffer(message, B8); 269 | SetIndexBuffer(8,B8,INDICATOR_DATA); 270 | } 271 | if(bufferIdx == 9) 272 | { 273 | WriteToBuffer(message, B9); 274 | SetIndexBuffer(9,B9,INDICATOR_DATA); 275 | } 276 | if(bufferIdx == 10) 277 | { 278 | WriteToBuffer(message, B10); 279 | SetIndexBuffer(10,B10,INDICATOR_DATA); 280 | } 281 | if(bufferIdx == 11) 282 | { 283 | WriteToBuffer(message, B11); 284 | SetIndexBuffer(11,B11,INDICATOR_DATA); 285 | } 286 | if(bufferIdx == 12) 287 | { 288 | WriteToBuffer(message, B12); 289 | SetIndexBuffer(12,B12,INDICATOR_DATA); 290 | } 291 | if(bufferIdx == 13) 292 | { 293 | WriteToBuffer(message, B13); 294 | SetIndexBuffer(13,B13,INDICATOR_DATA); 295 | } 296 | if(bufferIdx == 14) 297 | { 298 | WriteToBuffer(message, B14); 299 | SetIndexBuffer(14,B14,INDICATOR_DATA); 300 | } 301 | if(bufferIdx == 15) 302 | { 303 | WriteToBuffer(message, B15); 304 | SetIndexBuffer(15,B15,INDICATOR_DATA); 305 | } 306 | if(bufferIdx == 16) 307 | { 308 | WriteToBuffer(message, B16); 309 | SetIndexBuffer(16,B16,INDICATOR_DATA); 310 | } 311 | if(bufferIdx == 17) 312 | { 313 | WriteToBuffer(message, B17); 314 | SetIndexBuffer(17,B17,INDICATOR_DATA); 315 | } 316 | if(bufferIdx == 18) 317 | { 318 | WriteToBuffer(message, B18); 319 | SetIndexBuffer(18,B18,INDICATOR_DATA); 320 | } 321 | if(bufferIdx == 19) 322 | { 323 | WriteToBuffer(message, B19); 324 | SetIndexBuffer(19,B19,INDICATOR_DATA); 325 | } 326 | if(bufferIdx == 20) 327 | { 328 | WriteToBuffer(message, B20); 329 | SetIndexBuffer(20,B20,INDICATOR_DATA); 330 | } 331 | if(bufferIdx == 21) 332 | { 333 | WriteToBuffer(message, B21); 334 | SetIndexBuffer(21,B21,INDICATOR_DATA); 335 | } 336 | if(bufferIdx == 22) 337 | { 338 | WriteToBuffer(message, B22); 339 | SetIndexBuffer(22,B22,INDICATOR_DATA); 340 | } 341 | if(bufferIdx == 23) 342 | { 343 | WriteToBuffer(message, B23); 344 | SetIndexBuffer(23,B23,INDICATOR_DATA); 345 | } 346 | if(bufferIdx == 24) 347 | { 348 | WriteToBuffer(message, B24); 349 | SetIndexBuffer(24,B24,INDICATOR_DATA); 350 | } 351 | if(bufferIdx == 25) 352 | { 353 | WriteToBuffer(message, B25); 354 | SetIndexBuffer(25,B25,INDICATOR_DATA); 355 | } 356 | if(bufferIdx == 26) 357 | { 358 | WriteToBuffer(message, B26); 359 | SetIndexBuffer(26,B26,INDICATOR_DATA); 360 | } 361 | if(bufferIdx == 27) 362 | { 363 | WriteToBuffer(message, B27); 364 | SetIndexBuffer(27,B27,INDICATOR_DATA); 365 | } 366 | if(bufferIdx == 28) 367 | { 368 | WriteToBuffer(message, B28); 369 | SetIndexBuffer(28,B28,INDICATOR_DATA); 370 | } 371 | if(bufferIdx == 29) 372 | { 373 | WriteToBuffer(message, B29); 374 | SetIndexBuffer(29,B29,INDICATOR_DATA); 375 | } 376 | ChartRedraw(mtChartId); 377 | } 378 | else 379 | if(message["action"]=="PLOT" && message["actionType"]=="ADDBUFFER") 380 | { 381 | string linelabel = message["style"]["linelabel"].ToStr(); 382 | string colorstyleStr = message["style"]["color"].ToStr(); 383 | string linetypeStr = message["style"]["linetype"].ToStr(); 384 | string linestyleStr = message["style"]["linestyle"].ToStr(); 385 | int linewidth = message["style"]["linewidth"].ToInt(); 386 | setFormingCandleBlank = message["style"]["blankforming"].ToBool(); 387 | 388 | color colorstyle = StringToColor(colorstyleStr); 389 | int linetype = StringToEnumInt(linetypeStr); 390 | int linestyle = StringToEnumInt(linestyleStr); 391 | 392 | SetStyle(activeBufferCount, linelabel, colorstyle, linetype, linestyle, linewidth); 393 | activeBufferCount = activeBufferCount + 1; 394 | 395 | ClearBuffer(activeBufferCount-1); 396 | } 397 | } 398 | } 399 | 400 | //+------------------------------------------------------------------+ 401 | //| | 402 | //+------------------------------------------------------------------+ 403 | void Clear(double &buffer[]) 404 | { 405 | int bufferSize = ArraySize(buffer); 406 | for(int i=0; i= EMPTY_VALUE) 574 | val = EMPTY_VALUE; 575 | buffer[i+offset] = val; 576 | } 577 | } 578 | } 579 | 580 | 581 | //+------------------------------------------------------------------+ 582 | //| Check for new indicator data function | 583 | //+------------------------------------------------------------------+ 584 | void CheckMessages() 585 | { 586 | // This is a workaround for Timer(). It is needed, because OnTimer() works if the indicator is manually added to a chart, but not with ChartIndicatorAdd() 587 | 588 | ZmqMsg chartMsg; 589 | 590 | // Recieve chart instructions stream from client via live Chart socket. 591 | chartSubscriptionSocket.recv(chartMsg,true); 592 | 593 | // Request recieved 594 | if(chartMsg.size()>0) 595 | { 596 | // Handle subscription SubscriptionHandler() 597 | SubscriptionHandler(chartMsg); 598 | ChartRedraw(ChartID()); 599 | } 600 | } 601 | 602 | //+------------------------------------------------------------------+ 603 | //| OnTimer() workaround function | 604 | //+------------------------------------------------------------------+ 605 | // Gets triggered by the OnTimer() function of the JsonAPI Expert script 606 | void OnChartEvent(const int id, 607 | const long &lparam, 608 | const double &dparam, 609 | const string &sparam) 610 | { 611 | if(id==CHARTEVENT_CUSTOM+222) 612 | CheckMessages(); 613 | } 614 | //+---------------------------------------------------- 615 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ejtraderMT MQL5 Expert 2 | 3 | source code expert for Metatrader 5 to use with ejtraderMT -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | ### Marth 6th 2 | - fixed tick data retrival. When requesting tick data, every other tick was skipped 3 | - refactored code 4 | 5 | ### 30th April 2020 6 | 7 | - add support for spreads 8 | - add support for plotting custom indicator data to charts 9 | - add support for streaming MT5 indicator data 10 | - new error reporting 11 | 12 | ### 16th February 2020 13 | 14 | - add support for candle ask/bid price spread 15 | 16 | ### 11th January 2020 17 | 18 | - add support for multiple datastreams in parallel for any combination of symbols and timeframes independently of the timeframe and symbol of the attached chart 19 | - add support for tick data 20 | - add support for direct download as CSV files 21 | - add one automatic retry binding to sockets. When running under Wine in Linux, sockets will be blocked for 60 seconds if closed uncleanly. This can happen if the client is still connected while the EA gets reloaded. 22 | - skip re-initialization on chart timeframe change 23 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # https://www.commandlinefu.com/commands/view/11560/delete-all-non-printing-characters-from-a-file 4 | # http://www.skybert.net/bash/adding-utf-8-bom-from-the-command-line/ 5 | 6 | # Remove non-printable ASCII characters 7 | tr -cd '[:print:]\n\r' < ./Experts/JsonAPI.mq5 > ./Experts/JsonAPI.clean.mq5 8 | # Add UTF-8 BOM 9 | sed -i '1s/^/\xef\xbb\xbf/' ./Experts/JsonAPI.clean.mq5 10 | mv ./Experts/JsonAPI.clean.mq5 ./Experts/JsonAPI.mq5 11 | 12 | # Remove non-printable ASCII characters 13 | tr -cd '[:print:]\n\r' < ./Indicators/JsonAPIIndicator.mq5 > ./Indicators/JsonAPIIndicator.clean.mq5 14 | # Add UTF-8 BOM 15 | sed -i '1s/^/\xef\xbb\xbf/' ./Indicators/JsonAPIIndicator.clean.mq5 16 | mv ./Indicators/JsonAPIIndicator.clean.mq5 ./Indicators/JsonAPIIndicator.mq5 17 | 18 | # Remove non-printable ASCII characters 19 | tr -cd '[:print:]\n\r' < ./Include/StringToEnumInt.mqh > ./Include/StringToEnumInt.clean.mqh 20 | # Add UTF-8 BOM 21 | sed -i '1s/^/\xef\xbb\xbf/' ./Include/StringToEnumInt.clean.mqh 22 | mv ./Include/StringToEnumInt.clean.mqh ./Include/StringToEnumInt.mqh 23 | 24 | # Remove non-printable ASCII characters 25 | tr -cd '[:print:]\n\r' < ./Include/controlerrors.mqh > ./Include/controlerrors.clean.mqh 26 | # Add UTF-8 BOM 27 | sed -i '1s/^/\xef\xbb\xbf/' ./Include/controlerrors.clean.mqh 28 | mv ./Include/controlerrors.clean.mqh ./Include/controlerrors.mqh --------------------------------------------------------------------------------