1. //+------------------------------------------------------------------+
  2. //|
  3. //| Copyright 2023, lengockhanhhai|
  4. //+------------------------------------------------------------------+
  5. #property copyright "2023.";
  6. #property link "[email protected]"
  7. #property version "1.20";
  8. #property strict
  9.  
  10. extern string Minimal_Deposit = "$100 (Cent Account)";
  11. extern string Time_Frame = "Time Frame H1";
  12. extern string Pairs = "AudCad / EurChf";
  13. extern bool Use_Daily_Target = true;
  14. extern double Daily_Target = 100;
  15. extern bool Hidden_TP = true;
  16. extern double Hiden_TP = 500;
  17. extern double Lot = 0.01;
  18. extern double LotMultiplikator = 1.30;
  19. extern double TakeProfit = 200;
  20.  
  21. //--- Smart Grid Distance Settings ---
  22. extern double Step = 250; // Initial distance between trade 1 and 2 (in points)
  23. extern double Step_Multiplier = 1.20; // Multiplier for subsequent grid distances (1.0 = Fixed)
  24.  
  25. extern double Averaging = 1;
  26. extern int MaxTrades = 12;
  27. //--- AutoLot and Risk Management Settings ---
  28. extern bool Use_AutoLot = true; // Enable Automatic Lot calculation
  29. extern double AutoLot_BaseBalance = 10000;// Base balance amount (e.g., 10000)
  30. extern double AutoLot_BaseLot = 0.01; // Target lot for base balance (e.g., 0.01)
  31. extern double Max_Allowed_Lot = 1.00; // Maximum allowable lot cap for any trade
  32.  
  33. extern bool UseEquityStop;
  34. extern double TotalEquityRisk = 20;
  35. extern int Open_Hour;
  36. extern int Close_Hour = 23;
  37. extern bool TradeOnThursday = true;
  38. extern int Thursday_Hour = 12;
  39. extern bool TradeOnFriday = true;
  40. extern int Friday_Hour = 20;
  41. extern bool Filter_Sideway = true;
  42. extern bool Filter_News = true;
  43. extern bool invisible_mode = true;
  44. extern double OpenRangePips = 1;
  45. extern double MaxDailyRange = 20000;
  46.  
  47. string I_s_0;
  48. int I_i_0;
  49. double I_d_0;
  50. double I_d_1;
  51. int I_i_1;
  52. double G_d_2;
  53. int G_i_2;
  54. int G_i_3;
  55. double G_d_3;
  56. int G_i_4;
  57. int G_i_5;
  58. int G_i_6;
  59. int G_i_7;
  60. int G_i_8;
  61. int G_i_9;
  62. int G_i_10;
  63. int G_i_11;
  64. int G_i_12;
  65. int G_i_13;
  66. int G_i_14;
  67. int G_i_15;
  68. double G_d_4;
  69. int G_i_16;
  70. int G_i_17;
  71. int G_i_18;
  72. int G_i_19;
  73. int G_i_20;
  74. double G_d_5;
  75. int G_i_21;
  76. int G_i_22;
  77. int G_i_23;
  78. double G_d_6;
  79. int G_i_24;
  80. int G_i_25;
  81. int G_i_26;
  82. double G_d_7;
  83. int G_i_27;
  84. int G_i_28;
  85. int G_i_29;
  86. double G_d_8;
  87. int G_i_30;
  88. int G_i_31;
  89. int G_i_32;
  90. double G_d_9;
  91. double G_d_10;
  92. int G_i_33;
  93. int G_i_34;
  94. double G_d_11;
  95. int G_i_35;
  96. int G_i_36;
  97. int G_i_37;
  98. double G_d_12;
  99. double G_d_13;
  100. int G_i_38;
  101. int G_i_39;
  102. double G_d_14;
  103. int G_i_40;
  104. int G_i_41;
  105. int G_i_42;
  106. double G_d_15;
  107. int G_i_43;
  108. int G_i_44;
  109. double G_d_16;
  110. int G_i_45;
  111. int G_i_46;
  112. bool G_b_0;
  113. double G_d_17;
  114. double G_d_18;
  115. int G_i_47;
  116. int G_i_48;
  117. double G_d_19;
  118. int G_i_49;
  119. int G_i_50;
  120. int G_i_51;
  121. double G_d_20;
  122. double G_d_21;
  123. int G_i_52;
  124. int G_i_53;
  125. double G_d_22;
  126. int G_i_54;
  127. int G_i_55;
  128. int G_i_56;
  129. bool G_b_1;
  130. double G_d_23;
  131. double G_d_24;
  132. int G_i_57;
  133. int G_i_58;
  134. double G_d_25;
  135. int G_i_59;
  136. int G_i_60;
  137. int G_i_61;
  138. double G_d_26;
  139. double G_d_27;
  140. int G_i_62;
  141. int G_i_63;
  142. double G_d_28;
  143. int G_i_64;
  144. int G_i_65;
  145. int G_i_66;
  146. int G_i_67;
  147. int G_i_68;
  148. bool I_b_2;
  149. bool G_b_3;
  150. double G_d_29;
  151. double I_d_30;
  152. double G_d_31;
  153. double I_d_32;
  154. bool G_b_4;
  155. string I_s_1;
  156. bool I_b_5;
  157. double G_d_33;
  158. long G_l_1;
  159. long I_l_2;
  160. int G_i_70;
  161. bool I_b_7;
  162. int I_i_71;
  163. double I_d_34;
  164. int G_i_73;
  165. int G_i_75;
  166. bool G_b_9;
  167. double I_d_43;
  168. bool I_b_10;
  169. double I_d_44;
  170. int I_i_76;
  171. int I_i_77;
  172. double I_d_45;
  173. double I_d_46;
  174. double I_d_47;
  175. bool I_b_11;
  176. int I_i_78;
  177. int I_i_79;
  178. bool I_b_12;
  179. double I_d_48;
  180. double I_d_49;
  181. double I_d_50;
  182. bool I_b_13;
  183. long G_l_3;
  184. long G_l_4;
  185. int I_i_80;
  186. int G_i_81;
  187. int I_i_84;
  188. double G_d_55;
  189. double G_d_56;
  190. int G_i_85;
  191. double I_d_57;
  192. double I_d_58;
  193. int G_i_87;
  194. bool I_b_16;
  195. int I_i_88;
  196. bool I_b_17;
  197. bool I_b_18;
  198. bool I_b_19;
  199. double I_d_63;
  200. double I_d_64;
  201. bool I_b_20;
  202. double G_d_65;
  203. bool I_b_22;
  204. double I_d_66;
  205. int G_i_89;
  206. bool I_b_23;
  207. double I_d_67;
  208. double I_d_69;
  209. bool I_b_24;
  210. int I_i_90;
  211. string I_s_2;
  212. int G_i_91;
  213. int I_i_92;
  214. double G_d_70;
  215. int G_i_93;
  216. int G_i_97;
  217. double I_d_74;
  218. double I_d_75;
  219. int I_i_98;
  220. int G_i_99;
  221. long G_l_5;
  222. double I_d_76;
  223. double G_d_77;
  224. int G_i_100;
  225. double G_d_78;
  226. double I_d_79;
  227. double I_d_80;
  228. double I_d_81;
  229. double I_d_82;
  230. double I_d_83;
  231. double I_d_84;
  232. int G_i_102;
  233. long G_l_6;
  234. long G_l_7;
  235. int G_i_105;
  236. int G_i_106;
  237. long G_l_8;
  238. long G_l_9;
  239. int G_i_110;
  240. int G_i_111;
  241. int G_i_112;
  242. long G_l_10;
  243. long G_l_11;
  244. int G_i_115;
  245. long G_l_12;
  246. long G_l_13;
  247. int G_i_119;
  248. long G_l_14;
  249. long G_l_15;
  250. int G_i_124;
  251. long G_l_16;
  252. long G_l_17;
  253. double G_d_104;
  254. double I_d_105;
  255. string I_s_3;
  256. int I_i_129;
  257. string I_s_4;
  258. string I_s_5;
  259. string I_s_6;
  260. string I_s_7;
  261. int I_i_130;
  262. int I_i_131;
  263. int I_i_132;
  264. int I_i_133;
  265. int I_i_134;
  266. int I_i_135;
  267. int I_i_136;
  268. int I_i_137;
  269. bool I_b_43;
  270. string I_s_8;
  271. string I_s_9;
  272. double G_d_106;
  273. double G_d_108;
  274. long G_l_20;
  275. long G_l_21;
  276. long G_l_22;
  277. long G_l_23;
  278. double G_d_109;
  279. double G_d_110;
  280. double G_d_111;
  281. double G_d_112;
  282. double G_d_113;
  283. double G_d_114;
  284. double G_d_115;
  285. double G_d_116;
  286. double G_d_117;
  287. double G_d_118;
  288. double G_d_119;
  289. double G_d_120;
  290. int G_i_139;
  291. double G_d_121;
  292. double G_d_122;
  293. double G_d_123;
  294. double G_d_124;
  295. bool G_b_44;
  296. double G_d_125;
  297. double G_d_126;
  298. bool G_b_45;
  299. int G_i_143;
  300. bool G_b_46;
  301. bool G_b_47;
  302. double G_d_127;
  303. double G_d_128;
  304. int G_i_146;
  305. bool G_b_48;
  306. double returned_double;
  307.  
  308.  
  309. //+------------------------------------------------------------------+
  310. //| |
  311. //+------------------------------------------------------------------+
  312. int init() {
  313. I_s_2 = "Euro Scalper";
  314. I_d_67 = 2;
  315. I_s_3 = "Euro Scalper";
  316. I_i_129 = 1;
  317. I_s_4 = " MARTIN 1 - on. 2 - off.";
  318. I_i_98 = 1;
  319. I_b_24 = true;
  320. I_d_45 = 0;
  321. I_d_34 = 5;
  322. I_s_5 = "true = Fixed Lot, false = Account Balance";
  323. I_b_10 = true;
  324. I_d_105 = 30;
  325. I_d_44 = 0;
  326. I_d_30 = 0;
  327. I_i_77 = 1;
  328. I_d_46 = 0;
  329. I_d_82 = 0;
  330. I_d_50 = 10;
  331. I_d_49 = 10;
  332. I_d_47 = 0;
  333. I_s_6 = "汤X Number of trades 29 max 27 2x";
  334. I_s_7 = "Stop Loss";
  335. I_b_23 = false;
  336. I_b_12 = false;
  337. I_b_13 = false;
  338. I_d_76 = 48;
  339. I_b_11 = false;
  340. I_i_79 = 2;
  341. I_i_78 = 16;
  342. I_i_0 = 1111111;
  343. I_i_71 = 0;
  344. I_b_20 = true;
  345. I_d_43 = 0;
  346. I_d_80 = 0;
  347. I_d_66 = 0;
  348. I_d_81 = 0;
  349. I_d_84 = 0;
  350. I_d_48 = 0;
  351. I_d_74 = 0;
  352. I_d_75 = 0;
  353. I_d_63 = 0;
  354. I_d_64 = 0;
  355. I_d_1 = 0;
  356. I_b_17 = false;
  357. I_i_130 = 0;
  358. I_i_80 = 0;
  359. I_i_90 = 0;
  360. I_d_69 = 0;
  361. I_i_84 = 0;
  362. I_i_88 = 0;
  363. I_d_83 = 0;
  364. I_b_22 = false;
  365. I_b_18 = false;
  366. I_b_19 = false;
  367. I_i_92 = 0;
  368. I_b_16 = false;
  369. I_i_131 = 0;
  370. I_i_132 = 0;
  371. I_d_57 = 0;
  372. I_d_58 = 0;
  373. I_i_133 = 14;
  374. I_i_134 = 55295;
  375. I_i_135 = 42495;
  376. I_i_136 = 8421504;
  377. I_i_137 = 5197615;
  378. I_i_76 = -2;
  379. I_b_7 = false;
  380. I_b_5 = false;
  381. I_b_43 = true;
  382. I_s_9 = "ACCOUNT ANDA BELUM TERDAFTAR! UNTUK DIPAKAI DI LIVE ACCOUNT,HUBUNGI https://www.facebook.com/septi.fx.profit";;
  383. int L_i_15;
  384. L_i_15 = 0;
  385. I_s_0 = "Daftar account,358795,3720446,71328690,3710974,64513290,71417917,71328956,71423205,,,";
  386. if (_Symbol == "AUDCADm" || _Symbol == "AUDCAD") {
  387. I_i_0 = 101101;
  388. }
  389. if (_Symbol == "AUDJPYm" || _Symbol == "AUDJPY") {
  390. I_i_0 = 101102;
  391. }
  392. if (_Symbol == "AUDNZDm" || _Symbol == "AUDNZD") {
  393. I_i_0 = 101103;
  394. }
  395. if (_Symbol == "AUDUSDm" || _Symbol == "AUDUSD") {
  396. I_i_0 = 101104;
  397. }
  398. if (_Symbol == "CHFJPYm" || _Symbol == "CHFJPY") {
  399. I_i_0 = 101105;
  400. }
  401. if (_Symbol == "EURAUDm" || _Symbol == "EURAUD") {
  402. I_i_0 = 101106;
  403. }
  404. if (_Symbol == "EURCADm" || _Symbol == "EURCAD") {
  405. I_i_0 = 101107;
  406. }
  407. if (_Symbol == "EURCHFm" || _Symbol == "EURCHF") {
  408. I_i_0 = 101108;
  409. }
  410. if (_Symbol == "EURGBPm" || _Symbol == "EURGBP") {
  411. I_i_0 = 101109;
  412. }
  413. if (_Symbol == "EURJPYm" || _Symbol == "EURJPY") {
  414. I_i_0 = 101110;
  415. }
  416. if (_Symbol == "EURUSDm" || _Symbol == "EURUSD") {
  417. I_i_0 = 101111;
  418. }
  419. if (_Symbol == "GBPCHFm" || _Symbol == "GBPCHF") {
  420. I_i_0 = 101112;
  421. }
  422. if (_Symbol == "GBPJPYm" || _Symbol == "GBPJPY") {
  423. I_i_0 = 101113;
  424. }
  425. if (_Symbol == "GBPUSDm" || _Symbol == "GBPUSD") {
  426. I_i_0 = 101114;
  427. }
  428. if (_Symbol == "NZDJPYm" || _Symbol == "NZDJPY") {
  429. I_i_0 = 101115;
  430. }
  431. if (_Symbol == "NZDUSDm" || _Symbol == "NZDUSD") {
  432. I_i_0 = 101116;
  433. }
  434. if (_Symbol == "USDCHFm" || _Symbol == "USDCHF") {
  435. I_i_0 = 101117;
  436. }
  437. if (_Symbol == "USDJPYm" || _Symbol == "USDJPY") {
  438. I_i_0 = 101118;
  439. }
  440. if (_Symbol == "USDCADm" || _Symbol == "USDCAD") {
  441. I_i_0 = 101119;
  442. }
  443. if (I_i_0 == 0) {
  444. I_i_0 = 999999;
  445. }
  446. I_d_1 = (MarketInfo(_Symbol, MODE_SPREAD) * _Point);
  447. L_i_15 = 0;
  448. return 0;
  449. }
  450.  
  451. //+------------------------------------------------------------------+
  452. //| |
  453. //+------------------------------------------------------------------+
  454. int start() {
  455. string S_s_20;
  456. string S_s_21;
  457. string S_s_22;
  458. string S_s_23;
  459. string S_s_14;
  460. string S_s_15;
  461. string S_s_16;
  462. string S_s_17;
  463. string S_s_18;
  464. string S_s_19;
  465. int L_i_15;
  466. int L_i_11;
  467. string L_s_0;
  468. double L_d_0;
  469. double L_d_1;
  470. double L_d_2;
  471. double L_d_3;
  472. int L_i_3;
  473. int L_i_4;
  474. double L_d_4;
  475. double L_d_5;
  476. double L_d_6;
  477. int L_i_5;
  478. string L_s_1;
  479. string L_s_2;
  480. double L_d_7;
  481. double L_d_8;
  482. double L_d_9;
  483. double L_d_10;
  484. double L_d_11;
  485. double L_d_12;
  486. L_i_15 = 0;
  487. L_i_11 = 0;
  488. L_d_0 = 0;
  489. L_d_1 = 0;
  490. L_d_2 = 0;
  491. L_d_3 = 0;
  492. L_i_3 = 0;
  493. L_i_4 = 0;
  494. L_d_4 = 0;
  495. L_d_5 = 0;
  496. L_d_6 = 0;
  497. L_i_5 = 0;
  498. L_d_7 = 0;
  499. L_d_8 = 0;
  500. L_d_9 = 0;
  501. L_d_10 = 0;
  502. L_d_11 = 0;
  503. L_d_12 = 0;
  504. G_d_2 = 0;
  505. G_i_2 = 0;
  506. G_i_3 = 0;
  507. G_d_3 = 0;
  508. G_i_4 = 0;
  509. G_i_5 = 0;
  510. G_i_6 = 0;
  511. G_i_7 = 0;
  512. G_i_8 = 0;
  513. G_i_9 = 0;
  514. G_i_10 = 0;
  515. G_i_11 = 0;
  516. G_i_12 = 0;
  517. G_i_13 = 0;
  518. G_i_14 = 0;
  519. G_i_15 = 0;
  520. G_d_4 = 0;
  521. G_i_16 = 0;
  522. G_i_17 = 0;
  523. G_i_18 = 0;
  524. G_i_19 = 0;
  525. G_i_20 = 0;
  526. G_d_5 = 0;
  527. G_i_21 = 0;
  528. G_i_22 = 0;
  529. G_i_23 = 0;
  530. G_d_6 = 0;
  531. G_i_24 = 0;
  532. G_i_25 = 0;
  533. G_i_26 = 0;
  534. G_d_7 = 0;
  535. G_i_27 = 0;
  536. G_i_28 = 0;
  537. G_i_29 = 0;
  538. G_d_8 = 0;
  539. G_i_30 = 0;
  540. G_i_31 = 0;
  541. G_i_32 = 0;
  542. G_d_9 = 0;
  543. G_d_10 = 0;
  544. G_i_33 = 0;
  545. G_i_34 = 0;
  546. G_d_11 = 0;
  547. G_i_35 = 0;
  548. G_i_36 = 0;
  549. G_i_37 = 0;
  550. G_d_12 = 0;
  551. G_d_13 = 0;
  552. G_i_38 = 0;
  553. G_i_39 = 0;
  554. G_d_14 = 0;
  555. G_i_40 = 0;
  556. G_i_41 = 0;
  557. G_i_42 = 0;
  558. G_d_15 = 0;
  559. G_i_43 = 0;
  560. G_i_44 = 0;
  561. G_d_16 = 0;
  562. G_i_45 = 0;
  563. G_i_46 = 0;
  564. G_b_0 = false;
  565. G_d_17 = 0;
  566. G_d_18 = 0;
  567. G_i_47 = 0;
  568. G_i_48 = 0;
  569. G_d_19 = 0;
  570. G_i_49 = 0;
  571. G_i_50 = 0;
  572. G_i_51 = 0;
  573. G_d_20 = 0;
  574. G_d_21 = 0;
  575. G_i_52 = 0;
  576. G_i_53 = 0;
  577. G_d_22 = 0;
  578. G_i_54 = 0;
  579. G_i_55 = 0;
  580. G_i_56 = 0;
  581. G_b_1 = false;
  582. G_d_23 = 0;
  583. G_d_24 = 0;
  584. G_i_57 = 0;
  585. G_i_58 = 0;
  586. G_d_25 = 0;
  587. G_i_59 = 0;
  588. G_i_60 = 0;
  589. G_i_61 = 0;
  590. G_d_26 = 0;
  591. G_d_27 = 0;
  592. G_i_62 = 0;
  593. G_i_63 = 0;
  594. G_d_28 = 0;
  595. G_i_64 = 0;
  596. G_i_65 = 0;
  597. G_i_66 = 0;
  598. G_i_67 = 0;
  599. G_i_68 = 0;
  600. /*
  601. if (IsTesting()) {
  602. Alert("This EA Cannot be Backtest (Maaf ya EA tidak Bisa di Backtest wkwkwkwkw) ");
  603. L_i_15 = 0;
  604. return L_i_15;
  605. }
  606. */
  607. L_i_11 = ObjectsTotal(-1) - 1;
  608. if (L_i_11 >= 0) {
  609. do {
  610. L_s_0 = ObjectName(L_i_11);
  611. if ((ObjectGet(L_s_0, OBJPROP_TIME1) > 0)) {
  612. G_d_29 = ObjectGet(L_s_0, OBJPROP_TIME1);
  613. G_d_31 = (I_d_30 * 86400);
  614. if ((G_d_29 < (Time[0] - G_d_31))) {
  615. ObjectDelete(L_s_0);
  616. }
  617. }
  618. L_i_11 = L_i_11 - 1;
  619. } while (L_i_11 >= 0);
  620. }
  621. /*
  622. S_s_20 = (string)AccountNumber();
  623. S_s_20 = "," + S_s_20;
  624. S_s_20 = S_s_20 + ",";
  625. I_s_1 = S_s_20;
  626. I_i_1 = StringFind(I_s_0, I_s_1, 0);
  627. if (I_i_1 == -1) {
  628. I_b_5 = false;
  629. }
  630. else {
  631. I_b_5 = true;
  632. }
  633.  
  634. if (I_i_1 == 238 && IsDemo() == false) {
  635. Alert("ACCOUNT ANDA BELUM TERDAFTAR!HUBUNGI https://www.facebook.com/septi.fx.profit";);
  636. ObjectCreate(0, "Copyright", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
  637. ObjectSet("Copyright", OBJPROP_XDISTANCE, 1);
  638. ObjectSet("Copyright", OBJPROP_YDISTANCE, 20);
  639. ObjectSetText("Copyright", "For Aktivasi EA => https://www.facebook.com/septi.fx.profit";, 20, "Times New Roman", 65535);
  640. L_i_15 = 0;
  641. return L_i_15;
  642. }
  643. */
  644. ObjectCreate(0, "j", OBJ_LABEL, 0, 0, 0, 0, 0, 0, 0);
  645. ObjectSet("j", OBJPROP_CORNER, 4);
  646. ObjectSet("j", OBJPROP_XDISTANCE, 4);
  647. ObjectSet("j", OBJPROP_YDISTANCE, 10);
  648. ObjectSetText("j", "Euro Scalper NDD", 19, "Times New Roman Bold", 65280);
  649. S_s_20 = "\nLisensi https://www.facebook.com/septi.fx.profit \n================================\nINFORMATION:\n Nama Broker " + AccountCompany();
  650. S_s_20 = S_s_20 + "\n";
  651. S_s_20 = S_s_20 + "================================";
  652. S_s_20 = S_s_20 + "\n";
  653. S_s_20 = S_s_20 + "ACC INFORMATION:";
  654. S_s_20 = S_s_20 + "\n";
  655. S_s_20 = S_s_20 + " Nomor Account :";
  656. S_s_21 = (string)AccountNumber();
  657. S_s_20 = S_s_20 + S_s_21;
  658. S_s_20 = S_s_20 + "\n";
  659. S_s_20 = S_s_20 + " Account Leverage: ";
  660. S_s_20 = S_s_20 + DoubleToString(AccountLeverage(), 0);
  661. S_s_20 = S_s_20 + "\n";
  662. S_s_20 = S_s_20 + " Mata Uang : ";
  663. S_s_20 = S_s_20 + AccountCurrency();
  664. S_s_20 = S_s_20 + "\n";
  665. S_s_20 = S_s_20 + " EQUITY: ";
  666. S_s_20 = S_s_20 + DoubleToString(AccountEquity(), 2);
  667. S_s_20 = S_s_20 + "\n";
  668. S_s_20 = S_s_20 + " BALANCE:";
  669. S_s_20 = S_s_20 + DoubleToString(AccountBalance(), 2);
  670. S_s_20 = S_s_20 + "\n";
  671. S_s_20 = S_s_20 + "=================";
  672. S_s_20 = S_s_20 + "\n";
  673. S_s_20 = S_s_20 + "MARGIN INFORMATION:";
  674. S_s_20 = S_s_20 + "\n";
  675. S_s_20 = S_s_20 + " Free Margin : ";
  676. S_s_20 = S_s_20 + DoubleToString(AccountFreeMargin(), 2);
  677. S_s_20 = S_s_20 + "\n";
  678. S_s_20 = S_s_20 + " Used Margin : ";
  679. S_s_20 = S_s_20 + DoubleToString(AccountMargin(), 2);
  680. Comment("\n ", S_s_20, "\n\n\n :: Spread: ", MarketInfo(_Symbol, MODE_SPREAD), "\n=================");
  681. L_d_0 = 0;
  682. L_d_1 = 0;
  683. L_d_2 = 0;
  684. L_d_3 = 0;
  685. L_i_3 = (int)MarketInfo(_Symbol, MODE_STOPLEVEL);
  686. L_i_4 = (int)MarketInfo(_Symbol, MODE_SPREAD);
  687. L_d_4 = MarketInfo(_Symbol, MODE_POINT);
  688. L_d_5 = MarketInfo(_Symbol, MODE_BID);
  689. L_d_6 = MarketInfo(_Symbol, MODE_ASK);
  690. L_i_5 = (int)MarketInfo(_Symbol, MODE_DIGITS);
  691. if (Use_Daily_Target) {
  692. G_d_2 = 0;
  693. G_i_2 = HistoryTotal();
  694. if (G_i_2 >= 0) {
  695. do {
  696. if (OrderSelect(G_i_2, 0, 1) && OrderMagicNumber() == I_i_0) {
  697. G_l_1 = OrderCloseTime();
  698. if (G_l_1 >= iTime(_Symbol, 1440, 0) && OrderType() <= OP_SELL) {
  699. G_d_33 = OrderProfit();
  700. G_d_33 = (G_d_33 + OrderCommission());
  701. G_d_2 = ((G_d_33 + OrderSwap()) + G_d_2);
  702. }
  703. }
  704. G_i_2 = G_i_2 - 1;
  705. } while (G_i_2 >= 0);
  706. }
  707. if ((G_d_2 >= Daily_Target)) {
  708. G_i_70 = OrdersTotal() - 1;
  709. G_i_3 = G_i_70;
  710. if (G_i_70 >= 0) {
  711. do {
  712. I_b_7 = OrderSelect(G_i_3, 0, 0);
  713. if (OrderSymbol() == _Symbol) {
  714. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  715. if (OrderType() == OP_BUY) {
  716. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Bid, (int)I_d_34, 16711680);
  717. }
  718. if (OrderType() == OP_SELL) {
  719. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Ask, (int)I_d_34, 255);
  720. }
  721. }
  722. Sleep(1000);
  723. }
  724. G_i_3 = G_i_3 - 1;
  725. } while (G_i_3 >= 0);
  726. }
  727. Print("\nSelamat target harian tercapai");
  728. L_i_15 = 0;
  729. return L_i_15;
  730. }
  731. }
  732. if (Hidden_TP) {
  733. G_d_3 = 0;
  734. G_i_4 = 0;
  735. G_i_4 = 0;
  736. if (OrdersTotal() > 0) {
  737. do {
  738. if (!OrderSelect(G_i_4, 0, 0) || (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_0)) {
  739. G_d_3 = (G_d_3 + OrderProfit());
  740. }
  741. G_i_4 = G_i_4 + 1;
  742. } while (G_i_4 < OrdersTotal());
  743. }
  744. if ((Hiden_TP <= G_d_3)) {
  745. Print("\nMagic Take Profit");
  746. G_i_73 = OrdersTotal() - 1;
  747. G_i_5 = G_i_73;
  748. if (G_i_73 >= 0) {
  749. do {
  750. I_b_7 = OrderSelect(G_i_5, 0, 0);
  751. if (OrderSymbol() == _Symbol) {
  752. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  753. if (OrderType() == OP_BUY) {
  754. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Bid, (int)I_d_34, 16711680);
  755. }
  756. if (OrderType() == OP_SELL) {
  757. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Ask, (int)I_d_34, 255);
  758. }
  759. }
  760. Sleep(1000);
  761. }
  762. G_i_5 = G_i_5 - 1;
  763. } while (G_i_5 >= 0);
  764. }
  765. }
  766. }
  767. if ((I_d_43 == 0)) {
  768. I_d_43 = AccountBalance();
  769. }
  770. if (I_b_10) {
  771. I_d_44 = CalculateSmartLot();
  772. } else {
  773. if ((I_d_44 == -1)) {
  774. I_d_44 = (((AccountBalance() * I_d_105) / 100) / 10000);
  775. } else {
  776. if ((I_i_76 == Averaging)) {
  777. if (I_i_77 == 1) {
  778. I_d_44 = (I_d_44 * LotMultiplikator);
  779. } else {
  780. I_d_44 = (I_d_44 + Lot);
  781. }
  782. }
  783. }
  784. }
  785. if ((I_i_76 >= Averaging)) {
  786. I_i_76 = -2;
  787. }
  788. G_i_7 = 0;
  789. S_s_21 = _Symbol;
  790. G_i_8 = OrdersTotal();
  791. G_i_9 = 0;
  792. G_i_10 = 0;
  793. if (G_i_8 > 0) {
  794. do {
  795. bool order_select = OrderSelect(G_i_10, 0, 0);
  796. if (OrderMagicNumber() == I_i_0 && OrderSymbol() == S_s_21 && G_i_7 == OrderType()) {
  797. G_i_75 = G_i_9 + 1;
  798. G_i_9 = G_i_75;
  799. }
  800. G_i_10 = G_i_10 + 1;
  801. } while (G_i_10 < G_i_8);
  802. }
  803. G_i_6 = G_i_9;
  804. G_i_11 = 1;
  805. S_s_22 = _Symbol;
  806. G_i_12 = OrdersTotal();
  807. G_i_13 = 0;
  808. G_i_14 = 0;
  809. if (G_i_12 > 0) {
  810. do {
  811. bool order_select = OrderSelect(G_i_14, 0, 0);
  812. if (OrderMagicNumber() == I_i_0 && OrderSymbol() == S_s_22 && G_i_11 == OrderType()) {
  813. G_i_75 = G_i_13 + 1;
  814. G_i_13 = G_i_75;
  815. }
  816. G_i_14 = G_i_14 + 1;
  817. } while (G_i_14 < G_i_12);
  818. }
  819. G_i_75 = G_i_6 + G_i_13;
  820. if (G_i_75 == 0) {
  821. I_i_76 = -2;
  822. G_b_9 = (I_d_43 != AccountBalance());
  823. if (G_b_9) {
  824. I_d_43 = 0;
  825. I_d_44 = 0;
  826. }
  827. }
  828. if (I_i_77 == 1) {
  829. I_d_45 = LotMultiplikator;
  830. } else {
  831. I_d_45 = Lot;
  832. }
  833. I_d_46 = TakeProfit;
  834. I_d_47 = Step;
  835. I_i_71 = I_i_0;
  836. L_s_1 = "false";
  837. L_s_2 = "false";
  838. G_i_75 = I_b_11;
  839. if ((G_i_75 == 0)
  840. || (I_b_11 && I_i_78 > I_i_79 && Hour() >= I_i_79 && Hour() <= I_i_78)
  841. || (I_i_79 > I_i_78 && Hour() < I_i_78 && Hour() > I_i_79)) {
  842. L_s_1 = "true";
  843. }
  844. if (I_b_11) {
  845. if ((I_i_78 > I_i_79 && Hour() < I_i_79 && Hour() > I_i_78)
  846. || (I_i_79 > I_i_78 && Hour() >= I_i_78 && Hour() <= I_i_79)) {
  847. L_s_2 = "true";
  848. }
  849. }
  850. if (I_b_12) {
  851. f0_18((int)I_d_50, (int)I_d_49, (int)I_d_48);
  852. }
  853. if (I_b_13) {
  854. G_l_3 = TimeCurrent();
  855. G_l_4 = I_i_80;
  856. if (G_l_3 >= G_l_4) {
  857. G_i_81 = OrdersTotal() - 1;
  858. G_i_15 = G_i_81;
  859. if (G_i_81 >= 0) {
  860. do {
  861. I_b_7 = OrderSelect(G_i_15, 0, 0);
  862. if (OrderSymbol() == _Symbol) {
  863. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  864. if (OrderType() == OP_BUY) {
  865. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Bid, (int)I_d_34, 16711680);
  866. }
  867. if (OrderType() == OP_SELL) {
  868. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Ask, (int)I_d_34, 255);
  869. }
  870. }
  871. Sleep(1000);
  872. }
  873. G_i_15 = G_i_15 - 1;
  874. } while (G_i_15 >= 0);
  875. }
  876. Print("Closed All due to TimeOut");
  877. }
  878. }
  879. G_d_4 = 0;
  880. I_i_84 = OrdersTotal() - 1;
  881. if (I_i_84 >= 0) {
  882. do {
  883. I_b_7 = OrderSelect(I_i_84, 0, 0);
  884. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  885. if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
  886. G_d_4 = (G_d_4 + OrderProfit());
  887. }
  888. }
  889. I_i_84 = I_i_84 - 1;
  890. } while (I_i_84 >= 0);
  891. }
  892. L_d_7 = G_d_4;
  893. if (UseEquityStop && (G_d_4 < 0)) {
  894. G_d_55 = fabs(G_d_4);
  895. G_d_56 = (TotalEquityRisk / 100);
  896. G_i_16 = 0;
  897. G_i_85 = OrdersTotal() - 1;
  898. G_i_17 = G_i_85;
  899. if (G_i_85 >= 0) {
  900. do {
  901. I_b_7 = OrderSelect(G_i_17, 0, 0);
  902. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  903. if (OrderType() == OP_SELL || OrderType() == OP_BUY) {
  904. G_i_16 = G_i_16 + 1;
  905. }
  906. }
  907. G_i_17 = G_i_17 - 1;
  908. } while (G_i_17 >= 0);
  909. }
  910. if (G_i_16 == 0) {
  911. I_d_57 = AccountEquity();
  912. }
  913. if ((I_d_57 < I_d_58)) {
  914. I_d_57 = I_d_58;
  915. } else {
  916. I_d_57 = AccountEquity();
  917. }
  918. I_d_58 = AccountEquity();
  919. if ((G_d_55 > (G_d_56 * I_d_57))) {
  920. G_i_85 = OrdersTotal() - 1;
  921. G_i_18 = G_i_85;
  922. if (G_i_85 >= 0) {
  923. do {
  924. I_b_7 = OrderSelect(G_i_18, 0, 0);
  925. if (OrderSymbol() == _Symbol) {
  926. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  927. if (OrderType() == OP_BUY) {
  928. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Bid, (int)I_d_34, 16711680);
  929. }
  930. if (OrderType() == OP_SELL) {
  931. I_b_7 = OrderClose(OrderTicket(), OrderLots(), Ask, (int)I_d_34, 255);
  932. }
  933. }
  934. Sleep(1000);
  935. }
  936. G_i_18 = G_i_18 - 1;
  937. } while (G_i_18 >= 0);
  938. }
  939. Print("Closed All due to Stop Out");
  940. I_b_16 = false;
  941. }
  942. }
  943. G_i_19 = 0;
  944. G_i_87 = OrdersTotal() - 1;
  945. G_i_20 = G_i_87;
  946. if (G_i_87 >= 0) {
  947. do {
  948. I_b_7 = OrderSelect(G_i_20, 0, 0);
  949. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  950. if (OrderType() == OP_SELL || OrderType() == OP_BUY) {
  951. G_i_19 = G_i_19 + 1;
  952. }
  953. }
  954. G_i_20 = G_i_20 - 1;
  955. } while (G_i_20 >= 0);
  956. }
  957. I_i_88 = G_i_19;
  958. if (G_i_19 == 0) {
  959. I_b_17 = false;
  960. }
  961. I_i_84 = OrdersTotal() - 1;
  962. if (I_i_84 >= 0) {
  963. do {
  964. I_b_7 = OrderSelect(I_i_84, 0, 0);
  965. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  966. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  967. I_b_18 = true;
  968. I_b_19 = false;
  969. L_d_0 = OrderLots();
  970. break;
  971. }
  972. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  973. I_b_18 = false;
  974. I_b_19 = true;
  975. L_d_1 = OrderLots();
  976. break;
  977. }
  978. }
  979. I_i_84 = I_i_84 - 1;
  980. } while (I_i_84 >= 0);
  981. }
  982. if (I_i_88 > 0 && I_i_88 <= MaxTrades) {
  983. RefreshRates();
  984. G_d_5 = 0;
  985. G_i_21 = 0;
  986. G_i_22 = 0;
  987. G_i_87 = OrdersTotal() - 1;
  988. G_i_23 = G_i_87;
  989. if (G_i_87 >= 0) {
  990. do {
  991. I_b_7 = OrderSelect(G_i_23, 0, 0);
  992. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  993. G_i_21 = OrderTicket();
  994. if (G_i_21 > G_i_22) {
  995. G_d_5 = OrderOpenPrice();
  996. G_i_22 = G_i_21;
  997. }
  998. }
  999. G_i_23 = G_i_23 - 1;
  1000. } while (G_i_23 >= 0);
  1001. }
  1002. I_d_63 = G_d_5;
  1003. G_d_6 = 0;
  1004. G_i_24 = 0;
  1005. G_i_25 = 0;
  1006. G_i_87 = OrdersTotal() - 1;
  1007. G_i_26 = G_i_87;
  1008. if (G_i_87 >= 0) {
  1009. do {
  1010. I_b_7 = OrderSelect(G_i_26, 0, 0);
  1011. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  1012. G_i_24 = OrderTicket();
  1013. if (G_i_24 > G_i_25) {
  1014. G_d_6 = OrderOpenPrice();
  1015. G_i_25 = G_i_24;
  1016. }
  1017. }
  1018. G_i_26 = G_i_26 - 1;
  1019. } while (G_i_26 >= 0);
  1020. }
  1021. I_d_64 = G_d_6;
  1022. if (I_b_20 == 0) {
  1023. if (I_b_18) {
  1024. G_d_65 = (I_d_63 - Ask);
  1025. if ((G_d_65 >= (I_d_47 * _Point))) {
  1026. I_b_22 = true;
  1027. }
  1028. }
  1029. if (I_b_19 != false) {
  1030. G_d_65 = (Bid - I_d_64);
  1031. if ((G_d_65 >= (I_d_47 * _Point))) {
  1032. I_b_22 = true;
  1033. }
  1034. }
  1035. } else {
  1036. if (I_b_20 == true && Volume[0] < 5) {
  1037. if (I_b_18) {
  1038. G_d_104 = (I_d_63 - Ask);
  1039. if ((G_d_104 >= (I_d_47 * _Point))) {
  1040. I_b_22 = true;
  1041. }
  1042. }
  1043. if (I_b_19) {
  1044. G_d_104 = (Bid - I_d_64);
  1045. if ((G_d_104 >= (I_d_47 * _Point))) {
  1046. I_b_22 = true;
  1047. }
  1048. }
  1049. }
  1050. }
  1051. }
  1052. if (I_i_88 < 1) {
  1053. I_b_19 = false;
  1054. I_b_18 = false;
  1055. if (I_b_20 == 0) {
  1056. I_b_22 = true;
  1057. } else {
  1058. if (I_b_20 == true && Volume[0] < 2) {
  1059. I_b_22 = true;
  1060. }
  1061. }
  1062. I_d_66 = AccountEquity();
  1063. I_d_66 = AccountEquity();
  1064. }
  1065. if (I_b_22) {
  1066. G_d_7 = 0;
  1067. G_i_27 = 0;
  1068. G_i_28 = 0;
  1069. G_i_89 = OrdersTotal() - 1;
  1070. G_i_29 = G_i_89;
  1071. if (G_i_89 >= 0) {
  1072. do {
  1073. I_b_7 = OrderSelect(G_i_29, 0, 0);
  1074. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  1075. G_i_27 = OrderTicket();
  1076. if (G_i_27 > G_i_28) {
  1077. G_d_7 = OrderOpenPrice();
  1078. G_i_28 = G_i_27;
  1079. }
  1080. }
  1081. G_i_29 = G_i_29 - 1;
  1082. } while (G_i_29 >= 0);
  1083. }
  1084. I_d_63 = G_d_7;
  1085. G_d_8 = 0;
  1086. G_i_30 = 0;
  1087. G_i_31 = 0;
  1088. G_i_89 = OrdersTotal() - 1;
  1089. G_i_32 = G_i_89;
  1090. if (G_i_89 >= 0) {
  1091. do {
  1092. I_b_7 = OrderSelect(G_i_32, 0, 0);
  1093. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  1094. G_i_30 = OrderTicket();
  1095. if (G_i_30 > G_i_31) {
  1096. G_d_8 = OrderOpenPrice();
  1097. G_i_31 = G_i_30;
  1098. }
  1099. }
  1100. G_i_32 = G_i_32 - 1;
  1101. } while (G_i_32 >= 0);
  1102. }
  1103. I_d_64 = G_d_8;
  1104. if (I_b_19 != false) {
  1105. if (I_b_23 || L_s_2 == "true") {
  1106. f0_1(false, true);
  1107. if (I_i_76 == -2) {
  1108. if (I_i_77 == 1) {
  1109. I_d_69 = NormalizeDouble((I_d_45 * L_d_1), (int)I_d_67);
  1110. } else {
  1111. I_d_69 = NormalizeDouble((Lot + L_d_1), (int)I_d_67);
  1112. }
  1113. }
  1114. } else {
  1115. if (I_i_76 == -2) {
  1116. G_d_10 = 0;
  1117. G_i_33 = 0;
  1118. I_i_1 = I_i_98;
  1119. if (I_i_1 == 0) {
  1120. G_d_10 = I_d_44;
  1121. }
  1122. if (I_i_1 == 1) {
  1123. if (I_i_77 == 1) {
  1124. returned_double = MathPow(I_d_45, I_i_90);
  1125. G_d_10 = NormalizeDouble((I_d_44 * returned_double), (int)I_d_67);
  1126. } else {
  1127. if (I_i_76 == -2) {
  1128. G_d_10 = NormalizeDouble(I_d_44, (int)I_d_67);
  1129. }
  1130. }
  1131. }
  1132. if (I_i_1 == 2) {
  1133. G_i_33 = 0;
  1134. G_d_10 = I_d_44;
  1135. G_i_119 = HistoryTotal() - 1;
  1136. G_i_34 = G_i_119;
  1137. if (G_i_119 >= 0) {
  1138. do {
  1139. if (!OrderSelect(G_i_34, 0, 1)) {
  1140. G_d_9 = -3;
  1141. break;
  1142. }
  1143. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1144. G_l_14 = OrderCloseTime();
  1145. G_l_15 = G_i_33;
  1146. if (G_l_15 < G_l_14) {
  1147. G_i_33 = (int)OrderCloseTime();
  1148. if ((OrderProfit() < 0)) {
  1149. if (I_i_77 == 1) {
  1150. G_d_10 = NormalizeDouble((OrderLots() * I_d_45), (int)I_d_67);
  1151. } else {
  1152. G_d_10 = NormalizeDouble((OrderLots() + Lot), (int)I_d_67);
  1153. }
  1154. } else {
  1155. G_d_10 = I_d_44;
  1156. }
  1157. }
  1158. }
  1159. G_i_34 = G_i_34 - 1;
  1160. } while (G_i_34 >= 0);
  1161. }
  1162. }
  1163. G_i_91 = GetLastError();
  1164. if (G_i_91 == 134) {
  1165. G_d_9 = -2;
  1166. } else {
  1167. G_d_9 = G_d_10;
  1168. }
  1169. I_d_69 = G_d_9;
  1170. }
  1171. }
  1172. if (I_b_24 && L_s_1 == "true") {
  1173. I_i_90 = I_i_88;
  1174. if ((I_d_69 > 0)) {
  1175. RefreshRates();
  1176. S_s_23 = _Symbol + "-";
  1177. S_s_23 = S_s_23 + I_s_2;
  1178. S_s_23 = S_s_23 + "-";
  1179. S_s_14 = (string)I_i_88;
  1180. S_s_23 = S_s_23 + S_s_14;
  1181. I_i_92 = f0_15(1, I_d_69, Bid, (int)I_d_34, Ask, 0, 0, S_s_23, I_i_71, 0, 11823615);
  1182. if (I_i_92 < 0) {
  1183. Print("Error: ", GetLastError());
  1184. L_i_15 = 0;
  1185. return L_i_15;
  1186. }
  1187. G_d_11 = 0;
  1188. G_i_35 = 0;
  1189. G_i_36 = 0;
  1190. G_i_91 = OrdersTotal() - 1;
  1191. G_i_37 = G_i_91;
  1192. if (G_i_91 >= 0) {
  1193. do {
  1194. I_b_7 = OrderSelect(G_i_37, 0, 0);
  1195. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  1196. G_i_35 = OrderTicket();
  1197. if (G_i_35 > G_i_36) {
  1198. G_d_11 = OrderOpenPrice();
  1199. G_i_36 = G_i_35;
  1200. }
  1201. }
  1202. G_i_37 = G_i_37 - 1;
  1203. } while (G_i_37 >= 0);
  1204. }
  1205. I_d_64 = G_d_11;
  1206. I_b_22 = false;
  1207. I_b_16 = true;
  1208. }
  1209. }
  1210. } else {
  1211. if (I_b_18) {
  1212. if (I_b_23 || L_s_2 == "true") {
  1213. f0_1(true, false);
  1214. if (I_i_76 == -2) {
  1215. if (I_i_77 == 1) {
  1216. I_d_69 = NormalizeDouble((I_d_45 * L_d_0), (int)I_d_67);
  1217. if(I_d_69 > Max_Allowed_Lot) I_d_69 = Max_Allowed_Lot;
  1218. } else {
  1219. I_d_69 = NormalizeDouble((Lot + L_d_0), (int)I_d_67);
  1220. }
  1221. }
  1222. } else {
  1223. if (I_i_76 == -2) {
  1224. G_d_13 = 0;
  1225. G_i_38 = 0;
  1226. I_i_1 = I_i_98;
  1227. if (I_i_1 == 0) {
  1228. G_d_13 = I_d_44;
  1229. }
  1230. if (I_i_1 == 1) {
  1231. if (I_i_77 == 1) {
  1232. returned_double = MathPow(I_d_45, I_i_90);
  1233. G_d_13 = NormalizeDouble((I_d_44 * returned_double), (int)I_d_67);
  1234. if(G_d_13 > Max_Allowed_Lot) G_d_13 = Max_Allowed_Lot;
  1235. } else {
  1236. if (I_i_76 == -2) {
  1237. G_d_13 = NormalizeDouble(I_d_44, (int)I_d_67);
  1238. }
  1239. }
  1240. }
  1241. if (I_i_1 == 2) {
  1242. G_i_38 = 0;
  1243. G_d_13 = I_d_44;
  1244. G_i_124 = HistoryTotal() - 1;
  1245. G_i_39 = G_i_124;
  1246. if (G_i_124 >= 0) {
  1247. do {
  1248. if (!OrderSelect(G_i_39, 0, 1)) {
  1249. G_d_12 = -3;
  1250. break;
  1251. }
  1252. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1253. G_l_16 = OrderCloseTime();
  1254. G_l_17 = G_i_38;
  1255. if (G_l_17 < G_l_16) {
  1256. G_i_38 = (int)OrderCloseTime();
  1257. if ((OrderProfit() < 0)) {
  1258. if (I_i_77 == 1) {
  1259. G_d_13 = NormalizeDouble((OrderLots() * I_d_45), (int)I_d_67);
  1260. } else {
  1261. G_d_13 = NormalizeDouble((OrderLots() + Lot), (int)I_d_67);
  1262. }
  1263. } else {
  1264. G_d_13 = I_d_44;
  1265. }
  1266. }
  1267. }
  1268. G_i_39 = G_i_39 - 1;
  1269. } while (G_i_39 >= 0);
  1270. }
  1271. }
  1272. G_i_93 = GetLastError();
  1273. if (G_i_93 == 134) {
  1274. G_d_12 = -2;
  1275. } else {
  1276. G_d_12 = G_d_13;
  1277. }
  1278. I_d_69 = G_d_12;
  1279. }
  1280. }
  1281. if (I_b_24 && L_s_1 == "true") {
  1282. I_i_90 = I_i_88;
  1283. if ((I_d_69 > 0)) {
  1284. S_s_14 = _Symbol + "-";
  1285. S_s_14 = S_s_14 + I_s_2;
  1286. S_s_14 = S_s_14 + "-";
  1287. S_s_15 = (string)I_i_88;
  1288. S_s_14 = S_s_14 + S_s_15;
  1289. I_i_92 = f0_15(0, I_d_69, Ask, (int)I_d_34, Bid, 0, 0, S_s_14, I_i_71, 0, 65280);
  1290. if (I_i_92 < 0) {
  1291. Print("Error: ", GetLastError());
  1292. L_i_15 = 0;
  1293. return L_i_15;
  1294. }
  1295. G_d_14 = 0;
  1296. G_i_40 = 0;
  1297. G_i_41 = 0;
  1298. G_i_93 = OrdersTotal() - 1;
  1299. G_i_42 = G_i_93;
  1300. if (G_i_93 >= 0) {
  1301. do {
  1302. I_b_7 = OrderSelect(G_i_42, 0, 0);
  1303. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  1304. G_i_40 = OrderTicket();
  1305. if (G_i_40 > G_i_41) {
  1306. G_d_14 = OrderOpenPrice();
  1307. G_i_41 = G_i_40;
  1308. }
  1309. }
  1310. G_i_42 = G_i_42 - 1;
  1311. } while (G_i_42 >= 0);
  1312. }
  1313. I_d_63 = G_d_14;
  1314. I_b_22 = false;
  1315. I_b_16 = true;
  1316. }
  1317. }
  1318. }
  1319. }
  1320. }
  1321. if ((OpenRangePips > 0) && (MaxDailyRange > 0)) {
  1322. G_d_15 = 0;
  1323. G_i_43 = DayOfYear();
  1324. G_i_44 = 0;
  1325. if (Bars > 0) {
  1326. do {
  1327. if (TimeDayOfYear(iTime(_Symbol, _Period, G_i_44)) == G_i_43) {
  1328. G_d_15 = iOpen(_Symbol, _Period, G_i_44);
  1329. }
  1330. if (TimeDayOfYear(iTime(_Symbol, _Period, G_i_44)) != G_i_43) break;
  1331. G_i_44 = G_i_44 + 1;
  1332. } while (G_i_44 < Bars);
  1333. }
  1334. L_d_8 = NormalizeDouble(((OpenRangePips * _Point) + G_d_15), _Digits);
  1335. G_d_16 = 0;
  1336. G_i_45 = DayOfYear();
  1337. G_i_46 = 0;
  1338. if (Bars > 0) {
  1339. do {
  1340. if (TimeDayOfYear(iTime(_Symbol, _Period, G_i_46)) == G_i_45) {
  1341. G_d_16 = iOpen(_Symbol, _Period, G_i_46);
  1342. }
  1343. if (TimeDayOfYear(iTime(_Symbol, _Period, G_i_46)) != G_i_45) break;
  1344. G_i_46 = G_i_46 + 1;
  1345. } while (G_i_46 < Bars);
  1346. }
  1347. G_d_70 = (OpenRangePips * _Point);
  1348. L_d_9 = NormalizeDouble((G_d_16 - G_d_70), _Digits);
  1349. L_d_10 = NormalizeDouble(((MaxDailyRange * _Point) + L_d_8), _Digits);
  1350. G_d_70 = (MaxDailyRange * _Point);
  1351. L_d_11 = NormalizeDouble((L_d_9 - G_d_70), _Digits);
  1352. if ((Close[0] > L_d_8 && Close[0] < L_d_10) || (Close[0] < L_d_9 && Close[0] > L_d_11)) {
  1353. if (I_b_22 && I_i_88 < 1) {
  1354. G_b_0 = true;
  1355. if (TradeOnThursday == false && DayOfWeek() == 4) {
  1356. G_b_0 = false;
  1357. }
  1358. if (TradeOnThursday && DayOfWeek() == 4 && TimeHour(TimeCurrent()) > Thursday_Hour) {
  1359. G_b_0 = false;
  1360. }
  1361. if (TradeOnFriday == false && DayOfWeek() == 5) {
  1362. G_b_0 = false;
  1363. }
  1364. if (TradeOnFriday && DayOfWeek() == 5 && TimeHour(TimeCurrent()) > Friday_Hour) {
  1365. G_b_0 = false;
  1366. }
  1367. if (Open_Hour == 24) {
  1368. Open_Hour = 0;
  1369. }
  1370. if (Close_Hour == 24) {
  1371. Close_Hour = 0;
  1372. }
  1373. if (Open_Hour < Close_Hour) {
  1374. if (TimeHour(TimeCurrent()) < Open_Hour || TimeHour(TimeCurrent()) >= Close_Hour) {
  1375. G_b_0 = false;
  1376. }
  1377. }
  1378. if (Open_Hour > Close_Hour && TimeHour(TimeCurrent()) < Open_Hour && TimeHour(TimeCurrent()) >= Close_Hour) {
  1379. G_b_0 = false;
  1380. }
  1381. G_i_97 = G_b_0;
  1382. if (G_i_97 == 1) {
  1383. L_d_2 = iClose(_Symbol, 0, 2);
  1384. returned_double = iClose(_Symbol, 0, 1);
  1385. L_d_3 = returned_double;
  1386. I_d_74 = Bid;
  1387. I_d_75 = Ask;
  1388. if (I_b_19 == false && I_b_18 == false && L_s_1 == "true") {
  1389. I_i_90 = I_i_88;
  1390. if ((L_d_2 > returned_double)) {
  1391. if (I_i_76 == -2) {
  1392. G_d_18 = 0;
  1393. G_i_47 = 0;
  1394. I_i_1 = I_i_98;
  1395. if (I_i_1 == 0) {
  1396. G_d_18 = I_d_44;
  1397. }
  1398. if (I_i_1 == 1) {
  1399. if (I_i_77 == 1) {
  1400. returned_double = MathPow(I_d_45, I_i_90);
  1401. G_d_18 = NormalizeDouble((I_d_44 * returned_double), (int)I_d_67);
  1402. } else {
  1403. if (I_i_76 == -2) {
  1404. G_d_18 = NormalizeDouble(I_d_44, (int)I_d_67);
  1405. }
  1406. }
  1407. }
  1408. if (I_i_1 == 2) {
  1409. G_i_47 = 0;
  1410. G_d_18 = I_d_44;
  1411. G_i_102 = HistoryTotal() - 1;
  1412. G_i_48 = G_i_102;
  1413. if (G_i_102 >= 0) {
  1414. do {
  1415. if (!OrderSelect(G_i_48, 0, 1)) {
  1416. G_d_17 = -3;
  1417. break;
  1418. }
  1419. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1420. G_l_6 = OrderCloseTime();
  1421. G_l_7 = G_i_47;
  1422. if (G_l_7 < G_l_6) {
  1423. G_i_47 = (int)OrderCloseTime();
  1424. if ((OrderProfit() < 0)) {
  1425. if (I_i_77 == 1) {
  1426. G_d_18 = NormalizeDouble((OrderLots() * I_d_45), (int)I_d_67);
  1427. } else {
  1428. G_d_18 = NormalizeDouble((OrderLots() + Lot), (int)I_d_67);
  1429. }
  1430. } else {
  1431. G_d_18 = I_d_44;
  1432. }
  1433. }
  1434. }
  1435. G_i_48 = G_i_48 - 1;
  1436. } while (G_i_48 >= 0);
  1437. }
  1438. }
  1439. G_i_99 = GetLastError();
  1440. if (G_i_99 == 134) {
  1441. G_d_17 = -2;
  1442. } else {
  1443. G_d_17 = G_d_18;
  1444. }
  1445. I_d_69 = G_d_17;
  1446. }
  1447. if ((I_d_69 > 0)) {
  1448. S_s_15 = _Symbol + "-";
  1449. S_s_15 = S_s_15 + I_s_2;
  1450. S_s_15 = S_s_15 + "-";
  1451. S_s_16 = (string)I_i_90;
  1452. S_s_15 = S_s_15 + S_s_16;
  1453. I_i_92 = f0_15(1, I_d_69, I_d_74, (int)I_d_34, I_d_74, 0, 0, S_s_15, I_i_71, 0, 11823615);
  1454. if (I_i_92 < 0) {
  1455. Print(I_d_69, "Error: ", GetLastError());
  1456. L_i_15 = 0;
  1457. return L_i_15;
  1458. }
  1459. G_d_19 = 0;
  1460. G_i_49 = 0;
  1461. G_i_50 = 0;
  1462. G_i_99 = OrdersTotal() - 1;
  1463. G_i_51 = G_i_99;
  1464. if (G_i_99 >= 0) {
  1465. do {
  1466. I_b_7 = OrderSelect(G_i_51, 0, 0);
  1467. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  1468. G_i_49 = OrderTicket();
  1469. if (G_i_49 > G_i_50) {
  1470. G_d_19 = OrderOpenPrice();
  1471. G_i_50 = G_i_49;
  1472. }
  1473. }
  1474. G_i_51 = G_i_51 - 1;
  1475. } while (G_i_51 >= 0);
  1476. }
  1477. I_d_63 = G_d_19;
  1478. I_b_16 = true;
  1479. }
  1480. } else {
  1481. if (I_i_76 == -2) {
  1482. G_d_21 = 0;
  1483. G_i_52 = 0;
  1484. I_i_1 = I_i_98;
  1485. if (I_i_1 == 0) {
  1486. G_d_21 = I_d_44;
  1487. }
  1488. if (I_i_1 == 1) {
  1489. if (I_i_77 == 1) {
  1490. returned_double = MathPow(I_d_45, I_i_90);
  1491. G_d_21 = NormalizeDouble((I_d_44 * returned_double), (int)I_d_67);
  1492. } else {
  1493. if (I_i_76 == -2) {
  1494. G_d_21 = NormalizeDouble(I_d_44, (int)I_d_67);
  1495. }
  1496. }
  1497. }
  1498. if (I_i_1 == 2) {
  1499. G_i_52 = 0;
  1500. G_d_21 = I_d_44;
  1501. G_i_106 = HistoryTotal() - 1;
  1502. G_i_53 = G_i_106;
  1503. if (G_i_106 >= 0) {
  1504. do {
  1505. if (!OrderSelect(G_i_53, 0, 1)) {
  1506. G_d_20 = -3;
  1507. break;
  1508. }
  1509. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1510. G_l_8 = OrderCloseTime();
  1511. G_l_9 = G_i_52;
  1512. if (G_l_9 < G_l_8) {
  1513. G_i_52 = (int)OrderCloseTime();
  1514. if ((OrderProfit() < 0)) {
  1515. if (I_i_77 == 1) {
  1516. G_d_21 = NormalizeDouble((OrderLots() * I_d_45), (int)I_d_67);
  1517. } else {
  1518. G_d_21 = NormalizeDouble((OrderLots() + Lot), (int)I_d_67);
  1519. }
  1520. } else {
  1521. G_d_21 = I_d_44;
  1522. }
  1523. }
  1524. }
  1525. G_i_53 = G_i_53 - 1;
  1526. } while (G_i_53 >= 0);
  1527. }
  1528. }
  1529. G_i_105 = GetLastError();
  1530. if (G_i_105 == 134) {
  1531. G_d_20 = -2;
  1532. } else {
  1533. G_d_20 = G_d_21;
  1534. }
  1535. I_d_69 = G_d_20;
  1536. }
  1537. if ((I_d_69 > 0)) {
  1538. S_s_16 = _Symbol + "-";
  1539. S_s_16 = S_s_16 + I_s_2;
  1540. S_s_16 = S_s_16 + "-";
  1541. S_s_17 = (string)I_i_90;
  1542. S_s_16 = S_s_16 + S_s_17;
  1543. I_i_92 = f0_15(0, I_d_69, I_d_75, (int)I_d_34, I_d_75, 0, 0, S_s_16, I_i_71, 0, 65280);
  1544. if (I_i_92 < 0) {
  1545. Print(I_d_69, "Error: ", GetLastError());
  1546. L_i_15 = 0;
  1547. return L_i_15;
  1548. }
  1549. G_d_22 = 0;
  1550. G_i_54 = 0;
  1551. G_i_55 = 0;
  1552. G_i_105 = OrdersTotal() - 1;
  1553. G_i_56 = G_i_105;
  1554. if (G_i_105 >= 0) {
  1555. do {
  1556. I_b_7 = OrderSelect(G_i_56, 0, 0);
  1557. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  1558. G_i_54 = OrderTicket();
  1559. if (G_i_54 > G_i_55) {
  1560. G_d_22 = OrderOpenPrice();
  1561. G_i_55 = G_i_54;
  1562. }
  1563. }
  1564. G_i_56 = G_i_56 - 1;
  1565. } while (G_i_56 >= 0);
  1566. }
  1567. I_d_64 = G_d_22;
  1568. I_b_16 = true;
  1569. }
  1570. }
  1571. }
  1572. }
  1573. }
  1574. if (I_i_92 > 0) {
  1575. G_l_5 = TimeCurrent();
  1576. G_d_77 = ((I_d_76 * 60) * 60);
  1577. I_i_80 = (int)(G_l_5 + G_d_77);
  1578. }
  1579. I_b_22 = false;
  1580. }
  1581. } else {
  1582. if (I_b_22 && I_i_88 < 1) {
  1583. G_b_1 = true;
  1584. if (TradeOnThursday == false && DayOfWeek() == 4) {
  1585. G_b_1 = false;
  1586. }
  1587. if (TradeOnThursday && DayOfWeek() == 4 && TimeHour(TimeCurrent()) > Thursday_Hour) {
  1588. G_b_1 = false;
  1589. }
  1590. if (TradeOnFriday == false && DayOfWeek() == 5) {
  1591. G_b_1 = false;
  1592. }
  1593. if (TradeOnFriday && DayOfWeek() == 5 && TimeHour(TimeCurrent()) > Friday_Hour) {
  1594. G_b_1 = false;
  1595. }
  1596. if (Open_Hour == 24) {
  1597. Open_Hour = 0;
  1598. }
  1599. if (Close_Hour == 24) {
  1600. Close_Hour = 0;
  1601. }
  1602. if (Open_Hour < Close_Hour) {
  1603. if (TimeHour(TimeCurrent()) < Open_Hour || TimeHour(TimeCurrent()) >= Close_Hour) {
  1604. G_b_1 = false;
  1605. }
  1606. }
  1607. if (Open_Hour > Close_Hour && TimeHour(TimeCurrent()) < Open_Hour && TimeHour(TimeCurrent()) >= Close_Hour) {
  1608. G_b_1 = false;
  1609. }
  1610. G_i_110 = G_b_1;
  1611. if (G_i_110 == 1) {
  1612. L_d_2 = iClose(_Symbol, 0, 2);
  1613. returned_double = iClose(_Symbol, 0, 1);
  1614. L_d_3 = returned_double;
  1615. I_d_74 = Bid;
  1616. I_d_75 = Ask;
  1617. if (I_b_19 == false && I_b_18 == false && L_s_1 == "true") {
  1618. I_i_90 = I_i_88;
  1619. if ((L_d_2 > returned_double)) {
  1620. if (I_i_76 == -2) {
  1621. G_d_24 = 0;
  1622. G_i_57 = 0;
  1623. I_i_1 = I_i_98;
  1624. if (I_i_1 == 0) {
  1625. G_d_24 = I_d_44;
  1626. }
  1627. if (I_i_1 == 1) {
  1628. if (I_i_77 == 1) {
  1629. returned_double = MathPow(I_d_45, I_i_90);
  1630. G_d_24 = NormalizeDouble((I_d_44 * returned_double), (int)I_d_67);
  1631. } else {
  1632. if (I_i_76 == -2) {
  1633. G_d_24 = NormalizeDouble(I_d_44, (int)I_d_67);
  1634. }
  1635. }
  1636. }
  1637. if (I_i_1 == 2) {
  1638. G_i_57 = 0;
  1639. G_d_24 = I_d_44;
  1640. G_i_112 = HistoryTotal() - 1;
  1641. G_i_58 = G_i_112;
  1642. if (G_i_112 >= 0) {
  1643. do {
  1644. if (!OrderSelect(G_i_58, 0, 1)) {
  1645. G_d_23 = -3;
  1646. break;
  1647. }
  1648. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1649. G_l_10 = OrderCloseTime();
  1650. G_l_11 = G_i_57;
  1651. if (G_l_11 < G_l_10) {
  1652. G_i_57 = (int)OrderCloseTime();
  1653. if ((OrderProfit() < 0)) {
  1654. if (I_i_77 == 1) {
  1655. G_d_24 = NormalizeDouble((OrderLots() * I_d_45), (int)I_d_67);
  1656. } else {
  1657. G_d_24 = NormalizeDouble((OrderLots() + Lot), (int)I_d_67);
  1658. }
  1659. } else {
  1660. G_d_24 = I_d_44;
  1661. }
  1662. }
  1663. }
  1664. G_i_58 = G_i_58 - 1;
  1665. } while (G_i_58 >= 0);
  1666. }
  1667. }
  1668. G_i_111 = GetLastError();
  1669. if (G_i_111 == 134) {
  1670. G_d_23 = -2;
  1671. } else {
  1672. G_d_23 = G_d_24;
  1673. }
  1674. I_d_69 = G_d_23;
  1675. }
  1676. if ((I_d_69 > 0)) {
  1677. S_s_17 = _Symbol + "-";
  1678. S_s_17 = S_s_17 + I_s_2;
  1679. S_s_17 = S_s_17 + "-";
  1680. S_s_18 = (string)I_i_90;
  1681. S_s_17 = S_s_17 + S_s_18;
  1682. I_i_92 = f0_15(1, I_d_69, I_d_74, (int)I_d_34, I_d_74, 0, 0, S_s_17, I_i_71, 0, 11823615);
  1683. if (I_i_92 < 0) {
  1684. Print(I_d_69, "Error: ", GetLastError());
  1685. L_i_15 = 0;
  1686. return L_i_15;
  1687. }
  1688. G_d_25 = 0;
  1689. G_i_59 = 0;
  1690. G_i_60 = 0;
  1691. G_i_111 = OrdersTotal() - 1;
  1692. G_i_61 = G_i_111;
  1693. if (G_i_111 >= 0) {
  1694. do {
  1695. I_b_7 = OrderSelect(G_i_61, 0, 0);
  1696. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  1697. G_i_59 = OrderTicket();
  1698. if (G_i_59 > G_i_60) {
  1699. G_d_25 = OrderOpenPrice();
  1700. G_i_60 = G_i_59;
  1701. }
  1702. }
  1703. G_i_61 = G_i_61 - 1;
  1704. } while (G_i_61 >= 0);
  1705. }
  1706. I_d_63 = G_d_25;
  1707. I_b_16 = true;
  1708. }
  1709. } else {
  1710. if (I_i_76 == -2) {
  1711. G_d_27 = 0;
  1712. G_i_62 = 0;
  1713. I_i_1 = I_i_98;
  1714. if (I_i_1 == 0) {
  1715. G_d_27 = I_d_44;
  1716. }
  1717. if (I_i_1 == 1) {
  1718. if (I_i_77 == 1) {
  1719. returned_double = MathPow(I_d_45, I_i_90);
  1720. G_d_27 = NormalizeDouble((I_d_44 * returned_double), (int)I_d_67);
  1721. } else {
  1722. if (I_i_76 == -2) {
  1723. G_d_27 = NormalizeDouble(I_d_44, (int)I_d_67);
  1724. }
  1725. }
  1726. }
  1727. if (I_i_1 == 2) {
  1728. G_i_62 = 0;
  1729. G_d_27 = I_d_44;
  1730. G_i_115 = HistoryTotal() - 1;
  1731. G_i_63 = G_i_115;
  1732. if (G_i_115 >= 0) {
  1733. do {
  1734. if (!OrderSelect(G_i_63, 0, 1)) {
  1735. G_d_26 = -3;
  1736. break;
  1737. }
  1738. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1739. G_l_12 = OrderCloseTime();
  1740. G_l_13 = G_i_62;
  1741. if (G_l_13 < G_l_12) {
  1742. G_i_62 = (int)OrderCloseTime();
  1743. if ((OrderProfit() < 0)) {
  1744. if (I_i_77 == 1) {
  1745. G_d_27 = NormalizeDouble((OrderLots() * I_d_45), (int)I_d_67);
  1746. } else {
  1747. G_d_27 = NormalizeDouble((OrderLots() + Lot), (int)I_d_67);
  1748. }
  1749. } else {
  1750. G_d_27 = I_d_44;
  1751. }
  1752. }
  1753. }
  1754. G_i_63 = G_i_63 - 1;
  1755. } while (G_i_63 >= 0);
  1756. }
  1757. }
  1758. G_i_100 = GetLastError();
  1759. if (G_i_100 == 134) {
  1760. G_d_26 = -2;
  1761. } else {
  1762. G_d_26 = G_d_27;
  1763. }
  1764. I_d_69 = G_d_26;
  1765. }
  1766. if ((I_d_69 > 0)) {
  1767. S_s_18 = _Symbol + "-";
  1768. S_s_18 = S_s_18 + I_s_2;
  1769. S_s_18 = S_s_18 + "-";
  1770. S_s_19 = (string)I_i_90;
  1771. S_s_18 = S_s_18 + S_s_19;
  1772. I_i_92 = f0_15(0, I_d_69, I_d_75, (int)I_d_34, I_d_75, 0, 0, S_s_18, I_i_71, 0, 65280);
  1773. if (I_i_92 < 0) {
  1774. Print(I_d_69, "Error: ", GetLastError());
  1775. L_i_15 = 0;
  1776. return L_i_15;
  1777. }
  1778. G_d_28 = 0;
  1779. G_i_64 = 0;
  1780. G_i_65 = 0;
  1781. G_i_100 = OrdersTotal() - 1;
  1782. G_i_66 = G_i_100;
  1783. if (G_i_100 >= 0) {
  1784. do {
  1785. I_b_7 = OrderSelect(G_i_66, 0, 0);
  1786. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  1787. G_i_64 = OrderTicket();
  1788. if (G_i_64 > G_i_65) {
  1789. G_d_28 = OrderOpenPrice();
  1790. G_i_65 = G_i_64;
  1791. }
  1792. }
  1793. G_i_66 = G_i_66 - 1;
  1794. } while (G_i_66 >= 0);
  1795. }
  1796. I_d_64 = G_d_28;
  1797. I_b_16 = true;
  1798. }
  1799. }
  1800. }
  1801. }
  1802. }
  1803. }
  1804. G_i_67 = 0;
  1805. G_i_100 = OrdersTotal() - 1;
  1806. G_i_68 = G_i_100;
  1807. if (G_i_100 >= 0) {
  1808. do {
  1809. I_b_7 = OrderSelect(G_i_68, 0, 0);
  1810. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1811. if (OrderType() == OP_SELL || OrderType() == OP_BUY) {
  1812. G_i_67 = G_i_67 + 1;
  1813. }
  1814. }
  1815. G_i_68 = G_i_68 - 1;
  1816. } while (G_i_68 >= 0);
  1817. }
  1818. I_i_88 = G_i_67;
  1819. I_d_48 = 0;
  1820. L_d_12 = 0;
  1821. I_i_84 = OrdersTotal() - 1;
  1822. if (I_i_84 >= 0) {
  1823. do {
  1824. I_b_7 = OrderSelect(I_i_84, 0, 0);
  1825. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1826. if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
  1827. G_d_78 = OrderOpenPrice();
  1828. I_d_48 = ((G_d_78 * OrderLots()) + I_d_48);
  1829. L_d_12 = (L_d_12 + OrderLots());
  1830. }
  1831. }
  1832. I_i_84 = I_i_84 - 1;
  1833. } while (I_i_84 >= 0);
  1834. }
  1835. if (I_i_88 > 0) {
  1836. I_d_48 = NormalizeDouble((I_d_48 / L_d_12), _Digits);
  1837. }
  1838. if (I_b_16) {
  1839. I_i_84 = OrdersTotal() - 1;
  1840. if (I_i_84 >= 0) {
  1841. do {
  1842. I_b_7 = OrderSelect(I_i_84, 0, 0);
  1843. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1844. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_BUY) {
  1845. I_d_80 = ((I_d_46 * _Point) + I_d_48);
  1846. I_d_81 = I_d_80;
  1847. G_d_78 = (I_d_82 * _Point);
  1848. I_d_83 = (I_d_48 - G_d_78);
  1849. I_b_17 = true;
  1850. }
  1851. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71 && OrderType() == OP_SELL) {
  1852. G_d_78 = (I_d_46 * _Point);
  1853. I_d_80 = (I_d_48 - G_d_78);
  1854. I_d_84 = I_d_80;
  1855. I_d_83 = ((I_d_82 * _Point) + I_d_48);
  1856. I_b_17 = true;
  1857. }
  1858. }
  1859. I_i_84 = I_i_84 - 1;
  1860. } while (I_i_84 >= 0);
  1861. }
  1862. }
  1863. if (I_b_16 == false) return 0;
  1864. G_i_100 = I_b_17;
  1865. if (G_i_100 != 1) return 0;
  1866. I_i_84 = OrdersTotal() - 1;
  1867. if (I_i_84 < 0) return 0;
  1868. do {
  1869. I_b_7 = OrderSelect(I_i_84, 0, 0);
  1870. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1871. if (OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1872. I_b_7 = OrderModify(OrderTicket(), I_d_48, OrderStopLoss(), I_d_80, 0, 65535);
  1873. }
  1874. I_b_16 = false;
  1875. }
  1876. I_i_84 = I_i_84 - 1;
  1877. } while (I_i_84 >= 0);
  1878. L_i_15 = 0;
  1879. return L_i_15;
  1880. }
  1881.  
  1882. //+------------------------------------------------------------------+
  1883. //| |
  1884. //+------------------------------------------------------------------+
  1885. int deinit() {
  1886. int L_i_15;
  1887. L_i_15 = 0;
  1888. Comment("************");
  1889. L_i_15 = 0;
  1890. return 0;
  1891. }
  1892.  
  1893. //+------------------------------------------------------------------+
  1894. //| |
  1895. //+------------------------------------------------------------------+
  1896. int f0_1(bool FuncArg_Boolean_00000000, bool FuncArg_Boolean_00000001) {
  1897. string S_s_20;
  1898. string S_s_21;
  1899. string S_s_22;
  1900. string S_s_23;
  1901. int L_i_15;
  1902. int L_i_11;
  1903. int L_i_12;
  1904. L_i_15 = 0;
  1905. L_i_11 = 0;
  1906. L_i_12 = 0;
  1907. G_d_2 = 0;
  1908. G_d_106 = 0;
  1909. L_i_11 = 0;
  1910. L_i_12 = OrdersTotal() - 1;
  1911. if (L_i_12 < 0) return L_i_11;
  1912. do {
  1913. if (OrderSelect(L_i_12, 0, 0) && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  1914. if (OrderType() == OP_BUY && FuncArg_Boolean_00000000) {
  1915. RefreshRates();
  1916. if (!IsTradeContextBusy()) {
  1917. if (!OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid, _Digits), 5, 4294967295)) {
  1918. S_s_20 = (string)OrderTicket();
  1919. S_s_20 = "Error close BUY " + S_s_20;
  1920. Print(S_s_20);
  1921. L_i_11 = -1;
  1922. }
  1923. } else {
  1924. G_l_22 = iTime(NULL, 0, 0);
  1925. G_l_23 = I_i_131;
  1926. if (G_l_23 == G_l_22) {
  1927. L_i_15 = -2;
  1928. return L_i_15;
  1929. }
  1930. I_i_131 = (int)iTime(NULL, 0, 0);
  1931. S_s_21 = (string)OrderTicket();
  1932. S_s_21 = "Need close BUY " + S_s_21;
  1933. S_s_21 = S_s_21 + ". Trade Context Busy";
  1934. Print(S_s_21);
  1935. L_i_15 = -2;
  1936. return L_i_15;
  1937. }
  1938. }
  1939. if (OrderType() == OP_SELL && FuncArg_Boolean_00000001) {
  1940. RefreshRates();
  1941. if (!IsTradeContextBusy()) {
  1942. if (!OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask, _Digits), 5, 4294967295)) {
  1943. S_s_22 = (string)OrderTicket();
  1944. S_s_22 = "Error close SELL " + S_s_22;
  1945. Print(S_s_22);
  1946. L_i_11 = -1;
  1947. }
  1948. } else {
  1949. G_l_20 = iTime(NULL, 0, 0);
  1950. G_l_21 = I_i_132;
  1951. if (G_l_21 == G_l_20) {
  1952. L_i_15 = -2;
  1953. return L_i_15;
  1954. }
  1955. I_i_132 = (int)iTime(NULL, 0, 0);
  1956. S_s_23 = (string)OrderTicket();
  1957. S_s_23 = "Need close SELL " + S_s_23;
  1958. S_s_23 = S_s_23 + ". Trade Context Busy";
  1959. Print(S_s_23);
  1960. L_i_15 = -2;
  1961. return L_i_15;
  1962. }
  1963. }
  1964. }
  1965. L_i_12 = L_i_12 - 1;
  1966. } while (L_i_12 >= 0);
  1967. L_i_15 = L_i_11;
  1968. return L_i_15;
  1969. }
  1970.  
  1971. //+------------------------------------------------------------------+
  1972. //| |
  1973. //+------------------------------------------------------------------+
  1974. int f0_15(int Fa_i_00, double Fa_d_01, double Fa_d_02, int Fa_i_03, double Fa_d_04, double Fa_d_05, int Fa_i_06, string Fa_s_07, int Fa_i_08, int Fa_i_09, int Fa_i_0A) {
  1975. int L_i_15;
  1976. int L_i_11;
  1977. int L_i_12;
  1978. int L_i_13;
  1979. int L_i_14;
  1980. L_i_15 = 0;
  1981. L_i_11 = 0;
  1982. L_i_12 = 0;
  1983. L_i_13 = 0;
  1984. L_i_14 = 0;
  1985. G_d_2 = 0;
  1986. G_d_106 = 0;
  1987. G_i_3 = 0;
  1988. G_d_3 = 0;
  1989. G_d_108 = 0;
  1990. G_i_5 = 0;
  1991. G_d_109 = 0;
  1992. G_d_110 = 0;
  1993. G_i_8 = 0;
  1994. G_d_111 = 0;
  1995. G_d_112 = 0;
  1996. G_i_11 = 0;
  1997. G_d_113 = 0;
  1998. G_d_114 = 0;
  1999. G_i_14 = 0;
  2000. G_d_115 = 0;
  2001. G_d_4 = 0;
  2002. G_i_16 = 0;
  2003. G_d_116 = 0;
  2004. G_d_117 = 0;
  2005. G_i_19 = 0;
  2006. G_d_118 = 0;
  2007. G_d_5 = 0;
  2008. G_i_21 = 0;
  2009. G_d_119 = 0;
  2010. G_d_120 = 0;
  2011. G_i_139 = 0;
  2012. G_d_121 = 0;
  2013. G_d_122 = 0;
  2014. G_i_26 = 0;
  2015. G_d_7 = 0;
  2016. G_d_123 = 0;
  2017. G_i_28 = 0;
  2018. G_d_124 = 0;
  2019. G_d_8 = 0;
  2020. G_i_30 = 0;
  2021. L_i_11 = 0;
  2022. L_i_12 = 0;
  2023. L_i_13 = 0;
  2024. L_i_14 = 100;
  2025. I_i_1 = Fa_i_00;
  2026. if (I_i_1 > 5) return L_i_11;
  2027. if (I_i_1 == 2) {
  2028. L_i_13 = 0;
  2029. if (L_i_14 <= 0) return L_i_11;
  2030. do {
  2031. G_i_31 = Fa_i_0A;
  2032. G_i_5 = Fa_i_06;
  2033. G_d_108 = Fa_d_02;
  2034. if (Fa_i_06 == 0) {
  2035. G_d_3 = 0;
  2036. } else {
  2037. G_d_3 = ((G_i_5 * _Point) + G_d_108);
  2038. }
  2039. G_i_3 = (int)I_d_82;
  2040. G_d_106 = Fa_d_04;
  2041. if (G_i_3 == 0) {
  2042. G_d_2 = 0;
  2043. } else {
  2044. G_d_10 = (G_i_3 * _Point);
  2045. G_d_2 = (G_d_106 - G_d_10);
  2046. }
  2047. L_i_11 = OrderSend(_Symbol, 2, Fa_d_01, Fa_d_02, Fa_i_03, G_d_2, G_d_3, Fa_s_07, Fa_i_08, Fa_i_09, G_i_31);
  2048. if (L_i_11 > 0) {
  2049. I_i_76 = I_i_76 + 1;
  2050. }
  2051. G_i_146 = GetLastError();
  2052. L_i_12 = G_i_146;
  2053. if (G_i_146 == 0) return L_i_11;
  2054. G_b_48 = (G_i_146 == 4);
  2055. if (G_b_48 != true) {
  2056. G_b_48 = (G_i_146 == 137);
  2057. }
  2058. if (G_b_48 != true) {
  2059. G_b_48 = (L_i_12 == 146);
  2060. }
  2061. if (G_b_48 != true) {
  2062. G_b_48 = (L_i_12 == 136);
  2063. }
  2064. if (G_b_48 == false) return L_i_11;
  2065. Sleep(1000);
  2066. L_i_13 = L_i_13 + 1;
  2067. } while (L_i_13 < L_i_14);
  2068. return L_i_11;
  2069. }
  2070. if (I_i_1 == 4) {
  2071. L_i_13 = 0;
  2072. if (L_i_14 <= 0) return L_i_11;
  2073. do {
  2074. G_i_33 = Fa_i_0A;
  2075. G_i_11 = Fa_i_06;
  2076. G_d_112 = Fa_d_02;
  2077. if (Fa_i_06 == 0) {
  2078. G_d_111 = 0;
  2079. } else {
  2080. G_d_111 = ((G_i_11 * _Point) + G_d_112);
  2081. }
  2082. G_i_8 = (int)I_d_82;
  2083. G_d_110 = Fa_d_04;
  2084. if (G_i_8 == 0) {
  2085. G_d_109 = 0;
  2086. } else {
  2087. G_d_128 = (G_i_8 * _Point);
  2088. G_d_109 = (G_d_110 - G_d_128);
  2089. }
  2090. L_i_11 = OrderSend(_Symbol, 4, Fa_d_01, Fa_d_02, Fa_i_03, G_d_109, G_d_111, Fa_s_07, Fa_i_08, Fa_i_09, G_i_33);
  2091. if (L_i_11 > 0) {
  2092. I_i_76 = I_i_76 + 1;
  2093. }
  2094. G_i_35 = GetLastError();
  2095. L_i_12 = G_i_35;
  2096. if (G_i_35 == 0) return L_i_11;
  2097. G_b_45 = (G_i_35 == 4);
  2098. if (G_b_45 != true) {
  2099. G_b_45 = (G_i_35 == 137);
  2100. }
  2101. if (G_b_45 != true) {
  2102. G_b_45 = (L_i_12 == 146);
  2103. }
  2104. if (G_b_45 != true) {
  2105. G_b_45 = (L_i_12 == 136);
  2106. }
  2107. if (G_b_45 == false) return L_i_11;
  2108. Sleep(5000);
  2109. L_i_13 = L_i_13 + 1;
  2110. } while (L_i_13 < L_i_14);
  2111. return L_i_11;
  2112. }
  2113. if (I_i_1 == 0) {
  2114. L_i_13 = 0;
  2115. if (L_i_14 <= 0) return L_i_11;
  2116. do {
  2117. RefreshRates();
  2118. G_i_36 = Fa_i_0A;
  2119. G_i_16 = Fa_i_06;
  2120. G_d_4 = Ask;
  2121. if (Fa_i_06 == 0) {
  2122. G_d_115 = 0;
  2123. } else {
  2124. G_d_115 = ((G_i_16 * _Point) + G_d_4);
  2125. }
  2126. G_i_14 = (int)I_d_82;
  2127. G_d_114 = Bid;
  2128. if (G_i_14 == 0) {
  2129. G_d_113 = 0;
  2130. } else {
  2131. G_d_13 = (G_i_14 * _Point);
  2132. G_d_113 = (G_d_114 - G_d_13);
  2133. }
  2134. L_i_11 = OrderSend(_Symbol, 0, Fa_d_01, Ask, Fa_i_03, G_d_113, G_d_115, Fa_s_07, Fa_i_08, Fa_i_09, G_i_36);
  2135. if (L_i_11 > 0) {
  2136. I_i_76 = I_i_76 + 1;
  2137. }
  2138. G_i_143 = GetLastError();
  2139. L_i_12 = G_i_143;
  2140. if (G_i_143 == 0) return L_i_11;
  2141. G_b_46 = (G_i_143 == 4);
  2142. if (G_b_46 != true) {
  2143. G_b_46 = (G_i_143 == 137);
  2144. }
  2145. if (G_b_46 != true) {
  2146. G_b_46 = (L_i_12 == 146);
  2147. }
  2148. if (G_b_46 != true) {
  2149. G_b_46 = (L_i_12 == 136);
  2150. }
  2151. if (G_b_46 == false) return L_i_11;
  2152. Sleep(5000);
  2153. L_i_13 = L_i_13 + 1;
  2154. } while (L_i_13 < L_i_14);
  2155. return L_i_11;
  2156. }
  2157. if (I_i_1 == 3) {
  2158. L_i_13 = 0;
  2159. if (L_i_14 <= 0) return L_i_11;
  2160. do {
  2161. G_i_38 = Fa_i_0A;
  2162. G_i_21 = Fa_i_06;
  2163. G_d_5 = Fa_d_02;
  2164. if (Fa_i_06 == 0) {
  2165. G_d_118 = 0;
  2166. } else {
  2167. G_d_127 = (G_i_21 * _Point);
  2168. G_d_118 = (G_d_5 - G_d_127);
  2169. }
  2170. G_i_19 =(int) I_d_82;
  2171. G_d_117 = Fa_d_04;
  2172. if (G_i_19 == 0) {
  2173. G_d_116 = 0;
  2174. } else {
  2175. G_d_116 = ((G_i_19 * _Point) + G_d_117);
  2176. }
  2177. L_i_11 = OrderSend(_Symbol, 3, Fa_d_01, Fa_d_02, Fa_i_03, G_d_116, G_d_118, Fa_s_07, Fa_i_08, Fa_i_09, G_i_38);
  2178. if (L_i_11 > 0) {
  2179. I_i_76 = I_i_76 + 1;
  2180. }
  2181. G_i_40 = GetLastError();
  2182. L_i_12 = G_i_40;
  2183. if (G_i_40 == 0) return L_i_11;
  2184. G_b_47 = (G_i_40 == 4);
  2185. if (G_b_47 != true) {
  2186. G_b_47 = (G_i_40 == 137);
  2187. }
  2188. if (G_b_47 != true) {
  2189. G_b_47 = (L_i_12 == 146);
  2190. }
  2191. if (G_b_47 != true) {
  2192. G_b_47 = (L_i_12 == 136);
  2193. }
  2194. if (G_b_47 == false) return L_i_11;
  2195. Sleep(5000);
  2196. L_i_13 = L_i_13 + 1;
  2197. } while (L_i_13 < L_i_14);
  2198. return L_i_11;
  2199. }
  2200. if (I_i_1 == 5) {
  2201. L_i_13 = 0;
  2202. if (L_i_14 <= 0) return L_i_11;
  2203. do {
  2204. G_i_41 = Fa_i_0A;
  2205. G_i_26 = Fa_i_06;
  2206. G_d_122 = Fa_d_02;
  2207. if (Fa_i_06 == 0) {
  2208. G_d_121 = 0;
  2209. } else {
  2210. G_d_126 = (G_i_26 * _Point);
  2211. G_d_121 = (G_d_122 - G_d_126);
  2212. }
  2213. G_i_139 = (int)I_d_82;
  2214. G_d_120 = Fa_d_04;
  2215. if (G_i_139 == 0) {
  2216. G_d_119 = 0;
  2217. } else {
  2218. G_d_119 = ((G_i_139 * _Point) + G_d_120);
  2219. }
  2220. L_i_11 = OrderSend(_Symbol, 5, Fa_d_01, Fa_d_02, Fa_i_03, G_d_119, G_d_121, Fa_s_07, Fa_i_08, Fa_i_09, G_i_41);
  2221. if (L_i_11 > 0) {
  2222. I_i_76 = I_i_76 + 1;
  2223. }
  2224. G_i_43 = GetLastError();
  2225. L_i_12 = G_i_43;
  2226. if (G_i_43 == 0) return L_i_11;
  2227. G_b_44 = (G_i_43 == 4);
  2228. if (G_b_44 != true) {
  2229. G_b_44 = (G_i_43 == 137);
  2230. }
  2231. if (G_b_44 != true) {
  2232. G_b_44 = (L_i_12 == 146);
  2233. }
  2234. if (G_b_44 != true) {
  2235. G_b_44 = (L_i_12 == 136);
  2236. }
  2237. if (G_b_44 == false) return L_i_11;
  2238. Sleep(5000);
  2239. L_i_13 = L_i_13 + 1;
  2240. } while (L_i_13 < L_i_14);
  2241. return L_i_11;
  2242. }
  2243. if (I_i_1 == 1) {
  2244. L_i_13 = 0;
  2245. if (L_i_14 <= 0) return L_i_11;
  2246. do {
  2247. G_i_44 = Fa_i_0A;
  2248. G_i_30 = Fa_i_06;
  2249. G_d_8 = Bid;
  2250. if (Fa_i_06 == 0) {
  2251. G_d_124 = 0;
  2252. } else {
  2253. G_d_125 = (G_i_30 * _Point);
  2254. G_d_124 = (G_d_8 - G_d_125);
  2255. }
  2256. G_i_28 = (int)I_d_82;
  2257. G_d_123 = Ask;
  2258. if (G_i_28 == 0) {
  2259. G_d_7 = 0;
  2260. } else {
  2261. G_d_7 = ((G_i_28 * _Point) + G_d_123);
  2262. }
  2263. L_i_11 = OrderSend(_Symbol, 1, Fa_d_01, Bid, Fa_i_03, G_d_7, G_d_124, Fa_s_07, Fa_i_08, Fa_i_09, G_i_44);
  2264. if (L_i_11 > 0) {
  2265. I_i_76 = I_i_76 + 1;
  2266. }
  2267. G_i_46 = GetLastError();
  2268. L_i_12 = G_i_46;
  2269. if (G_i_46 == 0) return L_i_11;
  2270. G_b_0 = (G_i_46 == 4);
  2271. if (G_b_0 != true) {
  2272. G_b_0 = (G_i_46 == 137);
  2273. }
  2274. if (G_b_0 != true) {
  2275. G_b_0 = (L_i_12 == 146);
  2276. }
  2277. if (G_b_0 != true) {
  2278. G_b_0 = (L_i_12 == 136);
  2279. }
  2280. if (G_b_0 == false) return L_i_11;
  2281. Sleep(5000);
  2282. L_i_13 = L_i_13 + 1;
  2283. } while (L_i_13 < L_i_14);
  2284. }
  2285. L_i_15 = L_i_11;
  2286. return L_i_11;
  2287. }
  2288.  
  2289. //+------------------------------------------------------------------+
  2290. //| |
  2291. //+------------------------------------------------------------------+
  2292. void f0_18(int Fa_i_00, int Fa_i_01, double Fa_d_02) {
  2293. int L_i_15;
  2294. double L_d_13;
  2295. double L_d_14;
  2296. int L_i_16;
  2297. L_i_15 = 0;
  2298. L_d_13 = 0;
  2299. L_d_14 = 0;
  2300. L_i_16 = 0;
  2301. L_i_15 = 0;
  2302. L_d_13 = 0;
  2303. L_d_14 = 0;
  2304. if (Fa_i_01 == 0) return;
  2305. L_i_16 = OrdersTotal() - 1;
  2306. if (L_i_16 < 0) return;
  2307. do {
  2308. if (OrderSelect(L_i_16, 0, 0) && OrderSymbol() == _Symbol && OrderMagicNumber() == I_i_71) {
  2309. if (OrderSymbol() == _Symbol || OrderMagicNumber() == I_i_71) {
  2310. if (OrderType() == OP_BUY) {
  2311. G_d_2 = (Bid - Fa_d_02);
  2312. L_i_15 = (int)NormalizeDouble((G_d_2 / _Point), 0);
  2313. if (L_i_15 < Fa_i_00) continue;
  2314. returned_double = OrderStopLoss();
  2315. L_d_13 = returned_double;
  2316. G_d_2 = (Fa_i_01 * _Point);
  2317. L_d_14 = (Bid - G_d_2);
  2318. if (returned_double == 0 || (returned_double != 0 && L_d_14 > returned_double)) {
  2319. I_b_7 = OrderModify(OrderTicket(), Fa_d_02, L_d_14, OrderTakeProfit(), 0, 16776960);
  2320. }
  2321. }
  2322. if (OrderType() == OP_SELL) {
  2323. G_d_106 = (Fa_d_02 - Ask);
  2324. L_i_15 = (int)NormalizeDouble((G_d_106 / _Point), 0);
  2325. if (L_i_15 < Fa_i_00) continue;
  2326. returned_double = OrderStopLoss();
  2327. L_d_13 = returned_double;
  2328. L_d_14 = ((Fa_i_01 * _Point) + Ask);
  2329. if (returned_double == 0 || (returned_double != 0 && L_d_14 < returned_double)) {
  2330. I_b_7 = OrderModify(OrderTicket(), Fa_d_02, L_d_14, OrderTakeProfit(), 0, 255);
  2331. }
  2332. }
  2333. }
  2334. Sleep(1000);
  2335. }
  2336. L_i_16 = L_i_16 - 1;
  2337. } while (L_i_16 >= 0);
  2338. }
  2339. //+------------------------------------------------------------------+
  2340. //| Calculate AutoLot based on Account Balance and Cap by MaxLot |
  2341. //+------------------------------------------------------------------+
  2342. double CalculateSmartLot() {
  2343. if(!Use_AutoLot) {
  2344. return NormalizeDouble(MathMin(Lot, Max_Allowed_Lot), 2);
  2345. }
  2346.  
  2347. double currentBalance = AccountBalance();
  2348. if(AutoLot_BaseBalance <= 0) return NormalizeDouble(MathMin(Lot, Max_Allowed_Lot), 2);
  2349.  
  2350. // Formula: (Current Balance / Base Balance) * Base Lot
  2351. double calculatedLot = (currentBalance / AutoLot_BaseBalance) * AutoLot_BaseLot;
  2352.  
  2353. // Round to standard 2 decimal places for lots
  2354. calculatedLot = NormalizeDouble(calculatedLot, 2);
  2355.  
  2356. // Enforce broker minimum lot size
  2357. double minLot = MarketInfo(_Symbol, MODE_MINLOT);
  2358. if(calculatedLot < minLot) calculatedLot = minLot;
  2359.  
  2360. // Enforce Max Allowed Lot Cap safety defense
  2361. if(calculatedLot > Max_Allowed_Lot) calculatedLot = Max_Allowed_Lot;
  2362.  
  2363. return calculatedLot;
  2364. }
  2365.  
  2366.  
  2367. //+------------------------------------------------------------------+