Selaa lähdekoodia

Ticket: 5083 Unused code removed

Huzaifa-MQLDev 4 kuukautta sitten
vanhempi
commit
0d4aad36b9
2 muutettua tiedostoa jossa 13 lisäystä ja 140 poistoa
  1. BIN
      blTelegramToMT4.ex4
  2. 13 140
      blTelegramToMT4.mq4

BIN
blTelegramToMT4.ex4


+ 13 - 140
blTelegramToMT4.mq4

@@ -23,28 +23,6 @@ struct msgDetails
23 23
 
24 24
 msgDetails od[MaxOrders];
25 25
 
26
-struct new_trade_store
27
-  {
28
-   ulong             ticket;         // Ticket
29
-   int               order_type;     // OrderType
30
-   double            lot;            // Lot
31
-   double            stop_loss;      // StopLoss
32
-   double            take_profit;    // TakeProfit
33
-   double            price;          // Price
34
-   string            symbol;         // Symbol
35
-   int               chatId;         // ChatId
36
-   string            trade_type;     // Trade Type (Trade Type: Tp1, Tp2, Tp3.... Tpn)
37
-
38
-                     new_trade_store()
39
-     {
40
-      ticket = -1;
41
-      chatId=-1;
42
-      trade_type = "";
43
-     }
44
-
45
-  };
46
-new_trade_store newTradeStore[MaxOrders];
47
-
48 26
 input       string               Settings              = " ------------- General Settings ------------- ";   //_
49 27
 input       int                  magic_no              = 333;                                                // Magic no
50 28
 input       string               symbolMatch           = "GOLD:XAUUSD,BitCoin:BTCUSD";                       // Symbol Mapping (Telegram:MT5)
@@ -59,20 +37,15 @@ input       double               lotSize               = 0.1;
59 37
 string      url1      = "http://127.0.0.1";
60 38
 string      header    = "Content-Type: application/json\r\nAccept: application/json\r\n";
61 39
 
62
-int getme_result;
63
-
64 40
 string symbolChart[];
65 41
 string symbolSnd[];
66 42
 string symbolsListUserInput[];
67 43
 uchar  sym1[];
68 44
 uchar  sym2[];
69
-datetime ea_start_time = 0;
70 45
 int last_message_id = INT_MIN;
71 46
 int OnInit()
