MT4 Files

Check-in [2410064bd4]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added strcpy function
Timelines: family | ancestors | descendants | both | exec_order
Files: files | file ages | folders
SHA1:2410064bd46ccec6a62917e06531577c566d5c02
User & Date: onagano 2011-04-01 14:00:42
Context
2011-04-06
11:43
Sophisticated order execution logic check-in: cf04d307e8 user: onagano tags: exec_order
2011-04-01
14:00
Added strcpy function check-in: 2410064bd4 user: onagano tags: exec_order
12:55
Added order execution EA check-in: 111cc509ae user: onagano tags: exec_order
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to experts/MOB_executeOrder.mq4.

36
37
38
39
40
41
42

43
44
45
46
47
48
49
..
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76

77
78
79
80
81

82
83
84
85
86
87
88
...
146
147
148
149
150
151
152




153
154
155
156
157
158
159
...
313
314
315
316
317
318
319

320
321

322
323
324
325












326
327
328
329
330
331
332
333
334
335
336
337
338

339
340
341
342
343
344
345
346












347
348
349
350
351
352
353
int      mob_insertBar(int stmtId, datetime dt, double vals[]);
int      mob_copyRates(int stmtId, double rates[][6], int size, int start, int end);
double   mob_selectDouble(string sql, double defaultVal);
int      mob_selectInt(string sql, int defaultVal);
datetime mob_selectDatetime(string sql, datetime defaultVal);
int      checkMOBError(int rc);
datetime mob_time();

#import "stdlib.ex4"
string   ErrorDescription(int error_code);
#import

#define OPE_SEND     1
#define OPE_CLOSE    2
#define OPE_CLOSEBY  3
................................................................................
int    updateStmt = 0;

int ordId[1];
int ordOperation[1];
int ordTicket[1];
int ordOppositeTicket[1];
string ordSymbol = "1234567890";

int ordType[1];
double ordLots[1];
double ordOpenPrice[1];
double ordClosePrice[1];
int ordSlippage[1];
double ordStopLoss[1];
double ordTakeProfit[1];
string ordComment = "1234567890123456789012345678901234567890";

