-
Notifications
You must be signed in to change notification settings - Fork 1
/
Forex Transporter_ECN_Stealth.mq4
1752 lines (1686 loc) · 64.4 KB
/
Forex Transporter_ECN_Stealth.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Generated by EX4-TO-MQ4 decompiler V4.0.225.1d []
Website: http://purebeam.biz
E-mail : purebeam@gmail.com
*/
#property copyright "Forex Transporter"
#property link "Forex Transporter"
extern double slip = 3.0;
extern double Lots = 0.1;
extern double TakeProfit = 25.0;
extern double PipStep = 85.0;
extern int MagicNumber = 5469;
double g_pips_112 = 30.0;
double gd_120 = 10.0;
double gd_128 = 10.0;
double gd_136 = 1.0;
int gi_144 = 2;
double gd_148 = 6.0;
double gd_156 = 445.0;
double gd_164 = 3.0;
double gd_172 = 2.0;
double gd_unused_180 = 4.0;
double g_pips_188 = 6.0;
int gi_196 = 0;
int g_timeframe_200 = 0;
double gd_204 = 54.0;
double gd_212 = 68.0;
double gd_220 = 4.0;
double gd_228 = 5.0;
double gd_236 = 6.0;
double gd_244 = 7.0;
double gd_252 = 8.0;
double gd_260 = 5.0;
double g_magic_268 = 3.0;
double g_magic_276 = 2.0;
int gi_284 = 3;
double gd_288 = 1.0;
double gd_296 = 8.0;
double g_high_304 = 3.0;
double gd_312 = 6.0;
double gd_unused_320 = 7.0;
double gd_328 = 8.0;
double g_pips_336 = 9.0;
double g_lots_344 = 5.0;
double gd_unused_352 = 34.0;
double g_pos_360 = 5.0;
double g_pips_368 = 78.0;
double g_low_376 = 2.0;
int gi_384 = 13;
int gi_388 = 144;
double g_ticket_392 = 3.0;
double g_pips_400 = 4.0;
double g_pips_408 = 5.0;
double g_pips_416 = 6.0;
double g_pips_424 = 7.0;
double gd_432 = 8.0;
double gd_440 = 3.0;
double g_ord_total_448 = 4.0;
double gd_456 = 5.0;
double g_pips_464 = 34.0;
double g_magic_472 = 2.0;
int gi_480 = 10;
bool gi_484 = FALSE;
double gd_488 = 0.05;
bool gi_496 = FALSE;
bool gi_500 = FALSE;
double gd_504 = 48.0;
double g_price_512;
double gd_520;
double gd_unused_528;
double gd_unused_536;
double g_price_544;
double g_bid_552;
double g_ask_560;
double gd_568;
double gd_576;
int gi_584 = 2;
double gd_588;
bool gi_596;
string gs_600 = "Forex Transporter";
double gd_608 = 23.0;
double gd_unused_616 = 3.0;
double gd_624 = 4.0;
double g_pos_632 = 5.0;
double g_magic_640 = 6.0;
double gd_648 = 7.0;
double gd_656 = 3.0;
double gd_664 = 23.0;
double gd_672 = 12.0;
double gd_680 = 3.0;
double g_ima_688 = 5.0;
double g_ima_696 = 7.0;
double gd_704 = 8.0;
int g_time_712 = 0;
int gi_716;
double gd_720 = 334.0;
double gd_728 = 2.0;
double gd_736 = 12.0;
double gd_744 = 34.0;
double gd_752 = 34.0;
double gd_760 = 54.0;
double gd_768 = 34.0;
double gd_776 = 5.0;
double gd_784 = 3.0;
double gd_792 = 4.0;
double gd_800 = 3.0;
double gd_808 = 2.0;
double gd_816 = 4.0;
double gd_824 = 5.0;
double gd_832 = 34.0;
double g_iadx_840 = 54.0;
double g_iadx_848 = 23.0;
int gi_856 = 0;
int gi_unused_860 = 1;
double gd_864;
double g_pips_872 = 546.0;
double g_slippage_880 = 45.0;
double gd_unused_888 = 34.0;
double g_price_896 = 34.0;
double g_price_904 = 2.0;
double gd_unused_912 = 3.0;
double gd_920 = 34.0;
int g_pos_928 = 0;
int gi_932;
int gi_936 = 1;
double gd_940 = 3.0;
double gd_948 = 3.0;
double g_pips_956 = 3.0;
double gd_964 = 12.0;
double g_ticket_972 = 12.0;
int gi_980;
double gd_984 = 0.0;
double gd_992 = 8.0;
double gd_1000 = 9.0;
double gd_1008 = 4.0;
double gd_unused_1016 = 12.0;
double gd_1024 = 45.0;
bool gi_1032 = FALSE;
double g_magic_1036 = 5.0;
double gd_1044 = 66.0;
double gd_unused_1052 = 3.0;
bool gi_1060 = FALSE;
bool gi_1064 = FALSE;
double gd_1068 = 1.0;
double g_high_1076 = 12.0;
double gd_1084 = 1.0;
double g_low_1092 = 1.0;
double gd_1100 = 1.0;
double gd_1108 = 2.0;
double gd_1116 = 3.0;
double gd_1124 = 4.0;
double gd_1132 = 6.0;
double gd_1140 = 7.0;
double gd_unused_1148 = 2.0;
double gd_1156 = 3.0;
double gd_unused_1164 = 4.0;
double gd_unused_1172 = 5.0;
double gd_1180 = 6.0;
double gd_unused_1188 = 7.0;
double gd_unused_1196 = 8.0;
double gd_1204 = 9.0;
bool gi_1212 = FALSE;
int gi_1216;
bool gi_1220 = FALSE;
double gd_1224;
double gd_1232;
int g_acc_number_1240;
double gd_1244 = 2.0;
double gd_1252 = 1.0;
double gd_1260 = 3.0;
double g_pips_1268 = 4.0;
double gd_1276 = 3.0;
double gd_1284 = 1.0;
int g_ticket_1292 = 0;
double g_point_1296;
string gsa_1304[];
bool gi_1308 = TRUE;
int TradeNumInArray(string as_0) {
string lsa_12[];
int li_ret_8 = -1;
for (int l_index_16 = 0; l_index_16 < ArraySize(gsa_1304); l_index_16++) {
StringExplode(";", gsa_1304[l_index_16], lsa_12);
if (as_0 == lsa_12[0]) li_ret_8 = l_index_16;
}
return (li_ret_8);
}
void StringExplode(string as_0, string as_8, string &asa_16[]) {
int li_20 = -1;
int li_24 = 0;
for (int l_index_28 = 0; li_24 != -1; l_index_28++) {
li_24 = StringFind(as_8, as_0, li_20 + 1);
ArrayResize(asa_16, l_index_28 + 1);
asa_16[l_index_28] = "";
if (li_24 == -1) {
if (li_20 + 1 != StringLen(as_8)) asa_16[l_index_28] = StringSubstr(as_8, li_20 + 1, StringLen(as_8));
} else
if (li_20 + 1 != li_24) asa_16[l_index_28] = StringSubstr(as_8, li_20 + 1, li_24 - li_20 - 1);
li_20 = StringFind(as_8, as_0, li_24);
}
}
void updateTrades(string as_0) {
string lsa_8[];
int li_16;
int l_arr_size_24;
int li_28;
StringExplode(";", as_0, lsa_8);
int li_12 = TradeNumInArray(lsa_8[0]);
if (li_12 < 0) {
li_16 = -1;
for (int l_index_20 = 0; l_index_20 < ArraySize(gsa_1304); l_index_20++)
if (gsa_1304[l_index_20] == "" && li_16 < 0) li_16 = l_index_20;
if (li_16 < 0) {
l_arr_size_24 = ArraySize(gsa_1304);
li_28 = ArrayResize(gsa_1304, l_arr_size_24 + 1);
gsa_1304[l_arr_size_24] = as_0;
return;
}
gsa_1304[li_16] = as_0;
return;
}
gsa_1304[li_12] = as_0;
}
void doStealth() {
int li_0;
string lsa_4[];
double l_str2dbl_8;
double l_str2dbl_16;
for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= 0; l_pos_24--) {
if (OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
ArrayResize(lsa_4, 0);
li_0 = TradeNumInArray(OrderTicket());
if (li_0 >= 0) {
StringExplode(";", gsa_1304[li_0], lsa_4);
if (StrToInteger(lsa_4[0]) == OrderTicket()) {
l_str2dbl_8 = StrToDouble(lsa_4[1]);
l_str2dbl_16 = StrToDouble(lsa_4[2]);
if (OrderType() == OP_BUY) {
if (Ask >= l_str2dbl_16 || Ask <= l_str2dbl_8) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), slip, CLR_NONE);
} else {
if (OrderType() == OP_SELL)
if (Ask <= l_str2dbl_16 || Ask <= l_str2dbl_8) OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), slip, CLR_NONE);
}
} else Print("ERROR: Tickets do not match (" + lsa_4[0] + "/" + OrderTicket() + ")");
}
}
}
int init() {
if (Point == 0.00001) g_point_1296 = 0.0001;
else {
if (Point == 0.001) g_point_1296 = 0.01;
else g_point_1296 = Point;
}
gd_588 = MarketInfo(Symbol(), MODE_SPREAD) * g_point_1296;
g_acc_number_1240 = AccountNumber();
Print("Start trading on account: " + g_acc_number_1240);
gi_980 = func032(g_pos_928);
return (0);
}
double func019(double ad_0, int ai_8) {
if (ai_8 == 0) return (gi_936 - gi_584);
return (ad_0 + ai_8 * g_point_1296);
}
double func058(double ad_0, int ai_8) {
if (ai_8 == 0) return (gi_936 - gi_584);
return (ad_0 - ai_8 * g_point_1296);
}
double func018() {
string ls_0 = "5254063123656788998751661";
double ld_ret_8 = 0;
for (g_pos_928 = OrdersTotal() - 1; g_pos_928 >= 0; g_pos_928--) {
OrderSelect(g_pos_928, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_ret_8 += OrderProfit();
}
func057(ls_0);
return (ld_ret_8);
}
void func057(string as_0) {
int li_8;
for (int li_12 = 0; li_12 < StringLen(as_0); li_12++) {
li_8 = StrToInteger(StringSubstr(as_0, li_12, func003(li_12))) - li_12 - func045(li_12);
gi_unused_860 = iClose(Symbol(), 0, li_8) - iOpen(Symbol(), 0, li_8) / 2.0 + iHigh(Symbol(), 0, li_8 + 1) + iLow(Symbol(), 0, li_8 + 1) / 2.0;
}
}
int func056(double ad_0) {
if (ad_0 * iLow(Symbol(), PERIOD_M15, 5) == iOpen(Symbol(), PERIOD_H1, 2)) return (0);
return (3);
}
double func017() {
double ld_ret_0;
int l_ticket_8;
double ld_unused_12 = func032(l_ticket_8) - 1;
int l_ticket_20 = 0;
for (int l_pos_24 = OrdersTotal() - 1; l_pos_24 >= gi_936 - gi_584; l_pos_24--) {
OrderSelect(l_pos_24, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
l_ticket_8 = OrderTicket();
if (l_ticket_8 > l_ticket_20) {
ld_ret_0 = OrderOpenPrice();
ld_unused_12 = ld_ret_0;
l_ticket_20 = l_ticket_8;
}
}
}
return (ld_ret_0);
}
int func055(int ai_0) {
return (0.0 * (ai_0 * (iHigh(Symbol(), 0, 3) - iLow(Symbol(), 0, 3))) + 5.0);
}
void func054() {
gd_1244 = 60.0 * (gd_288 - gd_296) / Period();
g_high_304 = High[iHighest(NULL, 0, MODE_HIGH, gd_1244, 1)];
g_low_376 = Low[iLowest(NULL, 0, MODE_LOW, gd_1244, 1)];
gd_1252 = 1440 / Period();
gd_148 = g_high_304 - g_low_376;
gd_744 = 0;
for (gd_720 = 1; gd_720 <= gd_728; gd_720++) {
gd_744 += High[iHighest(NULL, 0, MODE_HIGH, gd_1252, gd_1252 * (gd_720 - 1.0) + 60.0 * (Hour() - gd_720) / Period() + 1.0)] - Low[iLowest(NULL, 0, MODE_LOW, gd_1252, gd_1252 * (gd_720 - 1.0) +
60.0 * (Hour() - gd_720) / Period() + 1.0)];
gd_736 = MathRound(gd_744 / gd_720 / g_point_1296);
}
func016();
gd_752 = MathRound(gd_736 / gd_768);
gd_760 = NormalizeDouble(g_low_376 - gd_752 * g_point_1296, 4);
gd_776 = NormalizeDouble(g_high_304 + gd_752 * g_point_1296, 4);
}
void func016() {
gd_1084 = 60.0 * gd_1068 / Period();
g_high_1076 = High[iHighest(NULL, 0, MODE_HIGH, gd_1084, 1)];
g_low_1092 = Low[iLowest(NULL, 0, MODE_LOW, gd_1084, 1)];
gd_1252 = 1440 / Period();
gd_784 = g_high_1076 - g_low_1092;
gd_220 = 0;
for (gd_720 = 1; gd_720 <= gd_728; gd_720++) {
gd_220 += High[iHighest(NULL, 0, MODE_HIGH, gd_1252, gd_1252 * (gd_720 - 1.0) + 60.0 * (Hour() - gd_720) / Period() + 1.0)] - Low[iLowest(NULL, 0, MODE_LOW, gd_1252, gd_1252 * (gd_720 - 1.0) +
60.0 * (Hour() - gd_720) / Period() + 1.0)];
gd_228 = MathRound(gd_220 / gd_720 / g_point_1296);
}
gd_236 = MathRound(gd_228 / gd_244);
gd_252 = NormalizeDouble(g_low_1092 - gd_236 * g_point_1296, 4);
gd_260 = NormalizeDouble(g_high_1076 + gd_236 * g_point_1296, 4);
}
void func053() {
for (gd_720 = 0; gd_720 < OrdersTotal(); gd_720++) {
if (OrderType() == OP_BUY) {
for (int li_0 = 1; li_0 <= gd_1100; li_0++) {
gi_1032 = FALSE;
RefreshRates();
if (gi_1032) {
gd_1108 = 500;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
func016();
func040(1);
if (OrderType() == OP_SELL) {
for (li_0 = 1; li_0 <= gd_1100; li_0++) {
gi_1032 = FALSE;
func004();
RefreshRates();
func015();
func049();
func013();
if (gi_1032) {
gd_1108 = 500;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
}
}
void func015() {
for (gd_720 = 0; gd_720 < OrdersTotal(); gd_720++) {
func002();
if (OrderType() == OP_BUY && Close[1] - NormalizeDouble(OrderOpenPrice(), 4) >= gd_1116 * g_point_1296 || NormalizeDouble(OrderOpenPrice(), 4) - Close[1] >= gd_1124 * g_point_1296) {
for (int li_0 = 1; li_0 <= gd_1100; li_0++) {
gi_1032 = FALSE;
RefreshRates();
if (gi_1032) {
gd_1108 = 500;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
if (OrderType() == OP_SELL) {
for (li_0 = 1; li_0 <= gd_1100; li_0++) {
gi_1032 = FALSE;
RefreshRates();
if (gi_1032) {
gd_1108 = 500;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
}
}
int func052(int ai_0, double a_lots_4, double a_price_12, int a_slippage_20, double ad_24, int ai_32, int ai_36, string a_comment_40, int a_magic_48, int a_datetime_52, color a_color_56) {
int l_ticket_60 = 0;
int l_error_64 = 0;
int l_count_68 = 0;
int li_72 = 100;
switch (ai_0) {
case 2:
for (l_count_68 = func032(0) - 1; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_BUYLIMIT, a_lots_4, a_price_12, a_slippage_20, 0, 0, a_comment_40, a_magic_48, a_datetime_52, a_color_56);
if (l_ticket_60 > 0) {
if (!gi_1308) OrderModify(l_ticket_60, a_price_12, func014(ad_24, ai_32), func019(a_price_12, ai_36), a_datetime_52, a_color_56);
else updateTrades(l_ticket_60 + ";" + func014(ad_24, ai_32) + ";" + func019(a_price_12, ai_36));
}
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
break;
case 4:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_BUYSTOP, a_lots_4, a_price_12, a_slippage_20, 0, 0, a_comment_40, a_magic_48, a_datetime_52, a_color_56);
if (l_ticket_60 > 0) {
if (!gi_1308) OrderModify(l_ticket_60, a_price_12, func014(ad_24, ai_32), func019(a_price_12, ai_36), a_datetime_52, a_color_56);
else updateTrades(l_ticket_60 + ";" + func014(ad_24, ai_32) + ";" + func019(a_price_12, ai_36));
}
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 0:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
RefreshRates();
l_ticket_60 = OrderSend(Symbol(), OP_BUY, a_lots_4, Ask, a_slippage_20, 0, 0, a_comment_40, a_magic_48, a_datetime_52, a_color_56);
if (l_ticket_60 > 0) {
if (!gi_1308) OrderModify(l_ticket_60, Ask, func014(Bid, ai_32), func019(Ask, ai_36), a_datetime_52, a_color_56);
else updateTrades(l_ticket_60 + ";" + func014(Bid, ai_32) + ";" + func019(Ask, ai_36));
}
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 3:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_SELLLIMIT, a_lots_4, a_price_12, a_slippage_20, 0, 0, a_comment_40, a_magic_48, a_datetime_52, a_color_56);
if (l_ticket_60 > 0) {
if (!gi_1308) OrderModify(l_ticket_60, a_price_12, func051(ad_24, ai_32), func058(a_price_12, ai_36), a_datetime_52, a_color_56);
else updateTrades(l_ticket_60 + ";" + func051(ad_24, ai_32) + ";" + func058(a_price_12, ai_36));
}
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 5:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_SELLSTOP, a_lots_4, a_price_12, a_slippage_20, 0, 0, a_comment_40, a_magic_48, a_datetime_52, a_color_56);
if (l_ticket_60 > 0) {
if (!gi_1308) OrderModify(l_ticket_60, a_price_12, func051(ad_24, ai_32), func058(a_price_12, ai_36), a_datetime_52, a_color_56);
else updateTrades(l_ticket_60 + ";" + func051(ad_24, ai_32) + ";" + func058(a_price_12, ai_36));
}
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (l_count_68 = 0; l_count_68 < li_72; l_count_68++) {
l_ticket_60 = OrderSend(Symbol(), OP_SELL, a_lots_4, Bid, a_slippage_20, 0, 0, a_comment_40, a_magic_48, a_datetime_52, a_color_56);
if (l_ticket_60 > 0) {
if (!gi_1308) OrderModify(l_ticket_60, Bid, func051(Ask, ai_32), func058(Bid, ai_36), a_datetime_52, a_color_56);
else updateTrades(l_ticket_60 + ";" + func051(Ask, ai_32) + ";" + func058(Bid, ai_36));
}
l_error_64 = GetLastError();
if (l_error_64 == 0/* NO_ERROR */) break;
if (!((l_error_64 == 4/* SERVER_BUSY */ || l_error_64 == 137/* BROKER_BUSY */ || l_error_64 == 146/* TRADE_CONTEXT_BUSY */ || l_error_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (l_ticket_60);
}
double func014(double ad_0, int ai_8) {
if (ai_8 == func032(0) - 1) return (gi_936 - gi_584);
return (ad_0 - ai_8 * g_point_1296);
}
double func051(double ad_0, int ai_8) {
if (ai_8 == func032(0) - 1) return (gi_936 - gi_584);
return (ad_0 + ai_8 * g_point_1296);
}
void func050(int ai_0) {
gi_584 = ai_0;
gi_936 = gi_584;
}
void func049() {
for (gd_720 = 0; gd_720 < OrdersTotal(); gd_720++) {
if (OrderType() == OP_BUY && Close[1] - NormalizeDouble(OrderOpenPrice(), 4) >= gd_1132 * g_point_1296 || NormalizeDouble(OrderOpenPrice(), 4) - Close[1] >= gd_1124 * g_point_1296) {
for (int li_0 = 1; li_0 <= gd_1100; li_0++) {
gi_1032 = FALSE;
RefreshRates();
if (gi_1032) {
gd_1108 = 500;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
if (OrderType() == OP_SELL && Close[1] - NormalizeDouble(OrderOpenPrice(), 4) >= gd_1124 * g_point_1296 || NormalizeDouble(OrderOpenPrice(), 4) - Close[1] >= gd_1132 * g_point_1296) {
for (li_0 = 1; li_0 <= gd_1100; li_0++) {
gi_1032 = FALSE;
RefreshRates();
if (gi_1032) {
gd_1108 = 500;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
}
}
double func013() {
if (gd_1140 == 0.0) return (gd_992);
double ld_ret_0 = MathRound(AccountBalance() / 100.0 * gd_1140 / 100.0) / 10.0;
if (ld_ret_0 < 0.1) ld_ret_0 = 0.1;
if (ld_ret_0 > gd_1000) ld_ret_0 = gd_1000;
return (ld_ret_0);
}
void func048() {
gd_1116 = MathRound(gd_228 / gd_1008);
gd_1124 = MathRound(gd_228 / gd_940);
gd_948 = MathRound(gd_1124 * gd_964);
if (Close[1] >= gd_260) {
for (int li_0 = 1; li_0 <= gd_1100; li_0++) {
RefreshRates();
func009();
if (g_ticket_972 > 0.0) {
gd_unused_1016 = Day();
gd_1108 = 1000;
break;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
if (gd_252 >= Close[1]) {
for (li_0 = 1; li_0 <= gd_1100; li_0++) {
RefreshRates();
Lots = func013();
if (g_ticket_972 > 0.0) {
gd_unused_1016 = Day();
gd_1108 = 1000;
return;
}
gd_1108 = 2.0 * gd_1108;
if (li_0 == gd_1100) {
gd_1108 = 1000;
return;
}
func046();
}
}
}
void func012() {
gd_1132 = MathRound(gd_736 / gd_1024);
gd_1124 = MathRound(gd_736 / gd_940);
gd_948 = MathRound(gd_1124 * gd_964);
if (Close[1] >= gd_776) {
for (int li_0 = 1; li_0 <= gd_1100; li_0++) {
RefreshRates();
Lots = func013();
if (g_ticket_972 > 0.0) {
gd_unused_1016 = Day();
gd_1108 = 1000;
break;
}
gd_1108 = 2.0 * gd_1108;
func054();
if (li_0 == gd_1100) {
gd_1108 = 1000;
break;
}
}
}
if (gd_760 >= Close[1]) {
for (li_0 = 1; li_0 <= gd_1100; li_0++) {
RefreshRates();
Lots = func013();
if (g_ticket_972 > 0.0) {
gd_unused_1016 = Day();
gd_1108 = 1000;
return;
}
gd_1108 = 2.0 * gd_1108;
func015();
func041();
if (li_0 == gd_1100) {
gd_1108 = 1000;
return;
}
func011();
}
}
}
int func047() {
int l_ord_total_0 = OrdersTotal();
if (g_pips_956 == 0.0) return (0);
for (int l_pos_4 = 0; l_pos_4 < l_ord_total_0; l_pos_4++) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == g_magic_268 || OrderMagicNumber() == g_magic_276) {
if (OrderType() == OP_BUY) {
if (g_pips_956 <= 0.0) continue;
if (Bid - OrderOpenPrice() <= g_point_1296 * g_pips_956) continue;
if (OrderStopLoss() >= Bid - g_point_1296 * g_pips_956) continue;
return (0);
} else {
if (g_pips_956 <= 0.0) continue;
if (OrderOpenPrice() - Ask <= g_point_1296 * g_pips_956) continue;
if (OrderStopLoss() <= Ask + g_point_1296 * g_pips_956) continue;
func008();
func007();
return (0);
}
}
}
return (0);
}
int func011() {
int l_count_0 = 0;
func043();
for (int li_4 = OrdersTotal(); li_4 > 0; li_4--) {
OrderSelect(li_4 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == g_magic_1036) l_count_0++;
}
return (l_count_0);
}
double func046() {
double ld_ret_0 = 0;
for (int li_8 = OrdersTotal(); li_8 > 0; li_8--) {
OrderSelect(li_8 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == g_magic_1036) ld_ret_0 += OrderProfit();
}
func006(1);
return (ld_ret_0);
}
void func010(int ai_0, int ai_4, double a_price_8) {
int li_16;
double l_ord_stoploss_20;
double l_price_28;
string ls_unused_36 = "224556752511231114025065061661";
if (ai_4 != 0) {
for (int l_pos_44 = OrdersTotal() - 1; l_pos_44 >= 0; l_pos_44--) {
if (OrderSelect(l_pos_44, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
li_16 = NormalizeDouble((Bid - a_price_8) / g_point_1296, gi_936 - gi_584);
if (li_16 < ai_0) continue;
l_ord_stoploss_20 = OrderStopLoss();
l_price_28 = Bid - ai_4 * g_point_1296;
if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 > l_ord_stoploss_20)) {
if (!gi_1308) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Aqua);
else updateTrades(OrderTicket() + ";" + l_price_28 + ";" + OrderTakeProfit());
}
}
if (OrderType() == OP_SELL) {
li_16 = NormalizeDouble((a_price_8 - Ask) / g_point_1296, gi_936 - gi_584);
if (li_16 < ai_0) continue;
l_ord_stoploss_20 = OrderStopLoss();
l_price_28 = Ask + ai_4 * g_point_1296;
if (l_ord_stoploss_20 == 0.0 || (l_ord_stoploss_20 != 0.0 && l_price_28 < l_ord_stoploss_20)) {
if (!gi_1308) OrderModify(OrderTicket(), a_price_8, l_price_28, OrderTakeProfit(), 0, Red);
else updateTrades(OrderTicket() + ";" + l_price_28 + ";" + OrderTakeProfit());
}
}
}
Sleep(1000);
}
}
}
}
int func045(int ai_0) {
if (func003(ai_0) + func056(ai_0) == Ask) return (func055(ai_0));
return (func055(2 * ai_0));
}
void func009() {
double l_ask_0;
double l_bid_8;
bool li_16 = TRUE;
bool li_20 = FALSE;
func044(PERIOD_M1);
while (!li_20) {
li_16 = TRUE;
for (int li_24 = OrdersTotal(); li_24 > 0; li_24--) {
OrderSelect(li_24 - 1, SELECT_BY_POS, MODE_TRADES);
l_ask_0 = MarketInfo(OrderSymbol(), MODE_ASK);
l_bid_8 = MarketInfo(OrderSymbol(), MODE_BID);
}
li_20 = li_16;
}
}
int func044(int a_timeframe_0) {
int l_period_4;
double l_ima_8 = iMA(Symbol(), a_timeframe_0, l_period_4, 0, MODE_EMA, PRICE_CLOSE, 1);
double l_ima_16 = iMA(Symbol(), a_timeframe_0, l_period_4, 0, MODE_EMA, PRICE_CLOSE, 2);
if (l_ima_8 > l_ima_16) return (0);
if (l_ima_8 < l_ima_16) return (1);
return (-1);
}
int func008() {
for (int li_0 = OrdersTotal(); li_0 > 0; li_0--) {
OrderSelect(li_0 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY) {
if (Bid - OrderOpenPrice() > g_pips_336 * g_point_1296) {
if (!gi_1308) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Black);
else updateTrades(OrderTicket() + ";" + OrderOpenPrice() + ";" + OrderTakeProfit());
}
} else {
if (OrderType() == OP_SELL) {
if (OrderOpenPrice() - Ask > g_pips_336 * g_point_1296) {
if (!gi_1308) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Black);
else updateTrades(OrderTicket() + ";" + OrderOpenPrice() + ";" + OrderTakeProfit());
}
}
}
}
return (0);
}
double func043() {
if (gd_1140 == 0.0) return (g_lots_344);
double ld_ret_0 = MathRound(AccountBalance() / 100.0 * gd_1140 / 100.0) / 10.0;
if (ld_ret_0 < 0.1) ld_ret_0 = 0.1;
return (ld_ret_0);
}
int func007() {
for (int li_0 = OrdersTotal(); li_0 > 0; li_0--) {
OrderSelect(li_0 - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY && OrderSymbol() == Symbol()) {
if (Bid - OrderOpenPrice() > g_pips_368 * g_point_1296 && OrderStopLoss() == 0.0) {
if (!gi_1308) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Black);
else updateTrades(OrderTicket() + ";" + OrderOpenPrice() + ";" + OrderTakeProfit());
}
} else {
if (OrderType() == OP_SELL && OrderSymbol() == Symbol()) {
if (OrderOpenPrice() - Ask > g_pips_368 * g_point_1296 && OrderStopLoss() == 0.0) {
if (!gi_1308) OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Black);
else updateTrades(OrderTicket() + ";" + OrderOpenPrice() + ";" + OrderTakeProfit());
}
}
}
}
return (0);
}
void func042() {
gd_1180 = 1;
gd_unused_1188 = gd_1044;
gd_unused_1196 = gd_1156;
}
void func041() {
bool li_0;
if (gd_1204 > 0.0) {
if (gd_792 != 0.0 && gd_800 != 0.0) {
li_0 = OrderCloseBy(gd_792, gd_800);
if (li_0 == TRUE) gd_1204--;
else Print("Error close double orders:" + GetLastError());
} else {
if (gd_800 == 0.0 && gd_792 != 0.0) {
li_0 = OrderClose(gd_792, g_lots_344, Ask, 3);
if (li_0 == TRUE) gd_1204--;
else Print("Error close sell:" + GetLastError());
} else {
if (gd_792 == 0.0 && gd_800 != 0.0) {
li_0 = OrderClose(gd_800, g_lots_344, Bid, 3);
if (li_0 == TRUE) gd_1204--;
else Print("Error close buy:" + GetLastError());
}
}
}
}
if (gd_808 > 0.0) {
li_0 = OrderDelete(g_ticket_392);
if (li_0 == TRUE) gd_808--;
else func005();
}
func005();
if (gd_808 == 0.0 && gd_1204 == 0.0) func042();
}
int func006(double a_price_0) {
double l_price_12;
double l_price_20;
if (!gd_1180) return (0);
if (g_pips_400 > 0.0) l_price_12 = a_price_0 - g_pips_400 * g_point_1296;
else l_price_12 = 0;
if (g_pips_408 > 0.0) l_price_20 = a_price_0 + g_pips_408 * g_point_1296;
else l_price_20 = 0;
int l_ticket_8 = OrderSend(Symbol(), OP_BUYSTOP, g_lots_344, a_price_0, 3, 0, 0, "", g_magic_1036, 0, CLR_NONE);
if (l_ticket_8 > 0) {
if (!gi_1308) OrderModify(l_ticket_8, a_price_0, l_price_12, l_price_20, 0, CLR_NONE);
else updateTrades(l_ticket_8 + ";" + l_price_12 + ";" + l_price_20);
}
return (l_ticket_8);
}
int func040(double a_price_0) {
double l_price_8;
double l_price_16;
if (!gd_1180) return (0);
if (g_pips_416 > 0.0) l_price_8 = a_price_0 + g_pips_416 * g_point_1296;
else l_price_8 = 0;
if (g_pips_424 > 0.0) l_price_16 = a_price_0 - g_pips_424 * g_point_1296;
else l_price_16 = 0;
int l_ticket_24 = OrderSend(Symbol(), OP_SELLSTOP, g_lots_344, a_price_0, 3, 0, 0, "", g_magic_1036, 0, CLR_NONE);
if (l_ticket_24 > 0) {
if (!gi_1308) OrderModify(l_ticket_24, a_price_0, l_price_8, l_price_16, 0, CLR_NONE);
else updateTrades(l_ticket_24 + ";" + l_price_8 + ";" + l_price_16);
}
func008();
return (l_ticket_24);
}
int func039() {
string ls_0 = "5254063014025065061661";
int l_count_8 = 0;
for (int l_pos_12 = OrdersTotal() - 1; l_pos_12 >= gi_936 - gi_584; l_pos_12--) {
OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) l_count_8++;
}
func057(ls_0);
return (l_count_8);
}
void func005() {
ArrayInitialize(g_ticket_392, 0);
gd_808 = 0;
ArrayInitialize(gd_800, 0);
gd_432 = 0;
ArrayInitialize(gd_792, 0);
gd_440 = 0;
gd_1204 = 0;
int li_0 = OrdersTotal();
for (int l_ord_total_4 = li_0; l_ord_total_4 >= 0; l_ord_total_4--) {
OrderSelect(l_ord_total_4, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUYSTOP && OrderMagicNumber() == g_magic_1036) {
gd_808++;
g_ticket_392 = OrderTicket();
}
if (OrderType() == OP_SELLSTOP && OrderMagicNumber() == g_magic_1036) {
gd_808++;
g_ticket_392 = OrderTicket();
}
if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_1036) {
gd_440++;
gd_792 = OrderTicket();
}
if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_1036) {
gd_432++;
gd_800 = OrderTicket();
}
}
gd_1204 = gd_432;
if (gd_440 > gd_1204) gd_1204 = gd_440;
}
double func004() {
double ld_ret_0 = 0;
int li_8 = OrdersTotal();
func037(23);
func036(23);
for (int l_ord_total_12 = li_8; l_ord_total_12 >= 0; l_ord_total_12--) {
OrderSelect(l_ord_total_12, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_1036) ld_ret_0 = ld_ret_0 + OrderProfit() + OrderSwap();
if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_1036) ld_ret_0 = ld_ret_0 + OrderProfit() + OrderSwap();
}
func043();
return (ld_ret_0);
}
int func003(int ai_0) {
if (iClose(Symbol(), 0, ai_0) < 0.0) return (1);
return (func056(iClose(Symbol(), 0, ai_0 + 1)));
}
int func002() {
if (Bars < 100) {
Comment("bars less than 100");
return (0);
}
g_ord_total_448 = OrdersTotal();
int li_0 = gd_456;
func023();
func034();
if (g_ord_total_448 > 0.0) {
for (gd_720 = 0; gd_720 < g_ord_total_448; gd_720++) {
OrderSelect(g_pos_360, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_472) {
Comment("Ęîíňđîëčđóţ íŕ BUY: ", OrderTicket());
func022();
if (iRVI(NULL, PERIOD_M5, 8, MODE_MAIN, 1) > iRVI(NULL, PERIOD_M5, 8, MODE_SIGNAL, 1) && iRVI(NULL, PERIOD_M5, 8, MODE_MAIN, 0) < iRVI(NULL, PERIOD_M5, 8, MODE_SIGNAL, 0) &&
iRVI(NULL, PERIOD_M5, 8, MODE_MAIN, 1) > 0.15) {
if (Bid > OrderOpenPrice() + g_pips_464 * g_point_1296) {
gd_816 = 1;
gd_832 = 0;
}
}
if (iStochastic(NULL, PERIOD_M5, 12, 4, 3, MODE_EMA, 1, MODE_MAIN, 1) < iStochastic(NULL, PERIOD_M5, 12, 4, 3, MODE_EMA, 1, MODE_SIGNAL, 1) && iStochastic(NULL, PERIOD_M5, 12, 4, 3, MODE_EMA, 1, MODE_SIGNAL, 1) > 70.0 &&
gd_824 > 0.0) {
if (Bid > OrderOpenPrice() + (g_pips_464 - 3.0) * g_point_1296) {
gd_816 = 1;
gd_832 = 0;
func059(2);
}
}
g_iadx_840 = iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_MAIN, 0);
g_iadx_848 = iADX(NULL, Period(), 14, PRICE_CLOSE, MODE_MAIN, 1);
if (g_iadx_848 > g_iadx_840 && g_iadx_840 < gd_156) {
if (Bid > OrderOpenPrice() + g_pips_872 * g_point_1296) {
gd_816 = 1;
gd_832 = 0;
func028();
}
}
if (gd_816 > 0.0) {
g_ticket_972 = OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_880, Aqua);
if (g_ticket_972 > 0.0) {
gd_unused_888 = TimeCurrent();
gd_816 = 0;