Keine Beschreibung

blTelegramToMT4.mq4 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. //+------------------------------------------------------------------+
  2. //| blTelegramToMT4.mq4 |
  3. //| Copyright 2025, MQL Development |
  4. //| https://www.mqldevelopment.com/ |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright 2025, MQL Development"
  7. #property link "https://www.mqldevelopment.com/"
  8. #property version "1.1"
  9. #property strict
  10. #define buy "buy"
  11. #define sell "sell"
  12. #define MaxOrders 10000
  13. struct msgDetails
  14. {
  15. int msgid;
  16. ulong tickt;
  17. msgDetails()
  18. {
  19. msgid = -1;
  20. tickt = -1;
  21. }
  22. };
  23. msgDetails od[MaxOrders];
  24. input string Settings = " ------------- General Settings ------------- "; //_
  25. input int magic_no = 333; // Magic no
  26. input string symbolMatch = "GOLD:XAUUSD,BitCoin:BTCUSD"; // Symbol Mapping (Telegram:MT4)
  27. input string suffix = ""; // Account Suffix
  28. input string prefix = ""; // Account Prefix
  29. input double lotSize = 0.1; // Lot Size
  30. input double partialClose = 20; // Partial Closing %
  31. //+------------------------------------------------------------------+
  32. //| Expert initialization function |
  33. //+------------------------------------------------------------------+
  34. // Global Variables
  35. string url1 = "http://127.0.0.1"; // "http://myapp.local";
  36. string header = "Content-Type: application/json\r\nAccept: application/json\r\n";
  37. string symbolChart[];
  38. string symbolSnd[];
  39. string symbolsListUserInput[];
  40. uchar sym1[];
  41. uchar sym2[];
  42. int last_message_id = INT_MIN;
  43. int OnInit()
  44. {
  45. //--- create timer
  46. ushort u_sep = StringGetCharacter(",",0);
  47. StringSplit(symbolMatch,u_sep,symbolsListUserInput);
  48. ArrayResize(symbolChart,0);
  49. ArrayResize(symbolSnd,0);
  50. for(int i = 0; i < ArraySize(symbolsListUserInput); i++)
  51. {
  52. string str = symbolsListUserInput[i];
  53. int index = StringFind(str,":");
  54. int index2 = StringLen(str);
  55. ArrayResize(sym1,0);
  56. ArrayResize(sym2,0);
  57. for(int j = 0; j < index; j++)
  58. {
  59. ArrayResize(sym1,ArraySize(sym1)+1);
  60. sym1[j] = uchar(str[j]);
  61. }
  62. int k = 0;
  63. for(int j = index + 1 ; j < index2; j++)
  64. {
  65. ArrayResize(sym2,ArraySize(sym2)+1);
  66. sym2[k] = uchar(str[j]);
  67. k++;
  68. }
  69. ArrayResize(symbolChart,ArraySize(symbolChart)+1);
  70. ArrayResize(symbolSnd,ArraySize(symbolSnd)+1);
  71. symbolChart[i] = CharArrayToString(sym1);
  72. symbolSnd[i] = CharArrayToString(sym2);
  73. }
  74. string jsonString = GET_function(url1 + "/get-latest-message-id", header);
  75. StringReplace(jsonString,"},", "*");
  76. last_message_id = (int)getJsonStringValue(jsonString, "id") != 0 ? (int)getJsonStringValue(jsonString, "id") : INT_MIN;
  77. string message = getJsonStringValue(jsonString, "message");
  78. if(last_message_id != INT_MIN)
  79. {
  80. Print(" latest_message_id = ",last_message_id);
  81. Print(" result found against get-latest-message-id = ",message);
  82. }
  83. EventSetTimer(1);
  84. //---
  85. return(INIT_SUCCEEDED);
  86. }
  87. //+------------------------------------------------------------------+
  88. //| Expert deinitialization function |
  89. //+------------------------------------------------------------------+
  90. void OnDeinit(const int reason)
  91. {
  92. //--- destroy timer
  93. EventKillTimer();
  94. }
  95. //+------------------------------------------------------------------+
  96. //| Expert tick function |
  97. //+------------------------------------------------------------------+
  98. void OnTick()
  99. {
  100. //---
  101. }
  102. //+------------------------------------------------------------------+
  103. //| Timer function |
  104. //+------------------------------------------------------------------+
  105. void OnTimer()
  106. {
  107. //---
  108. if(last_message_id == INT_MIN)
  109. {
  110. string jsonString = GET_function(url1 + "/get-latest-message-id", header);
  111. StringReplace(jsonString,"},", "*");
  112. last_message_id = (int)getJsonStringValue(jsonString, "id") != 0 ? (int)getJsonStringValue(jsonString, "id") : INT_MIN;
  113. if(last_message_id != INT_MIN)
  114. {
  115. string message = getJsonStringValue(jsonString, "message");
  116. if(last_message_id != INT_MIN)
  117. {
  118. Print(" latest_message_id = ",last_message_id);
  119. Print(" result found against get-latest-message-id = ",message);
  120. }
  121. execute_functionality_on_new_message(last_message_id);
  122. }
  123. }
  124. else
  125. {
  126. string jsonString = GET_function(url1 + "/get-latest-message-id", header);
  127. StringReplace(jsonString,"},", "*");
  128. int latest_message_id = (int)getJsonStringValue(jsonString, "id") != 0 ? (int)getJsonStringValue(jsonString, "id") : INT_MIN;
  129. if(last_message_id != latest_message_id)
  130. {
  131. for(int i = latest_message_id; i > last_message_id; i--)
  132. {
  133. execute_functionality_on_new_message(i);
  134. }
  135. last_message_id = latest_message_id;
  136. }
  137. }
  138. }
  139. //+------------------------------------------------------------------+
  140. //| |
  141. //+------------------------------------------------------------------+
  142. string GET_function(string url,string headers)
  143. {
  144. string result_string = NULL;
  145. int timeout = 10; // Set the timeout value in seconds
  146. char result[],data[];
  147. string resultHeaders;
  148. int res = WebRequest("GET",url,headers,timeout,data,result,resultHeaders);
  149. if(res == 200)
  150. {
  151. result_string = CharArrayToString(result);
  152. }
  153. else
  154. {
  155. Print("content GETT: ", result_string," Error: ",GetLastError(), " res: ",res);
  156. }
  157. return result_string;
  158. }
  159. //+------------------------------------------------------------------+
  160. //| |
  161. //+------------------------------------------------------------------+
  162. bool checkExistingTrade(int message_id)
  163. {
  164. for(int i=0; i < MaxOrders; i++)
  165. {
  166. if(od[i].msgid == message_id)
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. //+------------------------------------------------------------------+
  174. //| |
  175. //+------------------------------------------------------------------+
  176. string getJsonStringValue(string json,string key,int addUp,string endSign)
  177. {
  178. int indexStart = StringFind(json,key)+StringLen(key)+addUp;
  179. int indexEnd = StringFind(json,endSign,indexStart);
  180. return StringSubstr(json,indexStart,indexEnd-indexStart);
  181. }
  182. //+------------------------------------------------------------------+
  183. //| |
  184. //+------------------------------------------------------------------+
  185. string getJsonStringValue(string json, string key)
  186. {
  187. int start = StringFind(json, "\""+key+"\"");
  188. if(start == -1)
  189. return "";
  190. // Find colon after key
  191. int colon = StringFind(json, ":", start);
  192. if(colon == -1)
  193. return "";
  194. // Find next comma or closing brace
  195. int endComma = StringFind(json, ",", colon);
  196. int endBrace = StringFind(json, "}", colon);
  197. int end = (endComma != -1 && (endComma < endBrace || endBrace == -1)) ? endComma : endBrace;
  198. if(end == -1)
  199. end = StringLen(json);
  200. string value = trim(StringSubstr(json, colon+1, end-colon-1));
  201. // remove quotes if exist
  202. StringReplace(value, "\"", "");
  203. return value;
  204. }
  205. //+------------------------------------------------------------------+
  206. //| |
  207. //+------------------------------------------------------------------+
  208. string trim(string text)
  209. {
  210. StringTrimLeft(text);
  211. StringTrimRight(text);
  212. return text;
  213. }
  214. //+------------------------------------------------------------------+
  215. //| |
  216. //+------------------------------------------------------------------+
  217. void execute_functionality_on_new_message(int i)
  218. {
  219. string url = url1 + "/get-message/" + IntegerToString(i);
  220. string jsonString = GET_function(url, header);
  221. StringReplace(jsonString,"},", "*");
  222. string message = getJsonStringValue(jsonString,"message",4,"\"");
  223. int group_message_id = (int)getJsonStringValue(jsonString, "message_id");
  224. StringToLower(message);
  225. StringReplace(message,"~","#");
  226. if(checkExistingTrade(group_message_id) == false)
  227. {
  228. string isReplyValue = getJsonStringValue(jsonString, "is_reply");
  229. StringReplace(isReplyValue," ","");
  230. if(isReplyValue == "True")
  231. {
  232. int reply_to_msg_id = (int)getJsonStringValue(jsonString, "reply_to_msg_id");
  233. message = getJsonStringValue(jsonString, "message");
  234. StringToLower(message);
  235. Print(" ================ Replied Message found of message_id ================ ",reply_to_msg_id);
  236. Print(" ================ Message: ================ ",message);
  237. int ticket = getTicket(reply_to_msg_id);
  238. if(ticket != -1)
  239. {
  240. if(StringFind(message,"set") != -1 && StringFind(message,"stop") != -1 && StringFind(message,"loss") != -1 && StringFind(message,"entry") != -1)
  241. {
  242. if(OrderSelect(ticket,SELECT_BY_TICKET))
  243. {
  244. bool result = OrderModify(ticket,OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,clrNONE);
  245. if(result)
  246. {
  247. Print("Order Sl Modify to Open Price ", ticket);
  248. }
  249. else
  250. {
  251. Print("Error in Modify order SL : ", GetLastError()," Setting SL at: ",OrderOpenPrice()," price: ",OrderClosePrice());
  252. }
  253. }
  254. }
  255. if(StringFind(message,"take") != -1 && StringFind(message,"some") != -1 && StringFind(message,"partial") != -1 && StringFind(message,"profit") != -1)
  256. {
  257. if(OrderSelect(ticket,SELECT_BY_TICKET))
  258. {
  259. double lot = NormalizeDouble(OrderLots()*(partialClose/100),2);
  260. bool result = OrderClose(ticket,lot,OrderClosePrice(),10, clrNONE);
  261. if(result)
  262. {
  263. Print("Partially closed ", lot, " lots from order ", ticket);
  264. for(int j = OrdersTotal()-1; j>=0; j--)
  265. {
  266. if(OrderSelect(j, SELECT_BY_POS))
  267. {
  268. if(OrderComment() != "")
  269. {
  270. string ticketToBeReplace = OrderComment();
  271. StringReplace(ticketToBeReplace,"from #","");
  272. if(int(ticketToBeReplace) == ticket)
  273. {
  274. findAndreplaceTicketFromStructure(OrderTicket(),reply_to_msg_id);
  275. }
  276. }
  277. }
  278. }
  279. }
  280. else
  281. {
  282. Print("Error closing partial order: ", GetLastError()," lot = ",lot," OrderLots() = ",OrderLots());
  283. }
  284. }
  285. }
  286. }
  287. }
  288. else
  289. {
  290. if(checkExistingTrade(group_message_id) == false)
  291. {
  292. Print(" --------------- New Trade Message Found ----------------- ", " Message Id: ", group_message_id);
  293. StringReplace(message,"~","#");
  294. StringReplace(message,"##", "#");
  295. StringToLower(message);
  296. message = removeExtraSpaces(message);
  297. Print("Message is ",message);
  298. string result[];
  299. string tempResult[];
  300. int indexTemp = 0;
  301. StringSplit(message,'#',tempResult);
  302. for(int j=0; j<ArraySize(tempResult); j++)
  303. {
  304. //result[i] = StringTrimLeft(result[i]);
  305. //result[i] = StringTrimRight(result[i]);
  306. //Print("Temp Result : ", tempResult[i], " index is: ", i);
  307. if(HasAlphanumeric(tempResult[j]))
  308. {
  309. //Print(" contains alphanumeric characters.");
  310. ArrayResize(result,ArraySize(result)+1);
  311. result[indexTemp] = tempResult[j];
  312. indexTemp++;
  313. }
  314. else
  315. {
  316. //Print(" does not contain alphanumeric characters.");
  317. //ArrayResize(indexToDelete,ArraySize(indexToDelete)+1);
  318. //indexToDelete[indexTemp] = i;
  319. //indexTemp++;
  320. }
  321. }
  322. int ticket = -1;
  323. message(result,message,group_message_id,ticket);
  324. addtoMessageStructure(group_message_id,message,ticket);
  325. }
  326. }
  327. }
  328. }
  329. //+------------------------------------------------------------------+
  330. //| |
  331. //+------------------------------------------------------------------+
  332. void findAndreplaceTicketFromStructure(int ticketToBeReplace,int reply_to_msg_id)
  333. {
  334. for(int i=0; i < MaxOrders; i++)
  335. {
  336. if(od[i].msgid == reply_to_msg_id)
  337. {
  338. od[i].tickt = ticketToBeReplace;
  339. Print("codeOrder is partially closed so update Ticket ",ticketToBeReplace);
  340. break;
  341. }
  342. }
  343. }
  344. //+------------------------------------------------------------------+
  345. //| |
  346. //+------------------------------------------------------------------+
  347. int getTicket(int reply_to_msg_id)
  348. {
  349. for(int i=0; i < MaxOrders; i++)
  350. {
  351. if(od[i].msgid == reply_to_msg_id)
  352. {
  353. return int(od[i].tickt);
  354. }
  355. }
  356. return -1;
  357. }
  358. //+------------------------------------------------------------------+
  359. //| |
  360. //+------------------------------------------------------------------+
  361. void message(string &result[], string message, int message_id,int & tickt)
  362. {
  363. string lineOne[]; // = result[0];
  364. int lineIndex = 0;
  365. string direction = "";
  366. int direction_index = -1;
  367. string symbol = "";
  368. if(ArraySize(result) >= 1)
  369. {
  370. StringSplit(result[0], ' ', lineOne);
  371. if(((StringFind(result[0], "buy", 0) != -1) || (StringFind(result[0], "sell", 0) != -1)))
  372. {
  373. for(int i=0; i<ArraySize(lineOne); i++)
  374. {
  375. if(HasAlphanumeric(lineOne[i]))
  376. {
  377. ArrayResize(lineOne,ArraySize(lineOne)+1);
  378. lineOne[lineIndex] = lineOne[i];
  379. Print("Direction and Symbol: ", lineOne[lineIndex], " index is: ", lineIndex);
  380. if(lineOne[lineIndex] == buy || lineOne[lineIndex] == sell)
  381. {
  382. direction = lineOne[lineIndex];
  383. direction_index = lineIndex;
  384. //Print(" Direction is: ", direction, " Direction Index: ", direction_index);
  385. }
  386. lineIndex++;
  387. }
  388. }
  389. if(ArraySize(lineOne) >= 2)
  390. {
  391. if(direction_index == 0)
  392. {
  393. symbol = lineOne[1];
  394. StringToUpper(symbol);
  395. //Print(" This is Message format One (1). Where Direction is: ", direction, " Symbol: ", symbol);
  396. }
  397. else
  398. if(direction_index > 0)
  399. {
  400. symbol = lineOne[0];
  401. StringToUpper(symbol);
  402. //Print(" This is Message format One (1). Where Direction is: ", direction, " Symbol: ", symbol);
  403. }
  404. }
  405. symbol = symbolMapping(symbol);
  406. double sl = 0;
  407. double tp = 0; // = result[0];
  408. for(int i=0 ; i < ArraySize(result); i++)
  409. {
  410. // result[i] = StringTrimLeft(result[i]);
  411. // result[i] = StringTrimRight(result[i]);
  412. // Print("Result : ", result[i], " index is: ", i);
  413. if((StringFind(result[i], "sl", 0) != -1))
  414. {
  415. string tempSl[];
  416. StringReplace(result[i],":", " ");
  417. result[i] = trimString(result[i]);
  418. result[i] = spaceRemove(result[i]);
  419. //Print(" Sl String: ", result[i]);
  420. StringSplit(result[i], ' ', tempSl);
  421. if(ArraySize(tempSl) >= 2)
  422. sl = (double) tempSl[1];
  423. Print("Sl : ", sl);
  424. }
  425. if((StringFind(result[i], "tp", 0) != -1))
  426. {
  427. Print("Tp : ", result[i], " index is: ", i);
  428. string tempTp[];
  429. StringReplace(result[i],":", " ");
  430. result[i] = trimString(result[i]);
  431. result[i] = spaceRemove(result[i]);
  432. Print("Tp After String Replace : ", result[i], " index is: ", i);
  433. StringSplit(result[i], ' ', tempTp);
  434. //double tp = (double) tempTp[1];
  435. for(int j=0 ; j < ArraySize(tempTp); j++)
  436. {
  437. Print(" Data is: ", tempTp[j]);
  438. }
  439. if(ArraySize(tempTp) >= 2)
  440. tp = (double) tempTp[1];
  441. Print("Tp : ", tp);
  442. }
  443. }
  444. Print("Side:", direction, " Symbol: ", symbol, " Tp: ", tp, " Sl: ", sl, " Message Id: ", message_id);
  445. if(direction == buy)
  446. {
  447. tickt = placeBuyTrade(symbol, tp, sl, message_id, lotSize);
  448. }
  449. if(direction == sell)
  450. {
  451. tickt = placeSellTrade(symbol, tp, sl, message_id, lotSize);
  452. }
  453. }
  454. }
  455. }
  456. //+------------------------------------------------------------------+
  457. //| |
  458. //+------------------------------------------------------------------+
  459. int placeBuyTrade(string symbol,double tp,double sl, int messageId, double lot_size)
  460. {
  461. double ask = SymbolInfoDouble(symbol,SYMBOL_ASK);
  462. double bid = SymbolInfoDouble(symbol,SYMBOL_BID);
  463. double buySl = sl;
  464. double buyTp = tp;
  465. int ticket = OrderSend(symbol, OP_BUY, lot_size, ask, 3, buySl, buyTp, "Buy Trade Placed.", magic_no, 0, clrBlue);
  466. Print("Buy order Print: Stop Loss: ", buySl, " Take profit: ", buyTp);
  467. if(ticket < 0)
  468. {
  469. Print("Buy Order Failed ", GetLastError());
  470. }
  471. else
  472. {
  473. Print(" Buy Order Is Placed Sucessfully ");
  474. }
  475. return ticket;
  476. }
  477. //+------------------------------------------------------------------+
  478. //| |
  479. //+------------------------------------------------------------------+
  480. int placeSellTrade(string symbol,double tp,double sl, int messageId, double lot_size)
  481. {
  482. double ask = SymbolInfoDouble(symbol,SYMBOL_ASK);
  483. double bid = SymbolInfoDouble(symbol,SYMBOL_BID);
  484. double sellSl = sl;
  485. double sellTp = tp;
  486. int ticket = OrderSend(symbol, OP_SELL, lot_size, bid, 3, sellSl, sellTp, "Sell Trade Placed.", magic_no, 0, clrRed);
  487. if(ticket < 0)
  488. {
  489. Print("Sell Order Failed ", GetLastError());
  490. }
  491. else
  492. {
  493. Print(" Sell Order Is Placed Sucessfully ");
  494. }
  495. return ticket;
  496. }
  497. //+------------------------------------------------------------------+
  498. //| |
  499. //+------------------------------------------------------------------+
  500. void addtoMessageStructure(int message_id,string message,ulong ticket)
  501. {
  502. for(int i=0; i < MaxOrders; i++)
  503. {
  504. if(od[i].msgid == -1)
  505. {
  506. od[i].msgid = message_id;
  507. od[i].tickt = ticket;
  508. StringToLower(message);
  509. Print(" Message ID ",message_id," of Message = ",message," Having Ticket ",ticket," is added To Structure :: ");
  510. break;
  511. }
  512. }
  513. }
  514. //+------------------------------------------------------------------+
  515. //| |
  516. //+------------------------------------------------------------------+
  517. string trimString(string inputt)
  518. {
  519. // Remove spaces from the left and right sides
  520. int startt = 0;
  521. int end = StringLen(inputt) - 1;
  522. // Find the first non-space character
  523. while(startt <= end && StringGetCharacter(inputt, startt) == ' ')
  524. startt++;
  525. // Find the last non-space character
  526. while(end >= startt && StringGetCharacter(inputt, end) == ' ')
  527. end--;
  528. // Extract the substring without leading or trailing spaces
  529. return StringSubstr(inputt, startt, end - startt + 1);
  530. }
  531. //+------------------------------------------------------------------+
  532. //| |
  533. //+------------------------------------------------------------------+
  534. string spaceRemove(string inputt)
  535. {
  536. int len = StringLen(inputt);
  537. string out = "";
  538. bool inSpace = false;
  539. for(int i = 0; i < len; i++)
  540. {
  541. ushort ch = StringGetCharacter(inputt, i);
  542. // treat space, tab, CR, LF as whitespace
  543. bool isSpace = (ch == 32 || ch == 9 || ch == 10 || ch == 13);
  544. if(isSpace)
  545. {
  546. // mark that we are inside a whitespace run, but don't append yet
  547. inSpace = true;
  548. continue;
  549. }
  550. // when we hit a non-space after whitespace, add a single space (if out not empty)
  551. if(inSpace && StringLen(out) > 0)
  552. out += " ";
  553. // append the non-space character (use substr to preserve unicode chars)
  554. out += StringSubstr(inputt, i, 1);
  555. inSpace = false;
  556. }
  557. return(out);
  558. }
  559. //+------------------------------------------------------------------+
  560. //| |
  561. //+------------------------------------------------------------------+
  562. string removeExtraSpaces(string str)
  563. {
  564. string result = "";
  565. int len = StringLen(str);
  566. bool lastWasSpace = false;
  567. for(int i = 0; i < len; i++)
  568. {
  569. string currentChar = StringSubstr(str, i, 1);
  570. if(currentChar == " ")
  571. {
  572. // Skip adding this space if the last character was also a space
  573. if(lastWasSpace)
  574. continue;
  575. lastWasSpace = true;
  576. }
  577. else
  578. {
  579. lastWasSpace = false;
  580. }
  581. result += currentChar;
  582. }
  583. return result;
  584. }
  585. //+------------------------------------------------------------------+
  586. //| |
  587. //+------------------------------------------------------------------+
  588. bool HasAlphanumeric(string str)
  589. {
  590. //Print("String Length: ", StringLen(str));
  591. for(int i = 0; i <= StringLen(str); i++)
  592. {
  593. //Print("Here ", StringLen(str));
  594. if(IsAlphanumeric((char)str[i]))
  595. {
  596. return true;
  597. break;
  598. }
  599. }
  600. return false;
  601. }
  602. //+------------------------------------------------------------------+
  603. //| |
  604. //+------------------------------------------------------------------+
  605. bool IsAlphanumeric(char c)
  606. {
  607. if((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
  608. return true;
  609. return false;
  610. }
  611. //+------------------------------------------------------------------+
  612. //| |
  613. //+------------------------------------------------------------------+
  614. string symbolMapping(string symbol)
  615. {
  616. for(int k = 0; k < ArraySize(symbolChart); k++)
  617. {
  618. StringToUpper(symbolChart[k]);
  619. if(symbol == symbolChart[k])
  620. {
  621. symbol = symbolSnd[k];
  622. }
  623. }
  624. symbol = prefix + symbol + suffix;
  625. return symbol;
  626. }
  627. //+------------------------------------------------------------------+
  628. //| |
  629. //+------------------------------------------------------------------+
  630. //+------------------------------------------------------------------+
  631. //+------------------------------------------------------------------+