int ordMagicNumber[1];
datetime ordExpiration[1];
color ordArrowColor[1];
int ordErrorNumber[1];
string ordErrorMessage = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (!IsDllsAllowed()) {
................................................................................
   mob_bindStringParameter(updateStmt, 12, ordComment);
   mob_bindIntParameter(updateStmt, 13, ordMagicNumber);
   mob_bindDatetimeParameter(updateStmt, 14, ordExpiration);
   mob_bindIntParameter(updateStmt, 15, ordArrowColor);
   mob_bindIntParameter(updateStmt, 16, ordErrorNumber);
   mob_bindStringParameter(updateStmt, 17, ordErrorMessage);
   mob_bindIntParameter(updateStmt, 18, ordId);




//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
................................................................................
int updateOrder() {
   int rc = mob_executeStatement(updateStmt);
   return (rc);
}

void getServerResponse() {
   int err = GetLastError();

   ordErrorNumber[0] = err;
   ordErrorMessage = ErrorDescription(err);

   Print("#", err, ":", ordErrorMessage, "(", StringLen(ordErrorMessage), ")");
}

void orderSend() {












   int ticket = OrderSend(
      ordSymbol,
      ordType[0],
      ordLots[0],
      ordOpenPrice[0],
      ordSlippage[0],
      ordStopLoss[0],
      ordTakeProfit[0],
      ordComment,
      ordMagicNumber[0],
      ordExpiration[0],
      ordArrowColor[0]
      );

   if (ticket == -1) {
      getServerResponse();
   } else {
      ordTicket[0] = ticket;
   }
}

void orderClose() {












   if (OrderClose(
      ordTicket[0],
      ordLots[0],
      ordClosePrice[0],
      ordSlippage[0],
      ordArrowColor[0])) {
   } else {







>







 







>








>





>







 







>
>
>
>







 







>

<
>




>
>
>
>
>
>
>
>
>
>
>
>












|
>








>
>
>
>
>
>
>
>
>
>
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
...
321
322
323
324
325
326
327
328
329

330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
int      mob_insertBar(int stmtId, datetime dt, double vals[]);
int      mob_copyRates(int stmtId, double rates[][6], int size, int start, int end);
double   mob_selectDouble(string sql, double defaultVal);
int      mob_selectInt(string sql, int defaultVal);
datetime mob_selectDatetime(string sql, datetime defaultVal);
int      checkMOBError(int rc);
datetime mob_time();
int      mob_strcpy(string dest, int size, string src);
#import "stdlib.ex4"
string   ErrorDescription(int error_code);
#import

#define OPE_SEND     1
#define OPE_CLOSE    2
#define OPE_CLOSEBY  3
................................................................................
int    updateStmt = 0;

int ordId[1];
int ordOperation[1];
int ordTicket[1];
int ordOppositeTicket[1];
string ordSymbol = "1234567890";
int    ordSymbolSize;
int ordType[1];
double ordLots[1];
double ordOpenPrice[1];
double ordClosePrice[1];
int ordSlippage[1];
double ordStopLoss[1];
double ordTakeProfit[1];
string ordComment = "1234567890123456789012345678901234567890";
int    ordCommentSize;
int ordMagicNumber[1];
datetime ordExpiration[1];
color ordArrowColor[1];
int ordErrorNumber[1];
string ordErrorMessage = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
int    ordErrorMessageSize;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (!IsDllsAllowed()) {
................................................................................
   mob_bindStringParameter(updateStmt, 12, ordComment);
   mob_bindIntParameter(updateStmt, 13, ordMagicNumber);
   mob_bindDatetimeParameter(updateStmt, 14, ordExpiration);
   mob_bindIntParameter(updateStmt, 15, ordArrowColor);
   mob_bindIntParameter(updateStmt, 16, ordErrorNumber);
   mob_bindStringParameter(updateStmt, 17, ordErrorMessage);
   mob_bindIntParameter(updateStmt, 18, ordId);
   
   ordSymbolSize = StringLen(ordSymbol);
   ordCommentSize = StringLen(ordComment);
   ordErrorMessageSize = StringLen(ordErrorMessage);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
................................................................................
int updateOrder() {
   int rc = mob_executeStatement(updateStmt);
   return (rc);
}

void getServerResponse() {
   int err = GetLastError();
   string errMesg = ErrorDescription(err);
   ordErrorNumber[0] = err;

   mob_strcpy(ordErrorMessage, ordErrorMessageSize, errMesg);
   Print("#", err, ":", ordErrorMessage, "(", StringLen(ordErrorMessage), ")");
}

void orderSend() {
   if (ordOpenPrice[0] == 0.0) {
      RefreshRates();
      switch (ordType[0]) {
      case OP_BUY:
         ordOpenPrice[0] = Ask;
         break;
      case OP_SELL:
         ordOpenPrice[0] = Bid;
         break;
      }
   }
   
   int ticket = OrderSend(
      ordSymbol,
      ordType[0],
      ordLots[0],
      ordOpenPrice[0],
      ordSlippage[0],
      ordStopLoss[0],
      ordTakeProfit[0],
      ordComment,
      ordMagicNumber[0],
      ordExpiration[0],
      ordArrowColor[0]
   );
   
   if (ticket == -1) {
      getServerResponse();
   } else {
      ordTicket[0] = ticket;
   }
}

void orderClose() {
   if (ordClosePrice[0] == 0.0) {
      RefreshRates();
      switch (ordType[0]) {
      case OP_BUY:
         ordOpenPrice[0] = Bid;
         break;
      case OP_SELL:
         ordOpenPrice[0] = Ask;
         break;
      }
   }
   
   if (OrderClose(
      ordTicket[0],
      ordLots[0],
      ordClosePrice[0],
      ordSlippage[0],
      ordArrowColor[0])) {
   } else {

Changes to experts/libraries/mt4odbcbridge.mq4.

46
47
48
49
50
51
52

53
54
55
56
57
58
59
...
191
192
193
194
195
196
197





198
199
200
201
202
203
204
int      MOB_insertTick(int conId, int stmtId, datetime dt, int fraction, double vals[], int size);
int      MOB_insertBar(int conId, int stmtId, datetime dt, double vals[], int size);
int      MOB_copyRates(int conId, int stmtId, double rates[][6], int size, int start, int end);
double   MOB_selectDouble(int conId, string sql, double defaultVal);
int      MOB_selectInt(int conId, string sql, int defaultVal);
datetime MOB_selectDatetime(int conId, string sql, datetime defaultVal);
datetime MOB_time();

#import

//+------------------------------------------------------------------+
//| EX4 imports                                                      |
//+------------------------------------------------------------------+
#import "stdlib.ex4"
   string ErrorDescription(int error_code);
................................................................................
datetime mob_selectDatetime(string sql, datetime defaultVal) {
   return (MOB_selectDatetime(mob_conId, sql, defaultVal));
}

datetime mob_time() {
   return (MOB_time());
}






//+------------------------------------------------------------------+
//| Stateful helper functions                                        |
//+------------------------------------------------------------------+
int checkMOBError(int rc, bool rollback = false, bool disconnect = false) {
   if (rc < 0) {
      int eno = mob_getLastErrorNo();







>







 







>
>
>
>
>







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
...
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
int      MOB_insertTick(int conId, int stmtId, datetime dt, int fraction, double vals[], int size);
int      MOB_insertBar(int conId, int stmtId, datetime dt, double vals[], int size);
int      MOB_copyRates(int conId, int stmtId, double rates[][6], int size, int start, int end);
double   MOB_selectDouble(int conId, string sql, double defaultVal);
int      MOB_selectInt(int conId, string sql, int defaultVal);
datetime MOB_selectDatetime(int conId, string sql, datetime defaultVal);
datetime MOB_time();
int      MOB_strcpy(string dest, int size, string src);
#import

//+------------------------------------------------------------------+
//| EX4 imports                                                      |
//+------------------------------------------------------------------+
#import "stdlib.ex4"
   string ErrorDescription(int error_code);
................................................................................
datetime mob_selectDatetime(string sql, datetime defaultVal) {
   return (MOB_selectDatetime(mob_conId, sql, defaultVal));
}

datetime mob_time() {
   return (MOB_time());
}

int mob_strcpy(string dest, int size, string src) {
   return (MOB_strcpy(dest, size, src));
}


//+------------------------------------------------------------------+
//| Stateful helper functions                                        |
//+------------------------------------------------------------------+
int checkMOBError(int rc, bool rollback = false, bool disconnect = false) {
   if (rc < 0) {
      int eno = mob_getLastErrorNo();