-
Notifications
You must be signed in to change notification settings - Fork 2
/
NO17.mq4
753 lines (722 loc) · 53.6 KB
/
NO17.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
// ApM Modded v006 05/11/2012
#property copyright "Copyleft 2012"
#property link "http://www.net"
string modver = "M6 (TLP public)";
extern bool ShowTradeComment = TRUE;
//extern bool RealtimeChartUpdate = FALSE;
extern double Lots = 0.01;
extern double MultiLotsFactor = 1.6;
extern double StepLots = 15.0;
extern double TakeProfit = 23.0;
extern bool UseTrailing = FALSE;
extern double TrailStart = 38.0;
extern double TrailStop = 18.0;
extern int MaxOpenOrders = 15;
extern bool SafeEquityStopOut = FALSE;
extern double SafeEquityRisk = 0.5;
extern double Slippage = 3.0;
extern int MagicNumber = 2024536;
extern bool FreezeAfterTP = FALSE;
extern bool Close_All_Orders = FALSE;
extern string TradeComment = "FXGT";
extern string ______________ = "�����������:";
extern int StartHour = 0;
extern int StartMinute = 0;
extern int StopHour = 0;
extern int StopMinute = 0;
extern int StartingTradeDay = 0;
extern int EndingTradeDay = 7;
/*extern*/ bool UseLotFix = TRUE;
bool gi_184 = FALSE;
double gd_188 = 48.0;
double gd_196 = 500.0;
double gd_204 = 0.0;
bool gi_212 = TRUE;
bool gi_216 = FALSE;
int gi_220 = 1;
double gd_224;
double gd_232;
double gd_240;
double gd_248;
double gd_256;
double gd_264;
double gd_272;
double gd_280;
bool gi_HaveNewOpenOrders;
int gt_292 = 0;
int gi_296;
int gi_300 = 0;
double gd_304;
int gi_312 = 0;
int gi_OrdersOpen;
double gd_320 = 0.0;
bool gi_328 = FALSE;
bool gi_332 = FALSE;
bool gi_336 = FALSE;
int gi_340;
bool gi_344 = FALSE;
int gi_348 = 0;
int gi_352 = 0;
double gd_356;
double gd_364;
string gs_off_372 = "OFF";
string gs_live_380 = "REAL";
string gs_396 = "";
bool gi_408 = TRUE;
bool gi_412 = TRUE;
int gi_416 = 0;
int gi_420;
int gStartMinutes, gStopMinutes;
double PipToTP, MaxDD = 0;
bool IsTradeTime() {
if (FreezeAfterTP) return(false);
bool AllowTrade = true;
gStartMinutes = 60 * StartHour + StartMinute;
gStopMinutes = 60 * StopHour + StopMinute;
int day = DayOfWeek();
if (day < StartingTradeDay || day > EndingTradeDay) AllowTrade = false;
int minuntes = 60 * TimeHour(TimeCurrent()) + TimeMinute(TimeCurrent());
if (day <= StartingTradeDay && gStartMinutes >= minuntes) AllowTrade = false;
if (day >= EndingTradeDay && gStopMinutes < minuntes) AllowTrade = false;
return(AllowTrade);
}
int init() {
if (Digits == 2 || Digits == 4) gi_420 = 1;
else gi_420 = 10;
gi_416 = AccountNumber();
gd_280 = MarketInfo(Symbol(), MODE_SPREAD) * Point * gi_420;
double MI = MarketInfo(Symbol(), MODE_MINLOT);
if (MI == 0.001)
gd_204 = 3;
else if (MI == 0.01)
gd_204 = 2;
else if (MI == 0.1)
gd_204 = 1;
else if (MI == 1.0)
gd_204 = 0;
if (SafeEquityStopOut) gs_off_372 = "ON";
if (IsDemo()) gs_live_380 = "DEMO";
if (Period() != PERIOD_M1) {
Print("FGT ERROR :: Invalid Timeframe, Please switch to M1.");
Alert("FGT ERROR :: ", " Invalid Timeframe, Please switch to M1.");
gs_396 = "Invalid Timeframe. FGT works on M1";
gi_408 = FALSE;
}
return (0);
}
int deinit() {
Comment("");
if (ObjectFind("BG") >= 0) ObjectDelete("BG");
if (ObjectFind("BG1") >= 0) ObjectDelete("BG1");
if (ObjectFind("BG2") >= 0) ObjectDelete("BG2");
if (ObjectFind("BG3") >= 0) ObjectDelete("BG3");
if (ObjectFind("BG4") >= 0) ObjectDelete("BG4");
if (ObjectFind("BG5") >= 0) ObjectDelete("BG5");
if (ObjectFind("NAME") >= 0) ObjectDelete("NAME");
return (0);
}
int start() {
if (Close_All_Orders == TRUE) {f0_4(); return (0);}
int lia_0[1];
int lia_4[1];
double ld_12;
double ld_20;
double ld_28;
double ld_36;
int li_52;
if (UseTrailing) f0_18(TrailStart, TrailStop, gd_240);
if (gi_184) {
if (TimeCurrent() >= gi_296) {
f0_4();
Print("Closed All Trades Due To Server TimeOut");
}
}
if (gt_292 == Time[0]) return (0);
gt_292 = Time[0];
double ld_44 = f0_6();
if (SafeEquityStopOut) {
if (ld_44 < 0.0 && MathAbs(ld_44) > SafeEquityRisk / 100.0 * f0_9()) {
f0_4();
Print("Closed All due to EQUITY STOP-OUT");
gi_344 = FALSE;
}
}
gi_HaveNewOpenOrders = FALSE;
gi_OrdersOpen = f0_16();
//if (gi_OrdersOpen == 0) gi_HaveNewOpenOrders = FALSE;
for (gi_312 = OrdersTotal() - 1; gi_312 >= 0; gi_312--) {
if ( OrderSelect(gi_312, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
gi_332 = TRUE;
gi_336 = FALSE;
ld_12 = OrderLots();
break;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_SELL) {
gi_332 = FALSE;
gi_336 = TRUE;
ld_20 = OrderLots();
break;
}
}
}
}
gi_328 = FALSE;
if (gi_OrdersOpen > 0 && gi_OrdersOpen <= MaxOpenOrders) {
RefreshRates();
gd_264 = f0_2();
gd_272 = f0_7();
li_52 = func1(gi_332, gi_336, Bid, Ask, gd_264, gd_272, Point, StepLots, gi_420);
if (li_52 == 1) gi_328 = TRUE;
gs_396 = f0_12(3);
}
if (gi_OrdersOpen > 1 && UseLotFix) gi_300 = gi_OrdersOpen-1;
gd_304 = f0_14(OP_SELL);
if (gi_OrdersOpen < 1) {
gi_336 = FALSE;
gi_332 = FALSE;
gi_328 = TRUE;
gd_232 = AccountEquity();
}
if (gi_328) {
gd_264 = f0_2();
gd_272 = f0_7();
if (gi_336) {
if (gi_216) {
f0_1(0, 1);
gd_304 = NormalizeDouble(MultiLotsFactor * ld_20, gd_204);
} else gd_304 = f0_14(OP_SELL);
if (gi_212) {
gi_300 = gi_OrdersOpen;
if (gd_304 > 0.0) {
RefreshRates();
gi_340 = fOrderSend(1, gd_304, Bid, Slippage, Ask, 0, 0, TradeComment + "-" + gi_300, MagicNumber, 0, HotPink);
if (gi_340 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd_272 = f0_7();
gi_328 = FALSE;
gi_344 = TRUE;
}
}
} else {
if (gi_332) {
if (gi_216) {
f0_1(1, 0);
gd_304 = NormalizeDouble(MultiLotsFactor * ld_12, gd_204);
} else gd_304 = f0_14(OP_BUY);
if (gi_212) {
gi_300 = gi_OrdersOpen;
if (gd_304 > 0.0) {
gi_340 = fOrderSend(0, gd_304, Ask, Slippage, Bid, 0, 0, TradeComment + "-" + gi_300, MagicNumber, 0, Lime);
if (gi_340 < 0) {
Print("Error: ", GetLastError());
return (0);
}
gd_264 = f0_2();
gi_328 = FALSE;
gi_344 = TRUE;
}
}
}
}
}
if (gi_328 && gi_OrdersOpen < 1 && IsTradeTime()) {
ld_28 = iClose(Symbol(), 0, 2);
ld_36 = iClose(Symbol(), 0, 1);
gd_248 = Bid;
gd_256 = Ask;
if ((!gi_336) && !gi_332) {
gi_300 = gi_OrdersOpen;
if (ld_28 > ld_36) {
gd_304 = f0_14(OP_SELL);
if (gd_304 > 0.0) {
gi_340 = fOrderSend(1, gd_304, gd_248, Slippage, gd_248, 0, 0, TradeComment + " " + MagicNumber + "-" + gi_300, MagicNumber, 0, HotPink);
if (gi_340 < 0) {
Print(gd_304, "Error: ", GetLastError());
return (0);
}
gd_264 = f0_2();
gi_344 = TRUE;
}
} else {
gd_304 = f0_14(OP_BUY);
if (gd_304 > 0.0) {
gi_340 = fOrderSend(0, gd_304, gd_256, Slippage, gd_256, 0, 0, TradeComment + " " + MagicNumber + "-" + gi_300, MagicNumber, 0, Lime);
if (gi_340 < 0) {
Print(gd_304, "Error: ", GetLastError());
return (0);
}
gd_272 = f0_7();
gi_344 = TRUE;
}
}
}
if (gi_340 > 0) gi_296 = TimeCurrent() + 60.0 * (60.0 * gd_188);
gi_328 = FALSE;
}
gi_OrdersOpen = f0_16();
gd_240 = 0;
double ld_56 = 0;
for (gi_312 = OrdersTotal() - 1; gi_312 >= 0; gi_312--) {
if ( OrderSelect(gi_312, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY || OrderType() == OP_SELL) {
gd_240 += OrderOpenPrice() * OrderLots();
ld_56 += OrderLots();
//if (OrderProfit() < -2000) {f0_4();}
//////////////////////////////////////////////////////
}
}
}
}
if (gi_OrdersOpen > 0) gd_240 = NormalizeDouble(gd_240 / ld_56, Digits);
if (gi_344) {
for (gi_312 = OrdersTotal() - 1; gi_312 >= 0; gi_312--) {
if ( OrderSelect(gi_312, SELECT_BY_POS, MODE_TRADES ) == true) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
gd_224 = gd_240 + TakeProfit * Point * gi_420;
gd_320 = gd_240 - gd_196 * Point * gi_420;
gi_HaveNewOpenOrders = TRUE;
}
}
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_SELL) {
gd_224 = gd_240 - TakeProfit * Point * gi_420;
gd_320 = gd_240 + gd_196 * Point * gi_420;
gi_HaveNewOpenOrders = TRUE;
}
}
}
}}
if (gi_344) {
if (gi_HaveNewOpenOrders == TRUE) {
for (gi_312 = OrdersTotal() - 1; gi_312 >= 0; gi_312--) {
if ( OrderSelect(gi_312, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (NormalizeDouble(gd_224, Digits) == NormalizeDouble(OrderTakeProfit(), Digits)) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if(!OrderModify(OrderTicket(), gd_240, OrderStopLoss(), gd_224, 0, Yellow))
Print("OrderModify BUYda muammo: ",GetLastError());}
Sleep(3000);
if (OrderTakeProfit() > 0) gi_344 = FALSE;
}}
}
}
f0_13();
return (0);
}
void f0_13() {
if (ShowTradeComment) {
if (IsTesting() && !IsVisualMode()) return;
if (ObjectFind("BG") < 0) {
ObjectCreate("BG", OBJ_LABEL, 0, 0, 0);
ObjectSetText("BG", "g", 210, "Webdings", Orange);
ObjectSet("BG", OBJPROP_CORNER, 0);
ObjectSet("BG", OBJPROP_BACK, TRUE);
ObjectSet("BG", OBJPROP_XDISTANCE, 0);
ObjectSet("BG", OBJPROP_YDISTANCE, 15);
}
if (ObjectFind("BG1") < 0) {
ObjectCreate("BG1", OBJ_LABEL, 0, 0, 0);
ObjectSetText("BG1", "g", 210, "Webdings", DimGray);
ObjectSet("BG1", OBJPROP_BACK, FALSE);
ObjectSet("BG1", OBJPROP_XDISTANCE, 0);
ObjectSet("BG1", OBJPROP_YDISTANCE, 42);
}
if (ObjectFind("BG2") < 0) {
ObjectCreate("BG2", OBJ_LABEL, 0, 0, 0);
ObjectSetText("BG2", "g", 210, "Webdings", DimGray);
ObjectSet("BG2", OBJPROP_CORNER, 0);
ObjectSet("BG2", OBJPROP_BACK, TRUE);
ObjectSet("BG2", OBJPROP_XDISTANCE, 0);
ObjectSet("BG2", OBJPROP_YDISTANCE, 42);
}
if (ObjectFind("NAME") < 0) {
ObjectCreate("NAME", OBJ_LABEL, 0, 0, 0);
ObjectSetText("NAME", "FOREX GRID TRADER EA - " + Symbol(), 9, "Arial Bold", White);
ObjectSet("NAME", OBJPROP_CORNER, 0);
ObjectSet("NAME", OBJPROP_BACK, FALSE);
ObjectSet("NAME", OBJPROP_XDISTANCE, 5);
ObjectSet("NAME", OBJPROP_YDISTANCE, 23);
}
if (ObjectFind("BG3") < 0) {
ObjectCreate("BG3", OBJ_LABEL, 0, 0, 0);
ObjectSetText("BG3", "g", 110, "Webdings", DimGray);
ObjectSet("BG3", OBJPROP_CORNER, 0);
ObjectSet("BG3", OBJPROP_BACK, TRUE);
ObjectSet("BG3", OBJPROP_XDISTANCE, 0);
ObjectSet("BG3", OBJPROP_YDISTANCE, 73);
}
if (ObjectFind("BG5") < 0) {
ObjectCreate("BG5", OBJ_LABEL, 0, 0, 0);
ObjectSetText("BG5", "g", 210, "Webdings", DimGray);
ObjectSet("BG5", OBJPROP_CORNER, 0);
ObjectSet("BG5", OBJPROP_BACK, FALSE);
ObjectSet("BG5", OBJPROP_XDISTANCE, 0);
ObjectSet("BG5", OBJPROP_YDISTANCE, 73);
}
f0_3();
}
}
double f0_10(double ad_0) {
return (NormalizeDouble(ad_0, Digits));
}
int f0_1(bool ai_0 = TRUE, bool ai_4 = TRUE) {
int li_8 = 0;
for (int li_12 = OrdersTotal() - 1; li_12 >= 0; li_12--) {
if ( OrderSelect(li_12, SELECT_BY_POS, MODE_TRADES ) == true) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY && ai_0) {
RefreshRates();
if (!IsTradeContextBusy()) {
if (!OrderClose(OrderTicket(), OrderLots(), f0_10(Bid), 5, CLR_NONE)) {
Print("Error close BUY " + OrderTicket());
li_8 = -1;
}
} else {
if (gi_348 == iTime(NULL, 0, 0)) return (-2);
gi_348 = iTime(NULL, 0, 0);
Print("Need close BUY " + OrderTicket() + ". Trade Context Busy");
return (-2);
}
}
if (OrderType() == OP_SELL && ai_4) {
RefreshRates();
if (!IsTradeContextBusy()) {
if (!OrderClose(OrderTicket(), OrderLots(), f0_10(Ask), 5, CLR_NONE)) continue;
Print("Error Closing SELL Trade : " + OrderTicket());
li_8 = -1;
continue;
}
if (gi_352 == iTime(NULL, 0, 0)) return (-2);
gi_352 = iTime(NULL, 0, 0);
Print("Need to close SELL trade : " + OrderTicket() + ". Trade Context Busy");
return (-2);
}
}
}
}
return (li_8);
}
double f0_14(int ai_0) {
double ld_4;
int li_12;
switch (gi_220) {
case 0:
ld_4 = Lots;
break;
case 1:
ld_4 = NormalizeDouble(Lots * MathPow(MultiLotsFactor, gi_300), gd_204);
break;
case 2:
li_12 = 0;
ld_4 = Lots;
for (int li_20 = OrdersHistoryTotal() - 1; li_20 >= 0; li_20--) {
if (!OrderSelect(li_20, SELECT_BY_POS, MODE_HISTORY)) return (-3);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (li_12 < OrderCloseTime()) {
li_12 = OrderCloseTime();
if (OrderProfit() < 0.0) {
ld_4 = NormalizeDouble(OrderLots() * MultiLotsFactor, gd_204);
continue;
}
ld_4 = Lots;
continue;
return (-3);
}
}
}
}
if (AccountFreeMarginCheck(Symbol(), ai_0, ld_4) <= 0.0) return (-1);
if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
return (ld_4);
}
int f0_16() {
PipToTP = 0;
int li_0 = 0;
for (int li_4 = OrdersTotal() - 1; li_4 >= 0; li_4--) {
if ( OrderSelect(li_4, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (OrderType() == OP_SELL || OrderType() == OP_BUY) li_0++;
if (OrderTakeProfit() == 0) {gi_344 = TRUE; gi_HaveNewOpenOrders = TRUE;}
if (OrderTakeProfit() > 0.0 && PipToTP == 0) {
if (OrderType() == OP_SELL) PipToTP = (Ask - OrderTakeProfit() ) / Point / gi_420;
if (OrderType() == OP_BUY) PipToTP = (OrderTakeProfit() - Bid) / Point / gi_420;}
}}
return (li_0);
}
void f0_4() {
for (int li_0 = OrdersTotal() - 1; li_0 >= 0; li_0--) {
if ( OrderSelect(li_0, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY)
{if (!OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue))
Print("OrderClose BUYda muammo: ", GetLastError());}
if (OrderType() == OP_SELL)
{if (!OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red))
Print("OrderClose SELLda muammo: ", GetLastError());}
}
Sleep(1000);
}
}
}}
int fOrderSend(int ai_0, double ad_4, double ad_12, int ai_20, double ad_24, int ai_32, int ai_36, string as_40, int ai_48, int ai_52, color ai_56) {
if (gi_OrdersOpen >= MaxOpenOrders) return(0);
int li_60 = 0;
int li_64 = 0;
int li_68 = 0;
int li_72 = 100;
switch (ai_0) {
case 0:
for (li_68 = 0; li_68 < li_72; li_68++) {
RefreshRates();
li_60 = OrderSend(Symbol(), OP_BUY, ad_4, Ask, ai_20, f0_11(Bid, ai_32), f0_17(Ask, ai_36), as_40, ai_48, ai_52, ai_56);
li_64 = GetLastError();
if (li_64 == 0/* NO_ERROR */) break;
if (!((li_64 == 4/* SERVER_BUSY */ || li_64 == 137/* BROKER_BUSY */ || li_64 == 146/* TRADE_CONTEXT_BUSY */ || li_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
break;
case 1:
for (li_68 = 0; li_68 < li_72; li_68++) {
li_60 = OrderSend(Symbol(), OP_SELL, ad_4, Bid, ai_20, f0_0(Ask, ai_32), f0_5(Bid, ai_36), as_40, ai_48, ai_52, ai_56);
li_64 = GetLastError();
if (li_64 == 0/* NO_ERROR */) break;
if (!((li_64 == 4/* SERVER_BUSY */ || li_64 == 137/* BROKER_BUSY */ || li_64 == 146/* TRADE_CONTEXT_BUSY */ || li_64 == 136/* OFF_QUOTES */))) break;
Sleep(5000);
}
}
return (li_60);
}
double f0_11(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 - ai_8 * Point * gi_420);
}
double f0_0(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 + ai_8 * Point * gi_420);
}
double f0_17(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 + ai_8 * Point * gi_420);
}
double f0_5(double ad_0, int ai_8) {
if (ai_8 == 0) return (0);
return (ad_0 - ai_8 * Point * gi_420);
}
double f0_6() {
double ld_0 = 0;
for (gi_312 = OrdersTotal() - 1; gi_312 >= 0; gi_312--) {
if ( OrderSelect(gi_312, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
if (OrderType() == OP_BUY || OrderType() == OP_SELL) ld_0 += OrderProfit();
}}
return (ld_0);
}
void f0_18(int ai_0, int ai_4, double ad_8) {
int li_16;
double ld_20;
double ld_28;
if (ai_4 != 0) {
for (int li_36 = OrdersTotal() - 1; li_36 >= 0; li_36--) {
if ( OrderSelect(li_36, SELECT_BY_POS, MODE_TRADES ) == true) {
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() || OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) {
li_16 = NormalizeDouble((Bid - ad_8) / Point / gi_420, 0);
if (li_16 < ai_0) continue;
ld_20 = OrderStopLoss();
ld_28 = Bid - ai_4 * Point * gi_420;
if (ld_20 == 0.0 || (ld_20 != 0.0 && ld_28 > ld_20)){
if(!OrderModify(OrderTicket(), ad_8, ld_28, OrderTakeProfit(), 0, Aqua))
Print("OrderModify OP_BUYda muammo: ", GetLastError());}
}
if (OrderType() == OP_SELL) {
li_16 = NormalizeDouble((ad_8 - Ask) / Point / gi_420, 0);
if (li_16 < ai_0) continue;
ld_20 = OrderStopLoss();
ld_28 = Ask + ai_4 * Point * gi_420;
if (ld_20 == 0.0 || (ld_20 != 0.0 && ld_28 < ld_20)){
if(!OrderModify(OrderTicket(), ad_8, ld_28, OrderTakeProfit(), 0, Red))
Print("OrderModify SELLda muammo: ", GetLastError());}
}
}
Sleep(1000);
}
}
}
}
double f0_9() {
if (f0_16() == 0) gd_356 = AccountEquity();
if (gd_356 < gd_364) gd_356 = gd_364;
else gd_356 = AccountEquity();
gd_364 = AccountEquity();
return (gd_356);
}
double f0_2() {
double ld_0;
int li_8;
double ld_12 = 0;
int li_20 = 0;
for (int li_24 = OrdersTotal() - 1; li_24 >= 0; li_24--) {
if ( OrderSelect(li_24, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_BUY) {
li_8 = OrderTicket();
if (li_8 > li_20) {
ld_0 = OrderOpenPrice();
ld_12 = ld_0;
li_20 = li_8;
}}
}
}
return (ld_0);
}
double f0_7() {
double ld_0;
int li_8;
double ld_12 = 0;
int li_20 = 0;
for (int li_24 = OrdersTotal() - 1; li_24 >= 0; li_24--) {
if ( OrderSelect(li_24, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber && OrderType() == OP_SELL) {
li_8 = OrderTicket();
if (li_8 > li_20) {
ld_0 = OrderOpenPrice();
ld_12 = ld_0;
li_20 = li_8;
}}
}
}
return (ld_0);
}
void f0_3() {
string ls_1 = "", ls_2 = "", ls_3 = "";
string ls_0 = DoubleToStr(balanceDeviation(), 2);
if (balanceDeviation() > MaxDD) MaxDD = balanceDeviation();
ls_3 = "Margin Usage: " + DoubleToStr(100 - (AccountFreeMargin()/AccountBalance()*100),2) + "%\n";
if (!IsTradeTime()) ls_1 = "New Trades disallowed by scheduler";
if (FreezeAfterTP) ls_1 = "Freeze AfterTP Enabled";
Comment(""
+ "\n"
+ "\n"
+ "\n"
+ "EXPERT VERSION: 1.0 " + modver
+ "\n"
+ "======================================="
//+ "\n"
//+ "-----------------------------------------------------------------------------------"
//+ "\n"
//+ "AUTHENTICATION STATUS"
//+ "\n"
//+ "-----------------------------------------------------------------------------------"
//+ "\n"
//+ "STATUS MESSAGE: " + gs_396
//+ "\n"
//+ "-----------------------------------------------------------------------------------"
+ "\n"
+ "ACCOUNT INFORMATION"
+ "\n"
+ "-----------------------------------------------------------------------------------"
+ "\n"
//+ "Account Name: " + AccountName()
//+ "\n"
+ "Account Number: " + AccountNumber() + " (" + gs_live_380 + ")"
+ "\n"
//+ "Account Type: " + gs_live_380
//+ "\n"
+ "Account Leverage: 1:" + DoubleToStr(AccountLeverage(), 0)
+ "\n"
+ "Account Balance: " + DoubleToStr(AccountBalance(), 2)
+ "\n"
+ "Account Equity: " + DoubleToStr(AccountEquity(), 2)
+ "\n"
+ "Server Time: " + TimeToStr(TimeCurrent(), TIME_SECONDS)
+ "\n"
+ "-----------------------------------------------------------------------------------"
+ "\n"
+ "TRADE INFORMATIONS "
+ "\n"
+ "------------------------------------------------------------------------------------"
+ "\n"
+ "SAFE EQUITY STOP OUT : " + gs_off_372 + " @ " + DoubleToStr(SafeEquityRisk*100, 2) + "%"
+ "\n"
//+ "SAFE EQUITY RISK % : " + DoubleToStr(SafeEquityRisk, 2)
//+ "\n"
+ ls_2
+ "NEXT LOT(S) : " + DoubleToStr(gd_304, 2)
+ "\n"
+ "OPEN TRADES : " + DoubleToStr(f0_8(), 0) + " / " + MaxOpenOrders
+ "\n"
+ "FLOATING P/L : " + DoubleToStr(AccountProfit(), 2)
+ "\n"
// + "CURRENT PROFIT: " + DoubleToStr(CurProfit, 2)
// + "\n"
// + "POTENTIAL PROFIT: " + DoubleToStr(PotProfit, 2)
// + "\n"
+ "Pips To TP: " + DoubleToStr(PipToTP, 1)
+ "\n"
+ "=======================================\n"
+ "Drawdown : " + ls_0 + "%"
+ "\n"
+ "Drawdown (Max) : " + DoubleToStr(MaxDD,2) + "%"
+ "\n"
+ ls_3
+ "Total Profit/Loss : " + DoubleToStr(calculatePLBalance(),2) + "\n"
+ ls_1
);
}
double calculatePLBalance() {
double gd_TotalPL = 0;
int li_0 = OrdersHistoryTotal();
for (int li_4 = 0; li_4 < li_0; li_4++) {
if ( OrderSelect(li_4, SELECT_BY_POS, MODE_HISTORY)) {
if (OrderMagicNumber() == MagicNumber) gd_TotalPL += OrderProfit() + OrderSwap() + OrderCommission();
}
}
return(gd_TotalPL);
}
double balanceDeviation() {
double bd;
bd = (AccountEquity() / AccountBalance() - 1.0) / (-0.01);
if (bd <= 0.0) return (0);
return (bd);
}
int f0_8() {
int li_0 = OrdersTotal();
int li_8 = 0;
for (int li_4 = 0; li_4 < li_0; li_4++) {
if ( OrderSelect(li_4, SELECT_BY_POS, MODE_TRADES ) == true){
if ((OrderType() == OP_SELL || OrderType() == OP_BUY) && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{li_8++;}
}}
return (li_8);
}
string f0_12(int ai_0) {
if (ai_0 == 0) return ("HTTP Error");
if (ai_0 == 1) return ("Account does not exist or banned");
if (ai_0 == 2) return ("Account Activation Successful");
if (ai_0 == 3) return ("Account Authentication Successful");
if (ai_0 == 4) return ("Account not Activated!!!");
if (ai_0 == 5) return ("Insert a valid CLICKBANK ID.");
return ("Ok");
}
int func1(int a1, int a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
if ( a1 && a7 * a8 * a9 <= a5 - a4 ) return(1);
if ( a2 && a3 - a6 >= a9 * a8 * a7 ) return(1);
return(0);
}