72 47
   {
73 48
 //--- create timer
74
-   ea_start_time = TimeCurrent();
75
-
76 49
    ushort u_sep = StringGetCharacter(",",0);
77 50
    StringSplit(symbolMatch,u_sep,symbolsListUserInput);
78 51
    ArrayResize(symbolChart,0);
@@ -218,31 +191,6 @@ string  GET_function(string url,string headers)
218 191
 //+------------------------------------------------------------------+
219 192
 //|                                                                  |
220 193
 //+------------------------------------------------------------------+
221
-void seperatingDataOnint(int index, string data)
222
-  {
223
-
224
-   string message = getJsonStringValue(data,"message",4,"\"");
225
-   int message_id = (int)getJsonStringValue(data,"message_id",4,"\"");
226
-
227
-   if(checkExistingTrade(message_id) == false)
228
-     {
229
-      Print(" ================ OnInit New Trade Message Found ================");
230
-      StringReplace(message,"~","#");
231
-      StringToLower(message);
232
-      Print("Message is ", message);
233
-      for(int i=0; i < MaxOrders; i++)
234
-        {
235
-         if(od[i].msgid == -1)
236
-           {
237
-            od[i].msgid = message_id;
238
-            break;
239
-           }
240
-        }
241
-     }
242
-  }
243
-//+------------------------------------------------------------------+
244
-//|                                                                  |
245
-//+------------------------------------------------------------------+
246 194
 bool checkExistingTrade(int message_id)
247 195
   {
248 196
    for(int i=0; i < MaxOrders; i++)
@@ -302,73 +250,6 @@ string trim(string text)
302 250
 //+------------------------------------------------------------------+
303 251
 //|                                                                  |
304 252
 //+------------------------------------------------------------------+
305
-void seperatingData(int index, string data)
306
-  {
307
-// Print(" Data: ", data);
308
-   string message = getJsonStringValue(data,"message",4,"\"");
309
-   int message_id = (int)getJsonStringValue(data,"message_id",4,"\"");
310
-
311
-   string isReplyValue = getJsonStringValue(data,"is_reply",4,"\"");
312
-   int reply_to_msg_id = (int)getJsonStringValue(data,"reply_to_msg_id",4,"\"");
313
-
314
-   if(isReplyValue == "False")
315
-     {
316
-      if(checkExistingTrade(message_id) == false)
317
-        {
318
-         Print(" --------------- New Trade Message Found ----------------- ", " Message Id: ", message_id);
319
-         StringReplace(message,"~","#");
320
-         StringReplace(message,"##", "#");
321
-         StringToLower(message);
322
-         message = removeExtraSpaces(message);
323
-         Print("Message is ",message);
324
-         addtoMessageStructure(message_id,message);
325
-
326
-         string result[];
327
-         string tempResult[];
328
-         int indexTemp = 0;
329
-
330
-         StringSplit(message,'#',tempResult);
331
-
332
-         for(int i=0; i<ArraySize(tempResult); i++)
333
-           {
334
-            //result[i] = StringTrimLeft(result[i]);
335
-            //result[i] = StringTrimRight(result[i]);
336
-            //Print("Temp Result : ", tempResult[i], " index is: ", i);
337
-            if(HasAlphanumeric(tempResult[i]))
338
-              {
339
-               //Print(" contains alphanumeric characters.");
340
-               ArrayResize(result,ArraySize(result)+1);
341
-               result[indexTemp] = tempResult[i];
342
-               indexTemp++;
343
-              }
344
-            else
345
-              {
346
-               //Print(" does not contain alphanumeric characters.");
347
-               //ArrayResize(indexToDelete,ArraySize(indexToDelete)+1);
348
-               //indexToDelete[indexTemp] = i;
349
-               //indexTemp++;
350
-              }
351
-           }
352
-
353
-         message(result,message,message_id);
354
-
355
-        }
356
-     }
357
-
358
-   if(isReplyValue == "True")
359
-     {
360
-      if(checkExistingTrade(message_id) == false)
361
-        {
362
-         Print(" --------------- New Replied Message Found ----------------- ", " Message Id: ", message_id, " Reply Message Id: ", reply_to_msg_id);
363
-         StringToLower(message);
364
-         Print("Message is ",message);
365
-         addtoMessageStructure(message_id,message);
366
-        }
367
-     }
368
-  }
369
-//+------------------------------------------------------------------+
370
-//|                                                                  |
371
-//+------------------------------------------------------------------+
372 253
 void execute_functionality_on_new_message(int i)
373 254
   {
374 255
 
@@ -500,8 +381,7 @@ void message(string &result[], string message, int message_id)
500 381
          symbol = symbolMapping(symbol);
501 382
 
502 383
          double sl = 0;
503
-         double tpStore[]; // = result[0];
504
-         int tpIndex = 0;
384
+         double tp = 0; // = result[0];
505 385
          for(int i=0 ; i < ArraySize(result); i++)
506 386
            {
507 387
             // result[i] = StringTrimLeft(result[i]);
@@ -512,7 +392,7 @@ void message(string &result[], string message, int message_id)
512 392
                string tempSl[];
513 393
                result[i] = trimString(result[i]);
514 394
                //Print(" Sl String: ", result[i]);
515
-               StringSplit(result[i], ' ', tempSl);
395
+               StringSplit(result[i], ':', tempSl);
516 396
                if(ArraySize(tempSl) >= 2)
517 397
                   sl = (double) tempSl[1];
518 398
                Print("Sl : ", sl);
@@ -522,31 +402,24 @@ void message(string &result[], string message, int message_id)
522 402
                // Print("Tp : ", result[i], " index is: ", i);
523 403
                string tempTp[];
524 404
                result[i] = trimString(result[i]);
525
-               StringSplit(result[i], ' ', tempTp);
405
+               StringSplit(result[i], ':', tempTp);
526 406
                //double tp = (double) tempTp[1];
527
-
528
-               ArrayResize(tpStore,ArraySize(tpStore)+1);
529 407
                if(ArraySize(tempTp) >= 2)
530
-                  tpStore[tpIndex] = (double) tempTp[1];
531
-               Print("Tp : ", tpStore[tpIndex]);
532
-               tpIndex++;
408
+                  tp = (double) tempTp[1];
409
+               Print("Tp : ", tp);
533 410
               }
534 411
            }
535
-         Print("Side:", direction, " Symbol: ", symbol, " Tp Array Size: ", ArraySize(tpStore), " Message Id: ", message_id);
536
-         for(int i = 0 ; i < ArraySize(tpStore) ; i++)
537
-           {
538
-            Print("Side:", direction, " Symbol: ", symbol, " Tp: ", tpStore[i], " Sl: ", sl, " Message Id: ", message_id);
539
-            if(direction == buy)
540
-              {
541
-               placeBuyTrade(symbol, tpStore[i], sl, message_id, lotSize);
542
-              }
412
+         Print("Side:", direction, " Symbol: ", symbol, " Tp: ", tp, " Sl: ", sl, " Message Id: ", message_id);
543 413
 
544
-            if(direction == sell)
545
-              {
546
-               placeSellTrade(symbol, tpStore[i], sl, message_id, lotSize);
547
-              }
414
+         if(direction == buy)
415
+           {
416
+            placeBuyTrade(symbol, tp, sl, message_id, lotSize);
548 417
            }
549 418
 
419
+         if(direction == sell)
420
+           {
421
+            placeSellTrade(symbol, tp, sl, message_id, lotSize);
422
+           }
550 423
         }
551 424
      }
552 425
   }