Ea Pipjet


SUBMITTED BY: rich4team

DATE: Aug. 28, 2018, 4:25 p.m.

FORMAT: MQL

SIZE: 55.2 kB

HITS: 413

  1. #include <WinUser32.mqh>
  2. //#include <stdlib.mqh>
  3. #import "stdlib.ex4"
  4. string ErrorDescription(int a0);
  5. #import "PipJet.dll"
  6. int GetParams(int a0, int a1, int a2, double& a3[]);
  7. void Activate(string a0, int a1, string a2, string a3, string a4, int a5, string a6, int a7);
  8. int GetState();
  9. bool GetStateMessage(string a0, int a1, string a2, int a3);
  10. bool GetInfoMessage(string a0, int a1, string a2, int a3);
  11. bool GetAdvMessage(string a0, int a1, string a2, int a3);
  12. void GetStatus(int a0, int a1, double a2, double a3, double a4);
  13. int Increment(string a0, int a1, int a2, int a3);
  14. bool Decrement(int a0);
  15. bool IsTradeTime(int a0, int a1, int a2, int a3);
  16. bool s1_SetRules(int a0, int a1, int a2, double a3, double a4, double a5, double a6, double a7);
  17. bool s1_Buy(int a0, double a1);
  18. bool s1_Sell(int a0, double a1);
  19. bool s2_SetRules(int a0, int a1, int a2, double a3, double a4, double a5, double a6);
  20. bool s2_Buy(int a0, double a1, double a2);
  21. bool s2_Sell(int a0, double a1, double a2);
  22. bool s1_Init(int a0, double& a1[]);
  23. bool s2_Init(int a0, double& a1[]);
  24. void AddLink(int a0, int a1, int a2, int a3, int a4, string a5);
  25. void LinksBegin(int a0);
  26. void LinksEnd(int a0);
  27. #import
  28. extern string Ver.1.00 = "";
  29. extern string _1 = "System Parameters";
  30. extern bool Stealth = TRUE;
  31. extern bool Aggressive = TRUE;
  32. extern double GmtOffset = 0.0;
  33. extern bool NFA = FALSE;
  34. extern bool AutoLocalGmtOffset = TRUE;
  35. extern bool AutoServerGmtOffset = TRUE;
  36. extern int S1_Reference = 74123;
  37. extern int S2_Reference = 32147;
  38. extern string ReceiptCode = "0";
  39. extern string _2 = "Comment Position";
  40. extern int TopPadding = 30;
  41. extern int LeftPadding = 20;
  42. extern color TextColor1 = Orange;
  43. extern color TextColor2 = Orange;
  44. extern color TextColor3 = C'0x64,0x64,0xFF';
  45. extern string _3 = "Strategy Parameters";
  46. extern bool RemoteSafetyMode = TRUE;
  47. extern int Slippage = 3;
  48. extern bool SendEmails = FALSE;
  49. extern string OrderComments = "";
  50. extern string _4 = "Order Management";
  51. extern double LotSize = 0.1;
  52. extern string _5 = "Ratio Order Management";
  53. extern double RiskLevel = 0.2;
  54. extern bool RecoveryMode = TRUE;
  55. double gd_228 = 2.0;
  56. bool gi_236 = TRUE;
  57. bool gi_240 = TRUE;
  58. int gi_244 = 3;
  59. bool gi_248 = TRUE;
  60. int gi_252;
  61. int g_datetime_256;
  62. int gi_260;
  63. double g_hour_264;
  64. int gi_272;
  65. int g_spread_276;
  66. int g_spread_280;
  67. int gi_284;
  68. double gd_288;
  69. double gd_296;
  70. bool gi_312 = TRUE;
  71. int gi_316 = 0;
  72. int gi_320 = 0;
  73. int gi_324 = 0;
  74. int gi_328;
  75. int gi_unused_332 = 1;
  76. bool g_global_var_336 = FALSE;
  77. bool gi_340 = FALSE;
  78. double gd_344 = 0.0;
  79. string gs_352 = "";
  80. string gs_360 = "";
  81. string gs_368 = "";
  82. string gs_376 = "";
  83. string gs_384 = "";
  84. string gs_392 = "";
  85. string gs_400;
  86. string gs_408;
  87. string gs_416;
  88. int g_timeframe_424 = PERIOD_M15;
  89. int gi_428 = 10;
  90. int gi_432 = 50;
  91. int gi_436 = 200;
  92. int gi_440 = 20;
  93. int gi_444 = 0;
  94. int gi_448 = 16711680;
  95. int gi_452 = 255;
  96. int g_period_456 = 6;
  97. int g_period_460 = 20;
  98. int g_period_464 = 8;
  99. bool gi_468 = TRUE;
  100. bool gi_472 = TRUE;
  101. int gi_476 = 12;
  102. bool gi_480 = TRUE;
  103. int gi_484 = 20;
  104. bool gi_488 = TRUE;
  105. bool gi_492 = FALSE;
  106. double gd_496 = 1.0;
  107. double gd_504 = 24.0;
  108. bool gi_512 = TRUE;
  109. double gd_516 = 1.0;
  110. double gd_524 = 1.0;
  111. bool gi_532 = FALSE;
  112. int gi_536 = 0;
  113. bool gi_540 = TRUE;
  114. int g_timeframe_544 = PERIOD_M5;
  115. int gi_548 = 35;
  116. int gi_552 = 60;
  117. int gi_556 = 200;
  118. int gi_560 = 20;
  119. double gd_564 = 1.0;
  120. int gi_572 = 0;
  121. int gi_576 = 16748574;
  122. int gi_580 = 9639167;
  123. int gi_584 = 36;
  124. int g_period_588 = 168;
  125. int g_period_592 = 275;
  126. bool gi_596 = TRUE;
  127. bool gi_600 = FALSE;
  128. bool gi_604 = TRUE;
  129. double gd_608 = 1.0;
  130. double gd_616 = 12.0;
  131. double gd_624 = 24.0;
  132. bool gi_632 = FALSE;
  133. bool gi_636 = FALSE;
  134. int gi_640 = 0;
  135. bool gi_644 = TRUE;
  136. int gi_648 = 0;
  137. int gi_652 = 0;
  138. int gi_656 = 0;
  139. int gi_660;
  140. int gi_664;
  141. int gi_668;
  142. int gi_672;
  143. double gd_676 = 0.0;
  144. double gd_684 = 0.0;
  145. bool gi_692 = FALSE;
  146. bool gi_696;
  147. bool gi_700;
  148. bool gi_704;
  149. int g_count_708 = 0;
  150. int g_ticket_712 = -2;
  151. int g_ticket_716 = -2;
  152. double g_order_profit_720 = 0.0;
  153. double g_order_profit_728 = 0.0;
  154. int g_ticket_736 = -2;
  155. int g_ticket_740 = -2;
  156. double g_order_profit_744 = 0.0;
  157. double g_order_profit_752 = 0.0;
  158. int gi_760 = 0;
  159. int gi_764 = 0;
  160. double gd_768 = 2.0;
  161. int gi_776 = 0;
  162. int gi_780 = 0;
  163. double g_irsi_784;
  164. double g_irsi_792;
  165. double g_irsi_800;
  166. double g_irsi_808;
  167. double g_icci_816;
  168. double g_icci_824;
  169. double g_icci_832;
  170. double g_ima_856;
  171. bool gi_864 = TRUE;
  172. bool gi_868 = TRUE;
  173. double g_ihigh_872 = 0.0;
  174. double g_ilow_880 = 0.0;
  175. bool gi_888 = FALSE;
  176. int gi_892 = 0;
  177. int gi_896 = 0;
  178. int gi_900 = 0;
  179. int gi_904 = 0;
  180. int gi_908 = 0;
  181. int gi_912 = 0;
  182. int gi_916;
  183. int g_datetime_920 = 0;
  184. int g_datetime_924 = 0;
  185. int g_ticket_928 = -1;
  186. int g_datetime_932 = 0;
  187. int g_ticket_936 = -1;
  188. int g_datetime_940 = 0;
  189. bool gi_944 = TRUE;
  190. int g_datetime_948 = 0;
  191. int g_datetime_952 = 0;
  192. int gi_956 = 0;
  193. double g_icci_960;
  194. double g_icci_968;
  195. double g_ihigh_976;
  196. double g_ilow_984;
  197. double g_ihigh_992;
  198. double g_ilow_1000;
  199. bool gi_1008 = FALSE;
  200. int gi_1012 = 0;
  201. int gi_1016 = 0;
  202. int gi_1020 = 0;
  203. int gi_1024 = 0;
  204. int g_ticket_1028 = -1;
  205. int gi_1032;
  206. int gi_1036;
  207. int g_datetime_1040;
  208. int g_datetime_1044;
  209. double g_order_open_price_1048;
  210. int g_ticket_1056 = -1;
  211. int gi_1060;
  212. int gi_1064;
  213. int g_datetime_1068;
  214. int g_datetime_1072;
  215. double g_order_open_price_1076;
  216. bool gi_1084 = TRUE;
  217. int g_datetime_1088 = 0;
  218. int g_datetime_1092 = 0;
  219. string gsa_1096[] = {".", "..", "...", "....", "....."};
  220. int gi_unused_1100 = 0;
  221. int gi_unused_1104 = 0;
  222. string gs_1108 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  223. int gi_unused_1116 = 0;
  224. int gi_unused_1120 = 0;
  225. double gda_unused_1124[];
  226. bool gi_1128 = FALSE;
  227. int f0_20() {
  228. double lda_0[21];
  229. if (s1_Init(gi_328, lda_0)) {
  230. gi_428 = lda_0[0];
  231. gi_436 = lda_0[1];
  232. gi_440 = lda_0[2];
  233. gi_444 = lda_0[3];
  234. g_period_456 = lda_0[4];
  235. g_period_460 = lda_0[5];
  236. g_period_464 = lda_0[6];
  237. gd_496 = lda_0[11];
  238. gd_504 = lda_0[12];
  239. gd_516 = lda_0[13];
  240. gd_524 = lda_0[14];
  241. gi_536 = lda_0[15];
  242. g_timeframe_424 = lda_0[20];
  243. return (1);
  244. }
  245. return (0);
  246. }
  247. int f0_15() {
  248. double lda_0[17];
  249. if (s2_Init(gi_328, lda_0)) {
  250. gi_548 = lda_0[0];
  251. gi_556 = lda_0[1];
  252. gi_560 = lda_0[2];
  253. gd_564 = lda_0[3];
  254. gi_572 = lda_0[4];
  255. gi_584 = lda_0[5];
  256. g_period_588 = lda_0[6];
  257. g_period_592 = lda_0[7];
  258. gd_608 = lda_0[8];
  259. gd_616 = lda_0[9];
  260. gd_624 = lda_0[10];
  261. gi_640 = lda_0[11];
  262. g_timeframe_544 = lda_0[16];
  263. return (1);
  264. }
  265. return (0);
  266. }
  267. int init() {
  268. double global_var_4;
  269. double ld_12;
  270. if (gi_248) gi_252 = 0;
  271. else gi_252 = 1;
  272. gi_328 = Increment(Symbol(), Digits, IsTesting(), WindowHandle(Symbol(), Period()));
  273. gi_664 = LeftPadding;
  274. gi_660 = TopPadding;
  275. if (gi_668 != LeftPadding || gi_672 != TopPadding) {
  276. gi_668 = LeftPadding;
  277. gi_672 = TopPadding;
  278. } else f0_5(0, gi_664, gi_660);
  279. gi_652 = 0;
  280. gi_648 = 0;
  281. gs_400 = "PipJet" + " ver: " + "1.00" + " Symbol: " + Symbol();
  282. f0_36(gs_400, TextColor2);
  283. f0_34();
  284. ObjectsRedraw();
  285. for (int count_0 = 0; !IsStopped() && StringLen(AccountName()) <= 0; count_0++) {
  286. f0_36("Waiting for connection" + f0_13(count_0), TextColor1, 2, 2);
  287. ObjectsRedraw();
  288. Sleep(150);
  289. }
  290. f0_36("Authentication...", TextColor1, 2, 2);
  291. ObjectsRedraw();
  292. gi_320 = 0;
  293. ReceiptCode = StringTrimLeft(StringTrimRight(ReceiptCode));
  294. if (StringLen(ReceiptCode) <= 0) {
  295. if (GlobalVariableCheck("GV_PipJet_REC")) {
  296. global_var_4 = GlobalVariableGet("GV_PipJet_REC");
  297. ReceiptCode = f0_51(global_var_4);
  298. } else gi_320 |= 32;
  299. } else {
  300. ld_12 = f0_17(ReceiptCode);
  301. if (GlobalVariableSet("GV_PipJet_REC", ld_12) == 0) gi_320 |= 64;
  302. }
  303. Activate("1.00", AccountNumber(), AccountCurrency(), AccountCompany(), AccountServer(), IsDemo(), ReceiptCode, 1);
  304. gi_316 = GetState();
  305. if (!IsTesting()) f0_21();
  306. f0_40(gi_316 | gi_320, 2, 2);
  307. LinksBegin(gi_328);
  308. int str_len_20 = StringLen(gs_352);
  309. int str_len_24 = StringLen(gs_360);
  310. if (str_len_20 > 1) f0_36(gs_352);
  311. if (str_len_24 > 0) f0_43(gs_360, TextColor2, gi_652, gi_648 - 1, 7 * (str_len_20 + 1));
  312. f0_34();
  313. str_len_20 = StringLen(gs_368);
  314. str_len_24 = StringLen(gs_376);
  315. if (str_len_20 > 1) f0_36(gs_368);
  316. if (str_len_24 > 0) f0_43(gs_376, TextColor2, gi_652, gi_648 - 1, 7 * (str_len_20 + 1));
  317. if (str_len_20 > 1 || str_len_24 > 0) f0_34();
  318. bool li_28 = FALSE;
  319. bool li_32 = FALSE;
  320. li_28 = f0_20();
  321. li_32 = f0_15();
  322. if (li_28) {
  323. gi_236 = TRUE;
  324. if (Aggressive) gi_240 = li_32;
  325. else gi_240 = FALSE;
  326. } else {
  327. if (li_32) {
  328. gi_236 = FALSE;
  329. gi_240 = TRUE;
  330. } else {
  331. gi_240 = FALSE;
  332. gi_236 = FALSE;
  333. }
  334. }
  335. if ((!gi_236) && !gi_240) {
  336. gs_408 = "Error:";
  337. gs_416 = "This currency is not supported!";
  338. } else {
  339. gs_408 = "Aggressive:";
  340. gs_416 = f0_11(gi_236 && gi_240);
  341. if (Aggressive && (!(gi_236 && gi_240))) gs_416 = gs_416 + " (not supported)";
  342. }
  343. f0_36(gs_408);
  344. f0_36(gs_416, TextColor2, gi_652, gi_648 - 1, 7 * (StringLen(gs_408) + 1));
  345. f0_34();
  346. str_len_20 = StringLen(gs_384);
  347. str_len_24 = StringLen(gs_392);
  348. if (str_len_20 > 1) f0_36(gs_384);
  349. if (str_len_24 > 0) f0_43(gs_392, TextColor2, gi_652, gi_648 - 1, 7 * (str_len_20 + 1));
  350. ObjectsRedraw();
  351. LinksEnd(gi_328);
  352. if ((!gi_236) && !gi_240) MessageBox("You have selected the wrong currency pair!", gs_400 + ": Warning", MB_ICONEXCLAMATION);
  353. gi_324 = FALSE;
  354. if (IsTesting()) gi_312 = FALSE;
  355. g_global_var_336 = 0;
  356. gi_340 = FALSE;
  357. if (!IsTesting())
  358. if (GlobalVariableCheck("GV_PipJet_MKT")) g_global_var_336 = GlobalVariableGet("GV_PipJet_MKT");
  359. return (0);
  360. }
  361. void f0_21() {
  362. string ls_0 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  363. string ls_8 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
  364. if (gi_316 & 65536 > 0) {
  365. if (GetStateMessage(ls_0, 60, ls_8, 255)) {
  366. gs_352 = StringConcatenate(ls_0, ":");
  367. gs_360 = StringTrimLeft(ls_8);
  368. } else {
  369. gs_352 = "";
  370. gs_360 = "";
  371. }
  372. }
  373. if (GetInfoMessage(ls_0, 60, ls_8, 255)) {
  374. gs_368 = StringConcatenate(ls_0, ":");
  375. gs_376 = StringTrimLeft(ls_8);
  376. } else {
  377. gs_368 = "";
  378. gs_376 = "";
  379. }
  380. if (GetAdvMessage(ls_0, 60, ls_8, 255)) {
  381. gs_384 = StringConcatenate(ls_0, ":");
  382. gs_392 = StringTrimLeft(ls_8);
  383. return;
  384. }
  385. gs_384 = "";
  386. gs_392 = "";
  387. }
  388. int deinit() {
  389. Decrement(gi_328);
  390. if (IsTesting()) {
  391. if (!(!IsVisualMode())) return (0);
  392. f0_36("GmtOffset:");
  393. f0_36(DoubleToStr(GmtOffset, 1), TextColor2, gi_652, gi_648 - 1, 77);
  394. f0_34();
  395. f0_36("Digits:");
  396. f0_36(Digits, TextColor2, gi_652, gi_648 - 1, 56);
  397. f0_36("Spread:");
  398. f0_36(StringConcatenate(DoubleToStr(g_spread_276 / gd_288, 1), " (", g_spread_276, " pips)"), TextColor2, gi_652, gi_648 - 1, 56);
  399. f0_34();
  400. return (0);
  401. }
  402. GlobalVariableSet("GV_PipJet_MKT", g_global_var_336);
  403. switch (UninitializeReason()) {
  404. case REASON_CHARTCLOSE:
  405. case REASON_REMOVE:
  406. f0_47(0, gi_656);
  407. gi_656 = 0;
  408. break;
  409. case REASON_RECOMPILE:
  410. case REASON_CHARTCHANGE:
  411. case REASON_PARAMETERS:
  412. case REASON_ACCOUNT:
  413. f0_47(1, gi_656);
  414. gi_656 = 1;
  415. }
  416. return (0);
  417. }
  418. void f0_18(bool ai_0) {
  419. double lda_4[1];
  420. if (ai_0) RefreshRates();
  421. g_datetime_256 = TimeCurrent();
  422. if (!IsTesting()) {
  423. gi_324 = GetParams(gi_328, g_datetime_256, AutoServerGmtOffset, lda_4);
  424. if (gi_324 == 4 && (!AutoLocalGmtOffset)) gi_324 = FALSE;
  425. else GmtOffset = lda_4[0];
  426. }
  427. gi_260 = g_datetime_256 - 3600.0 * GmtOffset;
  428. g_hour_264 = TimeHour(gi_260);
  429. gi_272 = g_datetime_256 - 3600.0 * g_hour_264 - 60 * TimeMinute(gi_260) - TimeSeconds(gi_260);
  430. g_spread_276 = MarketInfo(Symbol(), MODE_SPREAD);
  431. gi_284 = MarketInfo(Symbol(), MODE_STOPLEVEL);
  432. gd_288 = 0.0001 / Point;
  433. if (Digits < 4) gd_288 = 100.0 * gd_288;
  434. }
  435. int f0_27() {
  436. for (int count_0 = 0; IsTradeContextBusy() && count_0 < 10; count_0++) Sleep(15);
  437. if (count_0 >= 10) Print("Trade context is buisy more than ", DoubleToStr(15 * count_0 / 1000, 2), " seconds");
  438. else
  439. if (count_0 > 0) Print("Trade context was buisy ", DoubleToStr(15 * count_0 / 1000, 2), " seconds");
  440. return (count_0);
  441. }
  442. int f0_28(int a_cmd_0, double a_lots_4, double a_price_12, double a_price_20, double a_price_28, int a_magic_36, color a_color_40, bool ai_44 = FALSE) {
  443. double price_48;
  444. double price_56;
  445. int error_68;
  446. double price_76;
  447. int ticket_64 = -1;
  448. int count_72 = 0;
  449. bool li_84 = FALSE;
  450. double ld_88 = gd_768 * gd_288 * Point;
  451. while (!li_84) {
  452. if (!ai_44) {
  453. price_48 = a_price_20;
  454. price_56 = a_price_28;
  455. } else {
  456. price_48 = 0;
  457. price_56 = 0;
  458. }
  459. if (a_cmd_0 == OP_BUY) price_76 = MarketInfo(Symbol(), MODE_ASK);
  460. else
  461. if (a_cmd_0 == OP_SELL) price_76 = MarketInfo(Symbol(), MODE_BID);
  462. if (count_72 > 0 && MathAbs(price_76 - a_price_12) > ld_88) {
  463. Print("Price is too far");
  464. break;
  465. }
  466. f0_27();
  467. ticket_64 = OrderSend(Symbol(), a_cmd_0, a_lots_4, a_price_12, Slippage * gd_288, price_56, price_48, OrderComments, a_magic_36, 0, a_color_40);
  468. if (ticket_64 >= 0) {
  469. gd_344 += a_lots_4;
  470. break;
  471. }
  472. count_72++;
  473. error_68 = GetLastError();
  474. switch (error_68) {
  475. case 130/* INVALID_STOPS */:
  476. if (!ai_44) g_global_var_336 = 1;
  477. case 0/* NO_ERROR */:
  478. if (!ai_44) ai_44 = TRUE;
  479. else li_84 = TRUE;
  480. break;
  481. case 4/* SERVER_BUSY */: break;
  482. case 6/* NO_CONNECTION */: break;
  483. case 129/* INVALID_PRICE */: break;
  484. case 136/* OFF_QUOTES */: break;
  485. case 137/* BROKER_BUSY */: break;
  486. case 146/* TRADE_CONTEXT_BUSY */: break;
  487. case 135/* PRICE_CHANGED */:
  488. case 138/* REQUOTE */:
  489. RefreshRates();
  490. break;
  491. default:
  492. li_84 = TRUE;
  493. }
  494. if (count_72 > 10) break;
  495. }
  496. if (ticket_64 >= 0) {
  497. if (ai_44) {
  498. if (OrderSelect(ticket_64, SELECT_BY_TICKET)) {
  499. Sleep(1000);
  500. f0_27();
  501. OrderModify(ticket_64, OrderOpenPrice(), a_price_28, a_price_20, 0, a_color_40);
  502. }
  503. }
  504. if (count_72 > 5) Print(f0_29(a_cmd_0) + " operation attempts: ", count_72);
  505. if (SendEmails) SendMail(gs_400, "Open " + f0_29(a_cmd_0) + ": [" + Symbol() + "] " + NormalizeDouble(a_price_12, Digits));
  506. } else Print(f0_29(a_cmd_0) + " operation failed - error(", error_68, "): ", ErrorDescription(error_68), " attempts: ", count_72);
  507. return (ticket_64);
  508. }
  509. int f0_42(int ai_0, color a_color_4, bool ai_8 = FALSE) {
  510. double price_12;
  511. double order_takeprofit_20;
  512. double order_stoploss_28;
  513. int error_40;
  514. if (ai_8) {
  515. f0_27();
  516. order_takeprofit_20 = OrderTakeProfit();
  517. order_stoploss_28 = OrderStopLoss();
  518. OrderModify(OrderTicket(), OrderOpenPrice(), 0, 0, 0, a_color_4);
  519. }
  520. for (int count_36 = 0; count_36 < 10; count_36++) {
  521. if (f0_27() > 5) RefreshRates();
  522. if (ai_0 == 0) price_12 = Bid;
  523. else price_12 = Ask;
  524. if (OrderClose(OrderTicket(), OrderLots(), price_12, Slippage * gd_288, a_color_4)) return (-1);
  525. error_40 = GetLastError();
  526. Print("Order close operation failed - error(", error_40, "): ", ErrorDescription(error_40));
  527. if (error_40 == 4108/* INVALID_TICKET */) return (-2);
  528. RefreshRates();
  529. }
  530. if (ai_8) {
  531. f0_27();
  532. OrderModify(OrderTicket(), OrderOpenPrice(), order_stoploss_28, order_takeprofit_20, 0, a_color_4);
  533. }
  534. Print("Order close operation failed");
  535. return (OrderTicket());
  536. }
  537. double f0_49(double ad_0, double ad_8, int &ai_16) {
  538. if (AccountLeverage() < 100) return (f0_9(ad_0 * ad_8 / MarketInfo(Symbol(), MODE_MARGINREQUIRED), ai_16));
  539. return (f0_9(ad_0 * ad_8 / MarketInfo(Symbol(), MODE_MARGINREQUIRED) / (AccountLeverage() / 100.0), ai_16));
  540. }
  541. double f0_9(double ad_0, int &ai_8) {
  542. double lotstep_20 = MarketInfo(Symbol(), MODE_LOTSTEP);
  543. double ld_28 = MarketInfo(Symbol(), MODE_MINLOT);
  544. double ld_36 = MarketInfo(Symbol(), MODE_MAXLOT);
  545. double ld_ret_12 = MathCeil(ad_0 / lotstep_20) * lotstep_20;
  546. ai_8 = 0;
  547. if (ld_ret_12 < ld_28) {
  548. ld_ret_12 = ld_28;
  549. ai_8 = -1;
  550. }
  551. if (ld_ret_12 > ld_36) {
  552. ld_ret_12 = ld_36;
  553. ai_8 = 1;
  554. }
  555. return (ld_ret_12);
  556. }
  557. void f0_30(double ad_0, double ad_8, int ai_16) {
  558. double ld_20 = (ad_8 - ad_0) / (Point * gd_288);
  559. if (ai_16 == 1) ld_20 = -ld_20;
  560. gd_676 += ld_20;
  561. if (gd_684 < gd_676) gd_684 = gd_676;
  562. }
  563. double f0_4(double ad_0) {
  564. int li_8;
  565. if (gd_684 > gd_676 + gd_228 * gd_288 && gi_760 > gi_776) {
  566. gi_340 = TRUE;
  567. return (f0_9(2.0 * ad_0, li_8));
  568. }
  569. gi_340 = FALSE;
  570. gi_776 = gi_760;
  571. return (ad_0);
  572. }
  573. int f0_31() {
  574. int count_0 = 0;
  575. gd_676 = 0;
  576. gd_684 = 0;
  577. for (int pos_4 = OrdersHistoryTotal() - 1; pos_4 >= 0; pos_4--) {
  578. if (OrderSelect(pos_4, SELECT_BY_POS, MODE_HISTORY)) {
  579. if (OrderMagicNumber() != S1_Reference && OrderMagicNumber() != S2_Reference) continue;
  580. f0_30(OrderOpenPrice(), OrderClosePrice(), OrderType());
  581. count_0++;
  582. }
  583. }
  584. return (count_0);
  585. }
  586. int f0_16(int a_magic_0, int a_cmd_4) {
  587. for (int pos_8 = OrdersTotal() - 1; pos_8 >= 0; pos_8--) {
  588. if (OrderSelect(pos_8, SELECT_BY_POS)) {
  589. if (OrderMagicNumber() == a_magic_0) {
  590. if (OrderSymbol() == Symbol())
  591. if (OrderType() == a_cmd_4) return (OrderTicket());
  592. }
  593. }
  594. }
  595. return (-1);
  596. }
  597. void f0_8() {
  598. g_count_708 = 0;
  599. for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
  600. if (OrderSelect(pos_0, SELECT_BY_POS)) {
  601. if (OrderSymbol() == Symbol())
  602. if (OrderMagicNumber() != S1_Reference && OrderMagicNumber() != S2_Reference) g_count_708++;
  603. }
  604. }
  605. }
  606. int f0_12() {
  607. return (g_count_708 <= 0 && g_ticket_712 < 0 && g_ticket_716 < 0 && g_ticket_736 < 0 && g_ticket_740 < 0);
  608. }
  609. int f0_33() {
  610. if (g_icci_816 >= 0.0 || g_irsi_784 >= 50.0) g_datetime_924 = g_datetime_256;
  611. if (g_icci_816 <= 0.0 || g_irsi_784 <= 50.0) g_datetime_920 = g_datetime_256;
  612. if (g_datetime_924 > 0 && g_datetime_256 - g_datetime_924 > 3600.0 * gd_516) return (2);
  613. if (g_datetime_920 > 0 && g_datetime_256 - g_datetime_920 > 3600.0 * gd_516) return (3);
  614. if (g_datetime_924 == 0 || g_datetime_920 == 0) return (0);
  615. return (1);
  616. }
  617. void f0_3() {
  618. int shift_0;
  619. if (g_datetime_256 - gi_272 < 3600.0 * gi_476) shift_0 = iBarShift(NULL, g_timeframe_424, gi_272 - 86400);
  620. else shift_0 = iBarShift(NULL, g_timeframe_424, gi_272);
  621. g_ihigh_872 = iHigh(NULL, g_timeframe_424, iHighest(NULL, g_timeframe_424, MODE_HIGH, shift_0 - gi_252, gi_252));
  622. g_ilow_880 = iLow(NULL, g_timeframe_424, iLowest(NULL, g_timeframe_424, MODE_LOW, shift_0 - gi_252, gi_252));
  623. }
  624. void f0_53() {
  625. int li_0;
  626. HideTestIndicators(TRUE);
  627. g_irsi_784 = iRSI(NULL, g_timeframe_424, g_period_456, PRICE_CLOSE, gi_252);
  628. g_irsi_792 = iRSI(NULL, g_timeframe_424, g_period_456, PRICE_CLOSE, gi_252 + 1);
  629. g_irsi_800 = iRSI(NULL, g_timeframe_424, g_period_456, PRICE_CLOSE, gi_252 + 2);
  630. if (gi_468) g_irsi_808 = iRSI(NULL, PERIOD_M1, g_period_460, PRICE_CLOSE, gi_252);
  631. g_icci_816 = iCCI(NULL, g_timeframe_424, g_period_464, PRICE_TYPICAL, gi_252);
  632. g_icci_824 = iCCI(NULL, g_timeframe_424, g_period_464, PRICE_TYPICAL, gi_252 + 1);
  633. g_icci_832 = iCCI(NULL, g_timeframe_424, g_period_464, PRICE_TYPICAL, gi_252 + 2);
  634. g_ima_856 = iMA(NULL, g_timeframe_424, g_period_464, 0, MODE_SMA, PRICE_MEDIAN, gi_252);
  635. if (gi_480) {
  636. if (g_irsi_784 >= 50 - gi_484 / 2 && g_irsi_784 <= gi_484 / 2 + 50) {
  637. gi_864 = TRUE;
  638. gi_868 = TRUE;
  639. }
  640. }
  641. if (gi_472) f0_3();
  642. if (gi_512) {
  643. li_0 = gi_908;
  644. gi_908 = f0_33();
  645. if (li_0 != gi_908) {
  646. gi_912 = li_0;
  647. if (gi_908 == 1) gi_916 = g_datetime_256 + 3600.0 * gd_524;
  648. }
  649. }
  650. if (gi_536 > 0) {
  651. if (g_spread_276 > gi_536 * gd_288) {
  652. if (g_spread_280 < g_spread_276) {
  653. Print("Strategy1: Safe spread limit exceeded: spread = ", g_spread_276);
  654. if (gi_540) Print("Strategy1: Using DayDirection filter");
  655. }
  656. gi_888 = TRUE;
  657. } else {
  658. if (g_spread_280 > gi_536 * gd_288) Print("Strategy1: Safe spread limit normalized: spread = ", g_spread_276);
  659. gi_888 = FALSE;
  660. }
  661. }
  662. HideTestIndicators(FALSE);
  663. }
  664. int f0_6() {
  665. double iclose_0;
  666. double iclose_8;
  667. int shift_16;
  668. int shift_20;
  669. if (!gi_864) return (0);
  670. if (gi_512) {
  671. if (gi_908 == 2) return (0);
  672. if (g_datetime_256 <= gi_916)
  673. if (gi_912 == 2) return (0);
  674. }
  675. if (gi_532 || gi_888) {
  676. if (g_datetime_256 - gi_272 < 43200.0) {
  677. shift_16 = iBarShift(NULL, g_timeframe_424, gi_272 - 86400);
  678. shift_20 = iBarShift(NULL, g_timeframe_424, gi_272);
  679. } else {
  680. shift_16 = iBarShift(NULL, g_timeframe_424, gi_272);
  681. shift_20 = gi_252;
  682. }
  683. iclose_8 = iClose(NULL, g_timeframe_424, shift_16);
  684. iclose_0 = iClose(NULL, g_timeframe_424, shift_20);
  685. if (iclose_0 < iclose_8) return (0);
  686. }
  687. return (s1_Buy(gi_328, Ask));
  688. }
  689. int f0_50() {
  690. double iclose_0;
  691. double iclose_8;
  692. int shift_16;
  693. int shift_20;
  694. if (!gi_868) return (0);
  695. if (gi_512) {
  696. if (gi_908 == 3) return (0);
  697. if (g_datetime_256 <= gi_916)
  698. if (gi_912 == 3) return (0);
  699. }
  700. if (gi_532 || gi_888) {
  701. if (g_datetime_256 - gi_272 < 43200.0) {
  702. shift_16 = iBarShift(NULL, g_timeframe_424, gi_272 - 86400);
  703. shift_20 = iBarShift(NULL, g_timeframe_424, gi_272);
  704. } else {
  705. shift_16 = iBarShift(NULL, g_timeframe_424, gi_272);
  706. shift_20 = gi_252;
  707. }
  708. iclose_8 = iClose(NULL, g_timeframe_424, shift_16);
  709. iclose_0 = iClose(NULL, g_timeframe_424, shift_20);
  710. if (iclose_0 > iclose_8) return (0);
  711. }
  712. return (s1_Sell(gi_328, Bid));
  713. }
  714. int f0_10() {
  715. if (Stealth || OrderTakeProfit() == 0.0) {
  716. if (gi_428 > 0)
  717. if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_428 * Point * gd_288, Digits)) return (1);
  718. }
  719. if (OrderStopLoss() == 0.0) {
  720. if (gi_896 > 0)
  721. if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_896 * Point, Digits)) return (1);
  722. }
  723. if (gi_492) {
  724. if (g_ticket_928 != OrderTicket()) {
  725. g_datetime_932 = OrderOpenTime();
  726. g_ticket_928 = OrderTicket();
  727. }
  728. if (g_icci_816 >= 0.0 || g_irsi_784 >= 50.0) g_datetime_932 = g_datetime_256;
  729. if (g_icci_832 < g_icci_824 && g_irsi_800 < g_irsi_792) g_datetime_932 = iTime(NULL, g_timeframe_424, gi_252);
  730. if (g_datetime_256 - g_datetime_932 > 3600.0 * gd_496 && OrderProfit() < 0.0) return (1);
  731. }
  732. if (gi_488) {
  733. if (g_datetime_256 - OrderOpenTime() > 3600.0 * gd_496) {
  734. if (g_icci_816 > 0.0 && g_irsi_784 > 50.0 && OrderProfit() > 0.0) return (1);
  735. if (g_datetime_256 - OrderOpenTime() > 3600.0 * gd_504) return (1);
  736. }
  737. }
  738. return (0);
  739. }
  740. int f0_26() {
  741. if (Stealth || OrderTakeProfit() == 0.0) {
  742. if (gi_428 > 0)
  743. if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_428 * Point * gd_288, Digits)) return (1);
  744. }
  745. if (OrderStopLoss() == 0.0) {
  746. if (gi_904 > 0)
  747. if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_904 * Point, Digits)) return (1);
  748. }
  749. if (gi_492) {
  750. if (g_ticket_936 != OrderTicket()) {
  751. g_datetime_940 = OrderOpenTime();
  752. g_ticket_936 = OrderTicket();
  753. }
  754. if (g_icci_816 <= 0.0 || g_irsi_784 <= 50.0) g_datetime_940 = g_datetime_256;
  755. if (g_icci_832 > g_icci_824 && g_irsi_800 > g_irsi_792) g_datetime_940 = iTime(NULL, g_timeframe_424, gi_252);
  756. if (g_datetime_256 - g_datetime_940 > 3600.0 * gd_496 && OrderProfit() < 0.0) return (1);
  757. }
  758. if (gi_488) {
  759. if (g_datetime_256 - OrderOpenTime() > 3600.0 * gd_496) {
  760. if (g_icci_816 < 0.0 && g_irsi_784 < 50.0 && OrderProfit() > 0.0) return (1);
  761. if (g_datetime_256 - OrderOpenTime() > 3600.0 * gd_504) return (1);
  762. }
  763. }
  764. return (0);
  765. }
  766. int f0_41() {
  767. double ld_0 = 0;
  768. double ld_8 = 0;
  769. if (g_ilow_880 > 0.0) {
  770. gi_896 = (Bid - g_ilow_880 + Point * gd_288) / Point;
  771. if (gi_436 > 0 && gi_896 > gi_436 * gd_288) gi_896 = gi_436 * gd_288;
  772. if (gi_896 < gi_440 * gd_288) gi_896 = gi_440 * gd_288;
  773. } else gi_896 = gi_440 * gd_288;
  774. if (gi_896 < gi_284) gi_896 = gi_284;
  775. if (Stealth) gi_892 = gi_432 * gd_288;
  776. else gi_892 = gi_428 * gd_288;
  777. if (gi_892 < gi_284) gi_892 = gi_284;
  778. ld_8 = NormalizeDouble(Bid - gi_896 * Point, Digits);
  779. ld_0 = NormalizeDouble(Ask + gi_892 * Point, Digits);
  780. return (f0_28(OP_BUY, gd_296, Ask, ld_0, ld_8, S1_Reference, gi_448, g_global_var_336));
  781. }
  782. int f0_48() {
  783. double ld_0 = 0;
  784. double ld_8 = 0;
  785. if (g_ihigh_872 > 0.0) {
  786. gi_904 = (g_ihigh_872 - Ask + Point * gd_288) / Point;
  787. if (gi_436 > 0 && gi_904 > gi_436 * gd_288) gi_904 = gi_436 * gd_288;
  788. if (gi_904 < gi_440 * gd_288) gi_904 = gi_440 * gd_288;
  789. } else gi_904 = gi_440 * gd_288;
  790. if (gi_904 < gi_284) gi_904 = gi_284;
  791. if (Stealth) gi_900 = gi_432 * gd_288;
  792. else gi_900 = gi_428 * gd_288;
  793. if (gi_900 < gi_284) gi_900 = gi_284;
  794. ld_8 = NormalizeDouble(Ask + gi_904 * Point, Digits);
  795. ld_0 = NormalizeDouble(Bid - gi_900 * Point, Digits);
  796. return (f0_28(OP_SELL, gd_296, Bid, ld_0, ld_8, S1_Reference, gi_452, g_global_var_336));
  797. }
  798. int f0_0() {
  799. int li_ret_16;
  800. double order_takeprofit_0 = OrderTakeProfit();
  801. double order_stoploss_8 = OrderStopLoss();
  802. if (order_takeprofit_0 == 0.0 || order_stoploss_8 == 0.0) {
  803. if (order_takeprofit_0 == 0.0) {
  804. if (gi_892 < gi_284) gi_892 = gi_284;
  805. order_takeprofit_0 = NormalizeDouble(Ask + gi_892 * Point, Digits);
  806. }
  807. if (order_stoploss_8 == 0.0) {
  808. if (gi_896 < gi_284) gi_896 = gi_284;
  809. order_stoploss_8 = NormalizeDouble(Bid - gi_896 * Point, Digits);
  810. }
  811. f0_27();
  812. OrderModify(OrderTicket(), OrderOpenPrice(), order_stoploss_8, order_takeprofit_0, 0, Green);
  813. }
  814. if (f0_10()) {
  815. li_ret_16 = f0_42(0, Violet, g_global_var_336);
  816. if (li_ret_16 < 0) return (li_ret_16);
  817. }
  818. if (gi_444 > 0) {
  819. if (Bid - OrderOpenPrice() > Point * gd_288 * gi_444) {
  820. if (OrderStopLoss() < Bid - Point * gd_288 * gi_444 || OrderStopLoss() == 0.0) {
  821. f0_27();
  822. OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * gd_288 * gi_444, Digits), OrderTakeProfit(), 0, Green);
  823. }
  824. }
  825. }
  826. return (OrderTicket());
  827. }
  828. int f0_46() {
  829. int li_ret_16;
  830. double order_takeprofit_0 = OrderTakeProfit();
  831. double order_stoploss_8 = OrderStopLoss();
  832. if (order_takeprofit_0 == 0.0 || order_stoploss_8 == 0.0) {
  833. if (order_takeprofit_0 == 0.0) {
  834. if (gi_900 < gi_284) gi_900 = gi_284;
  835. order_takeprofit_0 = NormalizeDouble(Bid - gi_900 * Point, Digits);
  836. }
  837. if (order_stoploss_8 == 0.0) {
  838. if (gi_904 < gi_284) gi_904 = gi_284;
  839. order_stoploss_8 = NormalizeDouble(Ask + gi_904 * Point, Digits);
  840. }
  841. f0_27();
  842. OrderModify(OrderTicket(), OrderOpenPrice(), order_stoploss_8, order_takeprofit_0, 0, Red);
  843. }
  844. if (f0_26()) {
  845. li_ret_16 = f0_42(1, Violet, g_global_var_336);
  846. if (li_ret_16 < 0) return (li_ret_16);
  847. }
  848. if (gi_444 > 0) {
  849. if (OrderOpenPrice() - Ask > Point * gd_288 * gi_444) {
  850. if (OrderStopLoss() > Ask + Point * gd_288 * gi_444 || OrderStopLoss() == 0.0) {
  851. f0_27();
  852. OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * gd_288 * gi_444, Digits), OrderTakeProfit(), 0, Red);
  853. }
  854. }
  855. }
  856. return (OrderTicket());
  857. }
  858. void f0_1() {
  859. if (g_ticket_712 == -2) {
  860. g_ticket_712 = f0_16(S1_Reference, OP_BUY);
  861. if (g_ticket_712 >= 0) {
  862. OrderSelect(g_ticket_712, SELECT_BY_TICKET);
  863. OrderPrint();
  864. Print("Strategy1: Order found:");
  865. }
  866. }
  867. if (g_ticket_716 == -2) {
  868. g_ticket_716 = f0_16(S1_Reference, OP_SELL);
  869. if (g_ticket_716 >= 0) {
  870. OrderSelect(g_ticket_716, SELECT_BY_TICKET);
  871. OrderPrint();
  872. Print("Strategy1: Order found:");
  873. }
  874. }
  875. f0_53();
  876. gi_696 = s1_SetRules(gi_328, gi_260, gi_888, g_icci_816, g_irsi_784, g_irsi_808, g_ima_856, Point * gd_288);
  877. if (gi_944 != gi_696) {
  878. if (gi_696) gi_760++;
  879. gi_944 = gi_696;
  880. }
  881. if (g_ticket_712 >= 0) {
  882. if (OrderSelect(g_ticket_712, SELECT_BY_TICKET)) {
  883. if (OrderCloseTime() == 0) g_ticket_712 = f0_0();
  884. else g_ticket_712 = -1;
  885. g_order_profit_720 = OrderProfit();
  886. if (g_ticket_712 < 0) f0_30(OrderOpenPrice(), OrderClosePrice(), OrderType());
  887. } else {
  888. g_ticket_712 = -2;
  889. g_order_profit_720 = 0;
  890. }
  891. }
  892. if (g_ticket_716 >= 0) {
  893. if (OrderSelect(g_ticket_716, SELECT_BY_TICKET)) {
  894. if (OrderCloseTime() == 0) g_ticket_716 = f0_46();
  895. else g_ticket_716 = -1;
  896. g_order_profit_728 = OrderProfit();
  897. if (g_ticket_716 < 0) f0_30(OrderOpenPrice(), OrderClosePrice(), OrderType());
  898. } else {
  899. g_ticket_716 = -2;
  900. g_order_profit_728 = 0;
  901. }
  902. }
  903. if ((!gi_696) || !gi_704 || gi_692) return;
  904. if (NFA && !f0_12()) return;
  905. int li_0 = f0_6();
  906. int li_4 = f0_50();
  907. if (g_datetime_948 != iTime(NULL, g_timeframe_424, gi_252) && li_0 && g_ticket_712 < 0) {
  908. g_ticket_712 = f0_41();
  909. if (g_ticket_712 < 0) return;
  910. g_datetime_948 = iTime(NULL, g_timeframe_424, gi_252);
  911. if (gi_480) {
  912. gi_864 = FALSE;
  913. gi_868 = TRUE;
  914. }
  915. gi_780++;
  916. return;
  917. }
  918. if (g_datetime_952 != iTime(NULL, g_timeframe_424, gi_252) && li_4 && g_ticket_716 < 0) {
  919. g_ticket_716 = f0_48();
  920. if (g_ticket_716 >= 0) {
  921. g_datetime_952 = iTime(NULL, g_timeframe_424, gi_252);
  922. if (gi_480) {
  923. gi_864 = TRUE;
  924. gi_868 = FALSE;
  925. }
  926. gi_780++;
  927. }
  928. }
  929. }
  930. void f0_35() {
  931. HideTestIndicators(TRUE);
  932. if (gi_596 || gi_604) g_icci_960 = iCCI(NULL, g_timeframe_544, g_period_588, PRICE_TYPICAL, gi_252);
  933. if (gi_600) g_icci_968 = iCCI(NULL, g_timeframe_544, g_period_592, PRICE_TYPICAL, gi_252);
  934. g_ihigh_976 = iHigh(NULL, g_timeframe_544, iHighest(NULL, g_timeframe_544, MODE_HIGH, gi_584, 1));
  935. g_ilow_984 = iLow(NULL, g_timeframe_544, iLowest(NULL, g_timeframe_544, MODE_LOW, gi_584, 1));
  936. if (gi_640 > 0) {
  937. if (g_spread_276 > gi_640 * gd_288) {
  938. if (g_spread_280 < g_spread_276) {
  939. Print("Strategy2: Safe spread limit exceeded: spread = ", g_spread_276);
  940. if (gi_644) Print("Strategy2: Using DayDirection filter");
  941. }
  942. gi_1008 = TRUE;
  943. } else {
  944. if (g_spread_280 > gi_640 * gd_288) Print("Strategy2: Safe spread limit normalized: spread = ", g_spread_276);
  945. gi_1008 = FALSE;
  946. }
  947. }
  948. HideTestIndicators(TRUE);
  949. }
  950. int f0_7() {
  951. double iclose_0;
  952. double iclose_8;
  953. int shift_16;
  954. int shift_20;
  955. if (gi_636 || gi_1008) {
  956. if (g_datetime_256 - gi_272 < 43200.0) {
  957. shift_16 = iBarShift(NULL, g_timeframe_544, gi_272 - 86400);
  958. shift_20 = iBarShift(NULL, g_timeframe_544, gi_272);
  959. } else {
  960. shift_16 = iBarShift(NULL, g_timeframe_544, gi_272);
  961. shift_20 = gi_252;
  962. }
  963. iclose_8 = iClose(NULL, g_timeframe_544, shift_16);
  964. iclose_0 = iClose(NULL, g_timeframe_544, shift_20);
  965. if (iclose_0 < iclose_8) return (0);
  966. }
  967. return (s2_Buy(gi_328, Ask, Bid));
  968. }
  969. int f0_22() {
  970. double iclose_0;
  971. double iclose_8;
  972. int shift_16;
  973. int shift_20;
  974. if (gi_636 || gi_1008) {
  975. if (g_datetime_256 - gi_272 < 43200.0) {
  976. shift_16 = iBarShift(NULL, g_timeframe_544, gi_272 - 86400);
  977. shift_20 = iBarShift(NULL, g_timeframe_544, gi_272);
  978. } else {
  979. shift_16 = iBarShift(NULL, g_timeframe_544, gi_272);
  980. shift_20 = gi_252;
  981. }
  982. iclose_8 = iClose(NULL, g_timeframe_544, shift_16);
  983. iclose_0 = iClose(NULL, g_timeframe_544, shift_20);
  984. if (iclose_0 > iclose_8) return (0);
  985. }
  986. return (s2_Sell(gi_328, Ask, Bid));
  987. }
  988. int f0_23() {
  989. double order_profit_0;
  990. if (Stealth || OrderTakeProfit() == 0.0) {
  991. if (gi_548 > 0)
  992. if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_548 * Point * gd_288, Digits)) return (1);
  993. }
  994. if (OrderStopLoss() == 0.0) {
  995. if (gi_1016 > 0)
  996. if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_1016 * Point, Digits)) return (1);
  997. }
  998. if (gi_604) {
  999. if (g_ticket_1028 != OrderTicket()) {
  1000. gi_1032 = 0;
  1001. gi_1036 = 0;
  1002. g_datetime_1044 = OrderOpenTime();
  1003. g_datetime_1040 = g_datetime_1044;
  1004. g_ticket_1028 = OrderTicket();
  1005. g_order_open_price_1048 = OrderOpenPrice();
  1006. }
  1007. order_profit_0 = OrderProfit();
  1008. if (Ask > g_order_open_price_1048) {
  1009. gi_1032 += g_datetime_256 - g_datetime_1040;
  1010. g_datetime_1040 = g_datetime_256;
  1011. } else {
  1012. gi_1036 += g_datetime_256 - g_datetime_1040;
  1013. g_datetime_1040 = g_datetime_256;
  1014. }
  1015. if (g_datetime_256 - g_datetime_1044 > 3600.0 * gd_608) {
  1016. if (g_icci_960 > 0.0 && order_profit_0 > 0.0 && gi_1032 < gi_1036) return (1);
  1017. if (g_icci_960 > 100.0 && order_profit_0 > 0.0) return (1);
  1018. if (g_datetime_256 - g_datetime_1044 > 3600.0 * gd_616 && order_profit_0 > 0.0) return (1);
  1019. if (g_datetime_256 - g_datetime_1044 > 3600.0 * gd_624) return (1);
  1020. }
  1021. }
  1022. if (gi_632) return (Bid >= g_ihigh_976);
  1023. return (Bid >= g_ihigh_992);
  1024. }
  1025. int f0_14() {
  1026. double order_profit_0;
  1027. if (Stealth || OrderTakeProfit() == 0.0) {
  1028. if (gi_548 > 0)
  1029. if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) >= NormalizeDouble(gi_548 * Point * gd_288, Digits)) return (1);
  1030. }
  1031. if (OrderStopLoss() == 0.0) {
  1032. if (gi_1024 > 0)
  1033. if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) >= NormalizeDouble(gi_1024 * Point, Digits)) return (1);
  1034. }
  1035. if (gi_604) {
  1036. if (g_ticket_1056 != OrderTicket()) {
  1037. gi_1060 = 0;
  1038. gi_1064 = 0;
  1039. g_datetime_1072 = OrderOpenTime();
  1040. g_datetime_1068 = g_datetime_1072;
  1041. g_ticket_1056 = OrderTicket();
  1042. g_order_open_price_1076 = OrderOpenPrice();
  1043. }
  1044. order_profit_0 = OrderProfit();
  1045. if (Bid < g_order_open_price_1076) {
  1046. gi_1060 += g_datetime_256 - g_datetime_1068;
  1047. g_datetime_1068 = g_datetime_256;
  1048. } else {
  1049. gi_1064 += g_datetime_256 - g_datetime_1068;
  1050. g_datetime_1068 = g_datetime_256;
  1051. }
  1052. if (g_datetime_256 - g_datetime_1072 > 3600.0 * gd_608) {
  1053. if (g_icci_960 < 0.0 && order_profit_0 > 0.0 && gi_1060 < gi_1064) return (1);
  1054. if (g_icci_960 < -100.0 && order_profit_0 > 0.0) return (1);
  1055. if (g_datetime_256 - g_datetime_1072 > 3600.0 * gd_616 && order_profit_0 > 0.0) return (1);
  1056. if (g_datetime_256 - g_datetime_1072 > 3600.0 * gd_624) return (1);
  1057. }
  1058. }
  1059. if (gi_632) return (Ask <= g_ilow_984);
  1060. return (Ask <= g_ilow_1000);
  1061. }
  1062. int f0_19() {
  1063. double ld_0 = 0;
  1064. double ld_8 = 0;
  1065. if (gd_564 > 0.0) {
  1066. gi_1016 = gd_564 * (g_ihigh_976 - g_ilow_984) / Point;
  1067. if (gi_556 > 0 && gi_1016 > gi_556 * gd_288) gi_1016 = gi_556 * gd_288;
  1068. if (gi_1016 < gi_560 * gd_288) gi_1016 = gi_560 * gd_288;
  1069. } else gi_1016 = gi_560 * gd_288;
  1070. if (gi_1016 < gi_284) gi_1016 = gi_284;
  1071. if (Stealth) gi_1012 = gi_552 * gd_288;
  1072. else gi_1012 = gi_548 * gd_288;
  1073. if (gi_1012 < gi_284) gi_1012 = gi_284;
  1074. ld_8 = NormalizeDouble(Bid - gi_1016 * Point, Digits);
  1075. ld_0 = NormalizeDouble(Ask + gi_1012 * Point, Digits);
  1076. return (f0_28(OP_BUY, gd_296, Ask, ld_0, ld_8, S2_Reference, gi_576, g_global_var_336));
  1077. }
  1078. int f0_39() {
  1079. double ld_0 = 0;
  1080. double ld_8 = 0;
  1081. if (gd_564 > 0.0) {
  1082. gi_1024 = gd_564 * (g_ihigh_976 - g_ilow_984) / Point;
  1083. if (gi_556 > 0 && gi_1024 > gi_556 * gd_288) gi_1024 = gi_556 * gd_288;
  1084. if (gi_1024 < gi_560 * gd_288) gi_1024 = gi_560 * gd_288;
  1085. } else gi_1024 = gi_560 * gd_288;
  1086. if (gi_1024 < gi_284) gi_1024 = gi_284;
  1087. if (Stealth) gi_1020 = gi_552 * gd_288;
  1088. else gi_1020 = gi_548 * gd_288;
  1089. if (gi_1020 < gi_284) gi_1020 = gi_284;
  1090. ld_8 = NormalizeDouble(Ask + gi_1024 * Point, Digits);
  1091. ld_0 = NormalizeDouble(Bid - gi_1020 * Point, Digits);
  1092. return (f0_28(OP_SELL, gd_296, Bid, ld_0, ld_8, S2_Reference, gi_580, g_global_var_336));
  1093. }
  1094. int f0_32() {
  1095. int li_ret_16;
  1096. double order_takeprofit_0 = OrderTakeProfit();
  1097. double order_stoploss_8 = OrderStopLoss();
  1098. if (order_takeprofit_0 == 0.0 || order_stoploss_8 == 0.0) {
  1099. if (order_takeprofit_0 == 0.0) {
  1100. if (gi_1012 < gi_284) gi_1012 = gi_284;
  1101. order_takeprofit_0 = NormalizeDouble(Ask + gi_1012 * Point, Digits);
  1102. }
  1103. if (order_stoploss_8 == 0.0) {
  1104. if (gi_1016 < gi_284) gi_1016 = gi_284;
  1105. order_stoploss_8 = NormalizeDouble(Bid - gi_1016 * Point, Digits);
  1106. }
  1107. f0_27();
  1108. OrderModify(OrderTicket(), OrderOpenPrice(), order_stoploss_8, order_takeprofit_0, 0, Green);
  1109. }
  1110. if (f0_23()) {
  1111. li_ret_16 = f0_42(0, Violet, g_global_var_336);
  1112. if (li_ret_16 < 0) return (li_ret_16);
  1113. }
  1114. if (gi_572 > 0) {
  1115. if (Bid - OrderOpenPrice() > Point * gd_288 * gi_572) {
  1116. if (OrderStopLoss() < Bid - Point * gd_288 * gi_572 || OrderStopLoss() == 0.0) {
  1117. f0_27();
  1118. OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - Point * gd_288 * gi_572, Digits), OrderTakeProfit(), 0, Green);
  1119. }
  1120. }
  1121. }
  1122. return (OrderTicket());
  1123. }
  1124. int f0_45() {
  1125. int li_ret_16;
  1126. double order_takeprofit_0 = OrderTakeProfit();
  1127. double order_stoploss_8 = OrderStopLoss();
  1128. if (order_takeprofit_0 == 0.0 || order_stoploss_8 == 0.0) {
  1129. if (order_takeprofit_0 == 0.0) {
  1130. if (gi_1020 < gi_284) gi_1020 = gi_284;
  1131. order_takeprofit_0 = NormalizeDouble(Bid - gi_1020 * Point, Digits);
  1132. }
  1133. if (order_stoploss_8 == 0.0) {
  1134. if (gi_1024 < gi_284) gi_1024 = gi_284;
  1135. order_stoploss_8 = NormalizeDouble(Ask + gi_1024 * Point, Digits);
  1136. }
  1137. f0_27();
  1138. OrderModify(OrderTicket(), OrderOpenPrice(), order_stoploss_8, order_takeprofit_0, 0, Red);
  1139. }
  1140. if (f0_14()) {
  1141. li_ret_16 = f0_42(1, Violet, g_global_var_336);
  1142. if (li_ret_16 < 0) return (li_ret_16);
  1143. }
  1144. if (gi_572 > 0) {
  1145. if (OrderOpenPrice() - Ask > Point * gd_288 * gi_572) {
  1146. if (OrderStopLoss() > Ask + Point * gd_288 * gi_572 || OrderStopLoss() == 0.0) {
  1147. f0_27();
  1148. OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + Point * gd_288 * gi_572, Digits), OrderTakeProfit(), 0, Red);
  1149. }
  1150. }
  1151. }
  1152. return (OrderTicket());
  1153. }
  1154. void f0_38() {
  1155. if (g_ticket_736 == -2) {
  1156. g_ticket_736 = f0_16(S2_Reference, OP_BUY);
  1157. if (g_ticket_736 >= 0) {
  1158. OrderSelect(g_ticket_736, SELECT_BY_TICKET);
  1159. OrderPrint();
  1160. Print("Strategy2: Order found:");
  1161. }
  1162. }
  1163. if (g_ticket_740 == -2) {
  1164. g_ticket_740 = f0_16(S2_Reference, OP_SELL);
  1165. if (g_ticket_740 >= 0) {
  1166. OrderSelect(g_ticket_740, SELECT_BY_TICKET);
  1167. OrderPrint();
  1168. Print("Strategy2: Order found:");
  1169. }
  1170. }
  1171. f0_35();
  1172. gi_700 = s2_SetRules(gi_328, gi_260, gi_1008, g_icci_960, g_icci_968, g_ilow_984, g_ihigh_976);
  1173. if (gi_1084 != gi_700) {
  1174. if (gi_700) {
  1175. g_order_profit_744 = 0;
  1176. g_order_profit_752 = 0;
  1177. gi_764++;
  1178. }
  1179. gi_1084 = gi_700;
  1180. }
  1181. if (g_ticket_736 >= 0) {
  1182. if (OrderSelect(g_ticket_736, SELECT_BY_TICKET)) {
  1183. if (OrderCloseTime() == 0) g_ticket_736 = f0_32();
  1184. else g_ticket_736 = -1;
  1185. g_order_profit_744 = OrderProfit();
  1186. if (g_ticket_736 < 0) f0_30(OrderOpenPrice(), OrderClosePrice(), OrderType());
  1187. } else {
  1188. g_ticket_736 = -2;
  1189. g_order_profit_744 = 0;
  1190. }
  1191. }
  1192. if (g_ticket_740 >= 0) {
  1193. if (OrderSelect(g_ticket_740, SELECT_BY_TICKET)) {
  1194. if (OrderCloseTime() == 0) g_ticket_740 = f0_45();
  1195. else g_ticket_740 = -1;
  1196. g_order_profit_752 = OrderProfit();
  1197. if (g_ticket_740 < 0) f0_30(OrderOpenPrice(), OrderClosePrice(), OrderType());
  1198. } else {
  1199. g_ticket_740 = -2;
  1200. g_order_profit_752 = 0;
  1201. }
  1202. }
  1203. if ((!gi_700) || !gi_704 || gi_692) return;
  1204. if (NFA && !f0_12()) return;
  1205. int li_0 = f0_7();
  1206. int li_4 = f0_22();
  1207. if (g_datetime_1088 != iTime(NULL, g_timeframe_544, gi_252) && li_0 && g_ticket_736 < 0 && g_order_profit_744 >= 0.0) {
  1208. g_ticket_736 = f0_19();
  1209. if (g_ticket_736 < 0) return;
  1210. g_datetime_1088 = iTime(NULL, g_timeframe_544, gi_252);
  1211. g_ihigh_992 = g_ihigh_976;
  1212. g_ilow_1000 = g_ilow_984;
  1213. g_order_profit_752 = 0;
  1214. gi_956++;
  1215. return;
  1216. }
  1217. if (g_datetime_1092 != iTime(NULL, g_timeframe_544, gi_252) && li_4 && g_ticket_740 < 0 && g_order_profit_752 >= 0.0) {
  1218. g_ticket_740 = f0_39();
  1219. if (g_ticket_740 >= 0) {
  1220. g_datetime_1092 = iTime(NULL, g_timeframe_544, gi_252);
  1221. g_ihigh_992 = g_ihigh_976;
  1222. g_ilow_1000 = g_ilow_984;
  1223. g_order_profit_744 = 0;
  1224. gi_956++;
  1225. }
  1226. }
  1227. }
  1228. string f0_11(bool ai_0) {
  1229. if (ai_0) return ("True");
  1230. return ("False");
  1231. }
  1232. string f0_2(bool ai_0, string as_4, string as_12 = "") {
  1233. if (ai_0) return (as_4);
  1234. return (as_12);
  1235. }
  1236. string f0_29(int ai_0) {
  1237. switch (ai_0) {
  1238. case 0:
  1239. return ("Buy");
  1240. case 1:
  1241. return ("Sell");
  1242. }
  1243. return ("Order");
  1244. }
  1245. string f0_24(int ai_0) {
  1246. switch (ai_0) {
  1247. case 1:
  1248. return ("automatic: server");
  1249. case 2:
  1250. return ("automatic: server");
  1251. case 4:
  1252. return ("automatic: local");
  1253. }
  1254. return ("manual");
  1255. }
  1256. string f0_37(int ai_0) {
  1257. switch (ai_0) {
  1258. case 1:
  1259. return ("Correction");
  1260. case 3:
  1261. return ("Upward Impulse");
  1262. case 2:
  1263. return ("Downward Impulse");
  1264. }
  1265. return ("");
  1266. }
  1267. string f0_13(int ai_0) {
  1268. int li_4 = MathMod(ai_0, 5);
  1269. return (gsa_1096[li_4]);
  1270. }
  1271. void f0_40(int ai_0, int ai_4 = -1, int ai_8 = -1) {
  1272. if (ai_4 == -1) ai_4 = gi_652;
  1273. if (ai_8 == -1) ai_8 = gi_648;
  1274. gi_652 = ai_4;
  1275. gi_648 = ai_8;
  1276. if (ai_0 & 16384 > 0) f0_36("Authenticated", TextColor1);
  1277. else f0_36("Authentication failed - error(" + ai_0 + ")", TextColor1);
  1278. if (ai_0 & 512 > 0) f0_36("Attention: Upgrade available", TextColor1);
  1279. if (ai_0 & 1024 > 0) f0_36("Error: Upgrade required", TextColor1);
  1280. if (ai_0 & 1 > 0) f0_36("Error: Internet initialization failed", TextColor1);
  1281. if (ai_0 & 2 > 0) f0_36("Error: Internet connection failed", TextColor1);
  1282. if (ai_0 & 4 > 0) f0_36("Error: Invalid account number", TextColor1);
  1283. if (ai_0 & 8 > 0) f0_36("Error: Invalid account status", TextColor1);
  1284. if (ai_0 & 16 > 0) f0_36("Error: Dll and Expert versions mismatch", TextColor1);
  1285. if (ai_0 & 128 > 0) f0_36("Error: Unable to retrieve authentication code", TextColor1);
  1286. if (ai_0 & 256 > 0) f0_36("Error: Server response failure", TextColor1);
  1287. if (ai_0 & 2048 > 0) f0_36("Error: Invalid authorisation details", TextColor1);
  1288. if (ai_0 & 4096 > 0) f0_36("Error: Authorisation declined", TextColor1);
  1289. }
  1290. string f0_52(int ai_0) {
  1291. return (StringConcatenate("PipJet", " lb: ", ai_0));
  1292. }
  1293. void f0_5(int ai_0, int &ai_4, int &ai_8) {
  1294. string name_12 = f0_52(ai_0);
  1295. if (ObjectFind(name_12) == 0) {
  1296. ai_4 = ObjectGet(name_12, OBJPROP_XDISTANCE);
  1297. ai_8 = ObjectGet(name_12, OBJPROP_YDISTANCE);
  1298. }
  1299. }
  1300. void f0_36(string a_text_0, color a_color_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) {
  1301. if (a_color_8 == CLR_NONE) a_color_8 = TextColor1;
  1302. if (ai_12 == -1) ai_12 = gi_652;
  1303. if (ad_16 == -1.0) ad_16 = gi_648;
  1304. string name_28 = f0_52(ai_12);
  1305. if (ObjectFind(name_28) != 0) {
  1306. ObjectCreate(name_28, OBJ_LABEL, 0, 0, 0);
  1307. ObjectSet(name_28, OBJPROP_CORNER, 0);
  1308. }
  1309. ObjectSetText(name_28, a_text_0, 9, "Courier New", a_color_8);
  1310. ObjectSet(name_28, OBJPROP_XDISTANCE, gi_664 + ai_24);
  1311. ObjectSet(name_28, OBJPROP_YDISTANCE, gi_660 + 14.0 * ad_16);
  1312. if (gi_648 < ad_16 + 1.0) gi_648 = ad_16 + 1.0;
  1313. if (gi_652 < ai_12 + 1) gi_652 = ai_12 + 1;
  1314. if (gi_656 < ai_12) gi_656 = ai_12;
  1315. }
  1316. void f0_34(int ai_0 = -1, double ad_4 = -1.0, int ai_12 = 0) {
  1317. if (ai_0 == -1) ai_0 = gi_652;
  1318. if (ad_4 == -1.0) ad_4 = gi_648;
  1319. f0_36("_______", TextColor2, ai_0, ad_4 - 0.3, ai_12);
  1320. if (gi_648 < ad_4 + 1.0) gi_648 = ad_4 + 1.0;
  1321. }
  1322. int f0_43(string as_0, int ai_8 = -1, int ai_12 = -1, double ad_16 = -1.0, int ai_24 = 0) {
  1323. string ls_36;
  1324. int li_52;
  1325. int li_56;
  1326. string ls_60;
  1327. string ls_68;
  1328. string ls_76;
  1329. string name_84;
  1330. int li_92;
  1331. int li_96;
  1332. int li_28 = 0;
  1333. int li_32 = 0;
  1334. if (ai_12 == -1) ai_12 = gi_652;
  1335. if (ad_16 == -1.0) ad_16 = gi_648;
  1336. int li_44 = StringLen(as_0);
  1337. int li_48 = 0;
  1338. while (li_32 < li_44) {
  1339. li_48 = 0;
  1340. li_32 = StringFind(as_0,
  1341. "\n", li_28);
  1342. if (li_32 == -1) li_32 = li_44;
  1343. else li_48 = 1;
  1344. ls_36 = StringSubstr(as_0, li_28, li_32 - li_28);
  1345. if (ls_36 == "0") {
  1346. f0_34(ai_12, ad_16, ai_24);
  1347. ai_12++;
  1348. } else {
  1349. li_52 = StringFind(ls_36, "<a>");
  1350. li_56 = -1;
  1351. if (li_52 >= 0) li_56 = StringFind(ls_36, "</a>", li_52 + 3);
  1352. if (li_52 >= 0 && li_56 > 0) {
  1353. if (li_52 > 0) ls_60 = StringSubstr(ls_36, 0, li_52);
  1354. else ls_60 = "";
  1355. ls_68 = StringSubstr(ls_36, li_52 + 3, li_56 - li_52 - 3);
  1356. ls_76 = StringSubstr(ls_36, li_56 + 4);
  1357. if (StringLen(ls_60) > 0) {
  1358. f0_36(ls_60, ai_8, ai_12, ad_16, ai_24);
  1359. ai_12++;
  1360. }
  1361. name_84 = f0_52(ai_12);
  1362. f0_36(ls_68, TextColor3, ai_12, ad_16, ai_24 + 7 * StringLen(ls_60));
  1363. li_92 = ObjectGet(name_84, OBJPROP_XDISTANCE);
  1364. li_96 = ObjectGet(name_84, OBJPROP_YDISTANCE);
  1365. AddLink(gi_328, li_92, li_96, li_92 + 7 * StringLen(ls_68), li_96 + 14, ls_68);
  1366. ai_12++;
  1367. if (StringLen(ls_76) > 0) {
  1368. f0_36(ls_76, ai_8, ai_12, ad_16, ai_24 + 7 * (StringLen(ls_60) + StringLen(ls_68)));
  1369. ai_12++;
  1370. }
  1371. } else {
  1372. if (li_32 - li_28 > 60) li_32 = li_28 + 60;
  1373. ls_36 = StringSubstr(as_0, li_28, li_32 - li_28);
  1374. f0_36(ls_36, ai_8, ai_12, ad_16, ai_24);
  1375. ai_12++;
  1376. }
  1377. }
  1378. li_28 = li_32 + li_48;
  1379. ad_16++;
  1380. }
  1381. return (ai_12);
  1382. }
  1383. void f0_47(int ai_0, int ai_4) {
  1384. for (int li_8 = ai_0; li_8 <= ai_4; li_8++) ObjectDelete(f0_52(li_8));
  1385. }
  1386. double f0_17(string as_0) {
  1387. int li_24;
  1388. as_0 = f0_44(as_0);
  1389. int str_len_8 = StringLen(as_0);
  1390. double ld_ret_12 = 0;
  1391. for (int li_20 = 0; li_20 < str_len_8; li_20++) {
  1392. li_24 = StringFind(gs_1108, StringSubstr(as_0, str_len_8 - li_20 - 1, 1));
  1393. ld_ret_12 += li_24 * MathPow(36, li_20);
  1394. }
  1395. return (ld_ret_12);
  1396. }
  1397. string f0_51(double ad_0) {
  1398. string str_concat_8 = "";
  1399. for (ad_0 = MathAbs(ad_0); ad_0 >= 1.0; ad_0 = MathFloor(ad_0 / 36.0)) str_concat_8 = StringConcatenate(StringSubstr(gs_1108, MathMod(ad_0, 36), 1), str_concat_8);
  1400. return (str_concat_8);
  1401. }
  1402. string f0_44(string as_0) {
  1403. int li_8;
  1404. int li_20;
  1405. int str_len_16 = StringLen(as_0);
  1406. for (int li_12 = 0; li_12 < str_len_16; li_12++) {
  1407. li_20 = 0;
  1408. li_8 = StringGetChar(as_0, li_12);
  1409. if (li_8 > '`' && li_8 < '{') li_20 = li_8 - 32;
  1410. if (li_8 > '฿' && li_8 < 256) li_20 = li_8 - 32;
  1411. if (li_8 == 'ธ') li_20 = 168;
  1412. if (li_20 > 0) as_0 = StringSetChar(as_0, li_12, li_20);
  1413. }
  1414. return (as_0);
  1415. }
  1416. int f0_25() {
  1417. int li_ret_0;
  1418. if (RiskLevel > 0.0) {
  1419. gd_296 = f0_49(RiskLevel, AccountFreeMargin(), li_ret_0);
  1420. if (RecoveryMode) gd_296 = f0_4(gd_296);
  1421. } else gd_296 = f0_9(LotSize, li_ret_0);
  1422. return (li_ret_0);
  1423. }
  1424. int start() {
  1425. int li_0;
  1426. if ((!gi_236) && !gi_240) return (0);
  1427. gi_316 = GetState();
  1428. if (Bars < 100) {
  1429. Print("Bars less than 100");
  1430. return (0);
  1431. }
  1432. if (!IsTesting()) f0_21();
  1433. g_spread_280 = g_spread_276;
  1434. f0_18(0);
  1435. if (gi_312) {
  1436. gi_312 = FALSE;
  1437. li_0 = f0_31();
  1438. Print("Orders in history: ", li_0, " profit made: ", DoubleToStr(gd_676, 0), " pips");
  1439. }
  1440. int li_4 = f0_25();
  1441. double ld_8 = NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED) * gd_296, 8);
  1442. gi_692 = NormalizeDouble(AccountFreeMargin(), 8) < ld_8;
  1443. gi_704 = IsTradeTime(gi_328, gi_260, gi_244, RemoteSafetyMode);
  1444. if (RemoteSafetyMode && (!IsTesting()) && gi_316 & 262144 > 0) gi_704 = FALSE;
  1445. if (NFA) f0_8();
  1446. if (gi_236) f0_1();
  1447. f0_18(1);
  1448. li_4 = f0_25();
  1449. gi_692 = NormalizeDouble(AccountFreeMargin(), 8) < ld_8;
  1450. if (gi_240) f0_38();
  1451. if (IsTesting() && (!IsVisualMode())) return (0);
  1452. f0_5(0, gi_664, gi_660);
  1453. gi_652 = 0;
  1454. gi_648 = 0;
  1455. f0_36(gs_400, TextColor2);
  1456. f0_34();
  1457. f0_40(gi_316 | gi_320);
  1458. LinksBegin(gi_328);
  1459. int str_len_16 = StringLen(gs_352);
  1460. int str_len_20 = StringLen(gs_360);
  1461. if (str_len_16 > 1) f0_36(gs_352);
  1462. if (str_len_20 > 0) f0_43(gs_360, TextColor2, gi_652, gi_648 - 1, 7 * (str_len_16 + 1));
  1463. f0_34();
  1464. str_len_16 = StringLen(gs_368);
  1465. str_len_20 = StringLen(gs_376);
  1466. if (str_len_16 > 1) f0_36(gs_368);
  1467. if (str_len_20 > 0) f0_43(gs_376, TextColor2, gi_652, gi_648 - 1, 7 * (str_len_16 + 1));
  1468. if (str_len_16 > 1 || str_len_20 > 0) f0_34();
  1469. f0_36(gs_408);
  1470. f0_36(gs_416, TextColor2, gi_652, gi_648 - 1, 7 * (StringLen(gs_408) + 1));
  1471. f0_34();
  1472. string ls_24 = DoubleToStr(GmtOffset, 1);
  1473. if (!IsTesting()) ls_24 = StringConcatenate(ls_24, " (", f0_24(gi_324), ")");
  1474. f0_36("ServerTime:");
  1475. f0_36(TimeToStr(g_datetime_256), TextColor2, gi_652, gi_648 - 1, 84);
  1476. f0_36("UtcTime:");
  1477. f0_36(TimeToStr(gi_260), TextColor2, gi_652, gi_648 - 1, 63);
  1478. f0_36("GmtOffset:");
  1479. f0_36(ls_24, TextColor2, gi_652, gi_648 - 1, 77);
  1480. f0_34();
  1481. f0_36("Lot:");
  1482. f0_36(DoubleToStr(gd_296, 2), TextColor2, gi_652, gi_648 - 1, 35);
  1483. switch (li_4) {
  1484. case 1:
  1485. f0_36("Maximum Lot size exeeded!");
  1486. break;
  1487. case -1:
  1488. f0_36("Minimum Lot size exeeded!");
  1489. }
  1490. if (gi_340) f0_36("Recovery Mode is Active!");
  1491. f0_36("Spread:");
  1492. f0_36(StringConcatenate(DoubleToStr(g_spread_276 / gd_288, 1), " (", g_spread_276, " pips)"), TextColor2, gi_652, gi_648 - 1, 56);
  1493. f0_36("Leverage:");
  1494. f0_36(AccountLeverage() + ":1", TextColor2, gi_652, gi_648 - 1, 70);
  1495. if (AccountLeverage() < 100) {
  1496. f0_36("Warning:");
  1497. f0_36("Your account leverage is lower than 1:100,", TextColor2, gi_652, gi_648 - 1, 63);
  1498. f0_36("the lot size will be reduced to prevent a loss.", TextColor2, gi_652, gi_648, 70);
  1499. }
  1500. if (gi_1128 != gi_692) {
  1501. if (gi_692) Print("Not enough money! Available margin = ", DoubleToStr(AccountFreeMargin(), 2), ", Required margin = ", DoubleToStr(ld_8, 2));
  1502. gi_1128 = gi_692;
  1503. }
  1504. if (gi_692) {
  1505. f0_34();
  1506. f0_36("Not enough money!");
  1507. f0_36("Available margin =");
  1508. f0_36(DoubleToStr(AccountFreeMargin(), 2), TextColor2, gi_652, gi_648 - 1, 133);
  1509. f0_36("Required margin =");
  1510. f0_36(DoubleToStr(ld_8, 2), TextColor2, gi_652, gi_648 - 1, 126);
  1511. }
  1512. f0_34();
  1513. if (IsTesting()) f0_36("Backtesting");
  1514. else {
  1515. GetStatus(gi_328, g_spread_276, gd_296, gd_344, AccountBalance());
  1516. gd_344 = 0;
  1517. }
  1518. if (gi_236 && gi_512) {
  1519. if (gi_908 == 0) f0_36("Analyzing market");
  1520. else f0_36(f0_37(gi_908) + " detected");
  1521. if (g_datetime_256 <= gi_916 && gi_908 != gi_912 && gi_912 != 0) f0_36(f0_37(gi_912) + " fading: " + TimeToStr(gi_916 - g_datetime_256, TIME_SECONDS));
  1522. } else f0_36(f0_2(gi_696 || gi_700, "Running", "Collecting Data"));
  1523. if (NFA && g_count_708 > 0) {
  1524. f0_34();
  1525. f0_36("Waiting for trades to close:");
  1526. f0_36(g_count_708, TextColor2, gi_652, gi_648 - 1, 203);
  1527. }
  1528. if (g_ticket_712 >= 0 || g_ticket_716 >= 0 || g_ticket_736 >= 0 || g_ticket_740 >= 0) {
  1529. f0_34();
  1530. if (g_ticket_712 >= 0) f0_36("Strategy1: Long position open");
  1531. if (g_ticket_716 >= 0) f0_36("Strategy1: Short position open");
  1532. if (g_ticket_736 >= 0) f0_36("Strategy2: Long position open");
  1533. if (g_ticket_740 >= 0) f0_36("Strategy2: Short position open");
  1534. }
  1535. str_len_16 = StringLen(gs_384);
  1536. str_len_20 = StringLen(gs_392);
  1537. if (str_len_16 > 1 || str_len_20 > 0) f0_34();
  1538. if (str_len_16 > 1) f0_36(gs_384);
  1539. if (str_len_20 > 0) f0_43(gs_392, TextColor2, gi_652, gi_648 - 1, 7 * (str_len_16 + 1));
  1540. f0_47(gi_652, gi_656);
  1541. gi_656 = gi_652 - 1;
  1542. ObjectsRedraw();
  1543. LinksEnd(gi_328);
  1544. return (0);
  1545. }

comments powered by Disqus