-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLego_v3.mq4
executable file
·1457 lines (1175 loc) · 54.8 KB
/
Lego_v3.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
//+------------------------------------------------------------------+
//| Build_Own_Strategy!.mq4 |
//| Copyright © 2010 Seletsky R.V.|
//| Copyleft @ 2011 Gloodun J. D.|
//| Copyleft © 2010-2011, AnonymousMMMMMMMMMI|
//+------------------------------------------------------------------+
#property copyright "S R V; Anon 9001; So"
#property link "MQL4.com; Strategy4you.ru"
//-----------------------------------------------------------------------------------------------------------+
// Instructions |
//------------------------------------------------------------------------------------------------------ 1 --+
// This advisor is built as a shell for your genius ideas.
// Has unusual thigs like money managemnt, stops management (very rare bird in bots!)
// Actually, I saw all that attempts of writting lame "grails", so I had to... GIVE AN OPPORTUNITY!
// Srsly. But I have to put MY OWN strategy just for a test...
// I've spent two months of free time for previos version.
// But the previous version was 3/10 rated, so I have to make some more... examples...
// But hey, it is also a collection of free scripts!
// For example, you can find a block of "condition screening",
// or learn, how to use custom indicators, or even input own strategy you was using two years.
// The point is both writting own strategy in minutes and inputting all the scripts and advisor-followers together with the advisor itself.
// Well, 95% of "robots" on MQL4 are empty grails... so I decided to make "Lvl. 11 Universal" robot.
// My point is providing customisability among closing methods...
// Right now, you can write/get own "indicator(s)" for defining closes separately from opens.
// I also capitalised ATR as TP and SL setter. Well, he slows the system, so
// Anyway, an attempt to put "two different closes at once" was a sort of pain in butt. So I had to make very unnice "dirty hack" way:
// - mount away limits and makes Open Size and Close Size of LOTS different, after what, use same blocks of Signals (Open\Close) for signalling. Looks murky,
// but the worst is possibilty to bug the strategy.
// Well, I can give some examples of coding.
// //CCI:-------------------------------
// if(otkr_CCI==true)
// {
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN, 1)<-100) See?
// { * * * * * * In's like some highschool math.
// CCI_By =true; Variable are in the left and in the right. Also: print : "iCCI(" here:
// You'll see some brief info. Normally, write after: NULL,0
// }
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN,1)>100)
// {
// CCI_Sell =true;
// }
// }
//
// if(zakr_CCI==true)
// {
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN, 1)<-100)
// {
// Cls_CCI_Sell=true;
// }
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN,1)>100)
// {
// Cls_CCI_By=true;
// }
// }
//
//
// Or another one (custom, this time. Really may be found here):
// if(otkr_Custom_14==true) // Well, ZigZag is not too very good example.
// {
// if(iCustom(NULL,0,"ZigZag",0,0)>PRICE_CLOSE)// Not for profit!
// { //Actually, all the paramethers are just basic ZZ's 5-7-12 or whatever... BASIC ones.)
// Custom_14_By=true;
// }
//
// if(iCustom(NULL,0,"ZigZag",0,0)<PRICE_CLOSE)
// {
// Custom_14_Sell=true;
// }
//
// }
//
// if(zakr_Custom_14==true)
// {
// if(iCustom(NULL,0,"ZigZag",0,0)>PRICE_CLOSE)
// {
// Cls_Custom_14_By=true;
// }
//
// if(iCustom(NULL,0,"ZigZag",0,0)<PRICE_CLOSE)
// {
// Cls_Custom_14_Sell=true;
// }
//
// }
//You can find the indicator zone simply by "Ctrl+F"+copt there - " Indicators Zone " .
//--------------------------------------------------------------------------------------------------
//-----------------Paramethers---------------------------------------------------------- 1 --------
extern string The_instruction = "...is in code-to comments";
extern string General_Paramethers = "---- General Paramethers ---- ";
extern double StopLoss =0; // StopLoss
extern double TakeProfit =0; // ÒakeÐrofit. May be defined by indicators also.
extern string SleepBars_about = "A pause. 600 seconds...";// I hope, theese are really seconds.
extern bool SleepBars =false;// A pause
extern double Slippage = 2; // Slippage. Open a dictionary.
extern string ID_of_EA__About = "aka MaigcNumber. What if you need 12 advisors at once?";
extern double ID_of_EA = 219249; // No, not that lame indicator "Zigzag", but a fuct. char.
extern string Block_of_Stakes = "---- Stake tuning ----";
extern string Bl_1 = "1 - FixLot, 2 - Martigail, 3 - Percental";
extern string Bl_2 = "Martingail is not a chaser here. Do you need such?"; // I mean, it waits for new deal for covering the problem.
extern string Bl_3 = "IK is a miltiplies for Martingail-taktic";
extern double StakeMode =1; //
extern double Lts1 =0.1; // Fixlot
extern double IK =2; // Multiplying Lts1 * IK (if the previous deal was fail). Normally, Martingail is ThisDealLots = PrevDealLots * 2, so...
extern double Percents =5; //
extern string ATR = "---- ---- ---- ----";
extern string ATR_s_ = "ATR is for setting TP and SL. May be replaced."; // Actually, never tuned by me properly.
extern string _purpose_is_ = "ATR_Multiply sets perception, for ex ample:";
extern string _stop_management = "if Multiply=0.9, then reaction is 0.9 pips per 0.0001 ATR";
extern double ATR_Period =14;
extern double ATR_Multiply = 0.9;
extern double ATR_Reach =0.0014;
extern bool ATR_SL = false;
extern bool ATR_TP = false;
// Do not want more...
extern string Implemented_Indicators = "Implemented plant-from indicators";
extern string Dont_earse = "Each may be found with Ctlr+F command";
extern string WARNING1 = "NOTE: THE PARAMETHERS OF OPEN AND CLOSE ARE SUPPOSED TO";
extern string WARNING2 = "BE DEFINED BY YOUR OWN, IT DEPENDS ON SELECTED STRATEGY.";
extern string WARNING3 = "MAKE SURE THE SELECTED INDICATOR USES YOUR IDEAS PROPERLY!";
extern string The_List_Of = "Anyway, the indicators. Use your math abilities.";
extern string Two_ÌÀs_Cross = "---- ---- ";
extern bool otkr_MA =false;
extern bool zakr_MA =false;
extern double MA1 =4;
extern double MA2 =67;
extern double Shift_ma =1; // I am too lazy to switch
extern double MA_sort_avoidit=0; //0 - Simple, 1 - Expotential, 2 - Smoothed, 3 - Linear Weighed
extern string Stochastic = " A little note here. You may need to change the code at inequalities";
extern bool otkr_Stoh =false;
extern bool zakr_Stoh =false;
extern double per_K=5;
extern double per_D=3;
extern double slow=3;
extern double zoneBUY=20;
extern double zoneSELL=80; //No, I couldn't fix the levels.
extern string Awesome = "But it is all right! B- of math skills must be enough for you.";
extern bool otkr_AO =false;
extern bool zakr_AO =false;
extern string Fractals = "If you had C- math marks, then ask somebody experienced to help you. You will also save your time.";
extern bool otkr_Fractals =false;
extern bool zakr_Fractals =false;
extern string Accelerator = "---- ---- ";
extern bool otkr_AC =false;
extern bool zakr_AC =false;
extern string Demarker = "---- ---- ";
extern bool otkr_Dema =false;
extern bool zakr_Dema =false;
extern double DeMa_period=14;
extern double niz_ur=0.3;
extern double verx_ur=0.7;
extern string CCI = "---- ---- ";
extern bool otkr_CCI =false;
extern bool zakr_CCI =false;
extern double CCI_period=14;
extern double CCI_Level=100; // What, if we want 95?
extern string RSI = "RSI levels are better to be tuned separately. Just for sure.";
extern bool otkr_RSI =false;
extern bool zakr_RSI =false;
extern double RSI_Period =14;
extern double RSI_High=70;
extern double RSI_Low=30;
extern string MACD = "MACD Signal Line";
extern bool otkr_MACD =false;
extern bool zakr_MACD =false;
extern double MACD_Fast=9;
extern double MACD_Slow=26; // MACD uses SIGNAL line
extern double MACD_Signal=14; // because you have 2 MA Cross system
extern string OsMA = "OsMA - like a second MACD S L";
extern bool otkr_OsMA =false;
extern bool zakr_OsMA =false;
extern double OsMA_Fast=9;
extern double OsMA_Slow=26; // SIGNAL line (Well, you can also try Zignal.com as a platform - expenseful lux look is a sort of guaranty. Yes, I've made an ad here - Anon MMMMMMMMMI)
extern double OsMA_Signal=14; // because you have 2 MA Cross system
extern string WPR = "Williams Percent Range";
extern bool otkr_WPR = false;
extern bool zakr_WPR = false;
extern double WPR_Period = 14;
extern double WPR_Shift = 0;
extern string MoneyFlow_aka_MFI = "---";
extern bool otkr_MFI = false;
extern bool zakr_MFI = false;
extern double MFI_Period=14;
extern double MFI_High =70;
extern double MFI_Low =30;
extern string ADX = "ADX Main Line, óðîâíè - 30 è 70";
extern bool otkr_ADX = false;
extern bool zakr_ADX = false;
extern double ADX_Period=14;
extern string SAR = "---";
extern bool otkr_SAR = false;
extern bool zakr_SAR = false;
extern double SAR_Step =0.02;
extern double SAR_MaxStep =0.2;
// And switchers for customs.
extern string Custom_Indicators = "Custom Indicators. ";
extern string Custom_Indicator1 = "Each is already defined.";
extern bool otkr_Custom_1 = false;
extern bool zakr_Custom_1 = false;
extern double example1 = 0; //Example doubles.
extern double example2 = 0;
//extern double Period1 =4; // Sorry, theese ones don't work yet. Also, their implementation makes system not too much slower...
//extern double Shift1 =3;
extern string Custom_Indicator2 = "This one also";
extern bool otkr_Custom_2 = false;
extern bool zakr_Custom_2 = false;
//extern double Period2 =4;
//extern double Shift2 =3;
extern string Custom_Indicator3 = "----";
extern bool otkr_Custom_3 = false;
extern bool zakr_Custom_3 = false;
//extern double Period3 =4;
//extern double Shift3 =3;
extern string Custom_Indicator4 = "Sometimes you need to edit this thing by own,";
extern bool otkr_Custom_4 = false;
extern bool zakr_Custom_4 = false;
//extern double Period4 =4;
//extern double Shift4 =3;
// extern string Custom_Indicator5 = "just for putting new indicators.";
// extern bool otkr_Custom_5 = false;
// extern bool zakr_Custom_5 = false;
// extern double Period5 =4;
// extern double Shift5 =3;
// extern string Custom_Indicator6 = "----";
// extern bool otkr_Custom_6 = false;
// extern double Period6 =4;
// extern double Shift6 =3;
// extern string Custom_Indicator7 = "There are 16 customs and 16 pre-defined indicators.";
// extern bool otkr_Custom_7 = false;
// extern bool zakr_Custom_7 = false;
// extern double Period7 =4;
// extern double Shift7 =3;
// extern string Custom_Indicator8 = "That is why backtest may be slow.";
// extern bool otkr_Custom_8 = false;
// extern bool zakr_Custom_8 = false;
// extern double Period8 =4;
// extern double Shift8 =3;
// extern string Custom_Indicator9 = "----";
// extern bool otkr_Custom_9 = false;
// extern bool zakr_Custom_9 = false;
// extern double Period9 =4;
// extern double Shift9 =3;
// extern string Custom_Indicator10 = "Buy hey. I do not worrying about BACKtests if the strategy is already proven on stat lot.";
// extern bool otkr_Custom_10= false;
// extern bool zakr_Custom_10= false;
// extern double Period10 =4;
// extern double Shift10 =3;
// extern string Custom_Indicator11 = "You know, you just need to stick an idea, nothing more.";
// extern bool otkr_Custom_11= false;
// extern bool zakr_Custom_11= false;
// extern double Period11 =4;
// extern double Shift11 =3;
// extern string Custom_Indicator12 = "---";
// extern bool otkr_Custom_12= false;
// extern bool zakr_Custom_12= false;
// extern double Period12 =4;
// extern double Shift12 =3;
// extern string Custom_Indicator13 = "Well, I have not constant Internet connection. Sorry for low traider level";
// extern bool otkr_Custom_13= false;
// extern bool zakr_Custom_13= false;
// extern double Period13 =4;
// extern double Shift13 =3;
// extern string Custom_Indicator14 = "---";
// extern bool otkr_Custom_14= false;
// extern bool zakr_Custom_14= false;
// extern double Period14 =4;
// extern double Shift14 =3;
// extern string Custom_Indicator15 = "Do NOT rename the doubles and bools";
// extern bool otkr_Custom_15= false;
// extern bool zakr_Custom_15= false;
// extern double Period15 =4;
// extern double Shift15 =3;
// extern string Custom_Indicator16 = "Sometimes you will have to add new doubles.";
// extern bool otkr_Custom_16= false;
// extern bool zakr_Custom_16= false;
// extern double Period16 =4;
// extern double Shift16 =3;
//
bool Work=true;
bool OrderSal;
string Symb; // Pair (ex. EURUSD) Name
//----------------------------------------------------------- 2 -----
int start()
{
//----------
int
Total, // Orders in window.
Tip=-1, // Type of order
Ticket; // Number of order
double
Lot, // Size of selected order
Lts, // Size of opening order
lot,
Min_Lot, // Min. Size
Step, // Min. Step (if modifying)
Free, // Free money on account
One_Lot, // Cost of 1 lot
Price, // Cost of selected order
SL, // SL of selected
TP, // TP of selected
//--
MA_By,MA_Sell,Stoh_By,Stoh_Sell,AO_By,AO_Sell,Fractals_By,Fractals_Sell,AC_By,AC_Sell,Cls_MA_Sell,Cls_MA_By,Cls_Stoh_Sell,Cls_Stoh_By,
Cls_AO_Sell,Cls_AO_By,Cls_Fractals_By,Cls_Fractals_Sell,Cls_AC_Sell,Cls_AC_By,Dema_By,Cls_Dema_Sell,Dema_Sell,Cls_Dema_By,CCI_By,CCI_Sell,Cls_WPR_Sell,Cls_CCI_By,Cls_CCI_Sell,
RSI_By,RSI_Sell,Cls_RSI_Sell,Cls_RSI_By,MFI_By,MFI_Sell,Cls_MFI_Sell,Cls_MFI_By,WPR_By,WPR_Sell,Cls_WRP_Sell,Cls_WPR_By, //äîáàâëåííîå.
MACD_By,MACD_Sell,Cls_MACD_Sell,Cls_MACD_By,OsMA_By,OsMA_Sell,Cls_OsMA_Sell,Cls_OsMA_By,ADX_By,ADX_Sell,Cls_ADX_Sell,Cls_ADX_By,SAR_By,SAR_Sell,Cls_SAR_Sell,Cls_SAR_By,
Custom_1__By, Custom_1__Sell, Cls_Custom_1__By, Cls_Custom_1__Sell,Custom_2__By, Custom_2__Sell, Cls_Custom_2__By, Cls_Custom_2__Sell,Custom_3__By, Custom_3__Sell, Cls_Custom_3__By, Cls_Custom_3__Sell,Custom_4__By, Custom_4__Sell, Cls_Custom_4__By, Cls_Custom_4__Sell;//,
// Custom_5__By, Custom_5__Sell, Cls_Custom_5__By, Cls_Custom_5__Sell,Custom_6__By, Custom_6__Sell, Cls_Custom_6__By, Cls_Custom_6__Sell,Custom_7__By, Custom_7__Sell, Cls_Custom_7__By, Cls_Custom_7__Sell,Custom_8__By, Custom_8__Sell, Cls_Custom_8__By, Cls_Custom_8__Sell,
// Custom_9__By, Custom_9__Sell, Cls_Custom_9__By, Cls_Custom_9__Sell,Custom_10_By, Custom_10_Sell, Cls_Custom_10_By, Cls_Custom_10_Sell,Custom_11_By, Custom_11_Sell, Cls_Custom_11_By, Cls_Custom_11_Sell,Custom_12_By, Custom_12_Sell, Cls_Custom_12_By, Cls_Custom_12_Sell,
// Custom_13_By, Custom_13_Sell, Cls_Custom_13_By, Cls_Custom_13_Sell,Custom_14_By, Custom_14_Sell, Cls_Custom_14_By, Cls_Custom_14_Sell,Custom_15_By, Custom_15_Sell, Cls_Custom_15_By, Cls_Custom_15_Sell,Custom_16_By, Custom_16_Sell, Cls_Custom_16_By, Cls_Custom_16_Sell;
// Theese bools were switched off, because "short" cose is more backtestable*
//Also, I am thinking about using NewsTraiderEA's library here. Or not... Too long to implement, but suddnely, no real trader guy uses "only technical". So i just have to use news.
bool
Modific=true,
Ans =false, // Server's ansver (after modifying or closing)
Cls_B=false, // Buy Close criteria bool
Cls_S=false, // Sell Close criteria bool
Opn_B=false, // Buy Open criteria bool
Opn_S=false, // Sell Open criteria bool
S_Bar=false; // Sleep Bars (aka Pause-600) bool.
// Comment // Decided to switch it off. You can resurrect it... but it's only for "real job", not for a backtest.
//(
// "TIME: ",TimeToStr(TimeCurrent()),
// "\n",
// "Order-s paramethers (##,TP,SL,LOT): |",OrderTicket(),"|",OrderStopLoss(),"|",OrderTakeProfit(),"|",OrderLots(),"|",
// "\n",
// "ID_Number: ", ID_of_EA,
// "\n",
// "StakeType, #:",StakeMode,
// "\n" //,
// "% for #3: ",Percents,
// "\n",
// "StopOut: ", AccountStopoutLevel(),
// "\n",
// "Spread: ", MarketInfo(Symbol(),MODE_SPREAD),
// "\n",
// "Leverage, 1 to: ",AccountLeverage(),
// "\n",
// "Broker", TerminalCompany( ) ,
// "\n",
// "\n",
// "\n", //
// "\n"
// ); // Eats resources very greedy. So, I've switched it off.
// It's probably, most resoure-eating thing for the backtest. I'll freeze it another time, but still...
// Sorry, you can restore it quickly, but still...
//-------------------- Pause after closed order. ------------------ 3 -
int time0 = 0; // Necessary booleans sorting...
for(int t0 = OrdersHistoryTotal();t0>=0;t0--) // Search among closed orders
if(OrderSelect(t0, SELECT_BY_POS,MODE_HISTORY )==true) // A-a-and it we found it...
{
if( iTime(NULL,0,1)-OrderOpenTime() < 600 && SleepBars==true ) //We're pausing. This string has the terms of pause.
{ // // BTW, time is in seconds by standard.
S_Bar=true;
Alert("Gimme a break...");
}
// return(0); // Hey, it's first time I had a bug. Remember - "switched off" by True/False cosesnippet can make it's influence.
}
//----------------------------------------------------------------------
//-------------------- Pre-Work Sorting-------------------------- 4 -
if(Bars<15) // Insufficient quantity of bars
{
Alert("Bars<15, need more bars of history.");
return; // Exit from start()
}
if(Work==false) // Critical error
{
Alert("Critical Error occured.");
return; // Exit from start()
}
//------------------------------------------------------------------------------
//------------------------------Orders counting--------------------------------- 4 --
Symb=Symbol();
Total=0;
for(int i=1; i<=OrdersTotal(); i++)
{
if (OrderSelect(i-1,SELECT_BY_POS)==true)
{
if (OrderSymbol()!=Symb)continue;
if (OrderType()>1)
{
Alert("Unusual order detected. Pause."); // Well, I'll leave it here since first author made it...
return;
}
Total++; //
if (Total>3) // Only one order on one pair. Made for brokers and their trust.
{
Alert("Too much orders. Pause."); // Normally ONE, but I am not against.
return; // exit from start()
}
Ticket=OrderTicket(); //
Tip =OrderType(); // It's info about lots...
Price =OrderOpenPrice(); //
SL =OrderStopLoss(); //
TP =OrderTakeProfit(); //
Lot =OrderLots(); // Lots in the order
}
}
//------------Indicators Zone--------(Here they're switching on)------------ 6 --
//Tune the indicators, huh?
//------------- Pre-Installed indicators
// NOTE: THE PARAMETHERS OF "OPED" AND "CLOSE" ARE SUPPOSED
// TO BE DEFINED BY YOUR OWN, IT DEPENDS ON SELECTED STRATEGY.
// MAKE SURE THE SELECTED INDICATOR OPENS AND CLOSES PROPERLY!
//ATR for TP and SL is here------------------------------
if(ATR_SL==true && iATR(NULL,0,ATR_Period,1)>=ATR_Reach)
StopLoss=iATR(NULL,0,ATR_Period,0)*ATR_Multiply/0.0001; //Yes, not the "price", but the "pips".
if(ATR_TP==true && iATR(NULL,0,ATR_Period,1)>=ATR_Reach)
TakeProfit=iATR(NULL,0,ATR_Period,0)*ATR_Multiply/0.0001;
//MAs------------------------------------
if(otkr_MA==true)
{
if( iMA(NULL,0,MA1,0,MA_sort_avoidit,PRICE_CLOSE,Shift_ma)>iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,Shift_ma))
{
MA_By =true;// Normally SMA, but here is my edit.
}
if(iMA(NULL,0,MA1,0,MA_sort_avoidit,PRICE_CLOSE,Shift_ma)<iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,Shift_ma))
{
MA_Sell =true;
}
}
if(zakr_MA==true)
{
if(iMA(NULL,0,MA1,0,MA_sort_avoidit,PRICE_CLOSE,Shift_ma)>iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,Shift_ma))
{
Cls_MA_Sell=true;
}
if(iMA(NULL,0,MA1,0,MA_sort_avoidit,PRICE_CLOSE,Shift_ma)<iMA(NULL,0,MA2,0,MODE_SMA,PRICE_CLOSE,Shift_ma))
{
Cls_MA_By=true;
}
}
//Ñòîõàñòèê-------------------------------
if(otkr_Stoh==true)
{
if(iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,0,1)>iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)
&& iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)<zoneBUY)
{
Stoh_By =true;
}
if(iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,0,1)<iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)
&& iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)>zoneSELL)
{
Stoh_Sell =true;
}
}
if(zakr_Stoh==true)
{
if(iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,0,1)>iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)
&& iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)<zoneBUY)
{
Cls_Stoh_Sell=true;
}
if(iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,0,1)<iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)
&& iStochastic(NULL,0,per_K,per_D,slow,MODE_LWMA,1,1,1)>zoneSELL)
{
Cls_Stoh_By=true;
}
}
//Awesome--------------------------------
if(otkr_AO==true)
{
if(iAO(NULL,0,0)+iAO(NULL,0,1)>iAO(NULL,0,2)+iAO(NULL,0,3))
{
AO_By =true;
}
if(iAO(NULL,0,0)+iAO(NULL,0,1)<iAO(NULL,0,2)+iAO(NULL,0,3))
{
AO_Sell =true;
}
}
if(zakr_AO==true)
{
if(iAO(NULL,0,0)+iAO(NULL,0,1)>iAO(NULL,0,2)+iAO(NULL,0,3))
{
Cls_AO_Sell=true;
}
if(iAO(NULL,0,0)+iAO(NULL,0,1)<iAO(NULL,0,2)+iAO(NULL,0,3))
{
Cls_AO_By=true;
}
}
//Fractals--------------------------------
if(otkr_Fractals==true)
{
if(iFractals(NULL,0,1,0)<PRICE_CLOSE)
{
Fractals_By =true;
}
if(iFractals(NULL,0,2,0)>PRICE_CLOSE)
{
Fractals_Sell =true;
}
}
if(zakr_Fractals==true)
{
if (iFractals(NULL,0,1,0)<PRICE_CLOSE)
{
Cls_Fractals_Sell=true;
}
if(iFractals(NULL,0,2,0)>PRICE_CLOSE)
{
Cls_Fractals_By=true;
}
}
//Accelerator---------------------------
if(otkr_AC==true)
{
if (iAC(NULL,0,0)>=0 && iAC(NULL,0,0)>iAC(NULL,0,1) && iAC(NULL,0,1)>iAC(NULL,0,2) || iAC(NULL,0,0)<=0 && iAC(NULL,0,0)>iAC(NULL,0,1) && iAC(NULL,0,1)>iAC(NULL,0,2) && iAC(NULL,0,2)>iAC(NULL,0,3))
{
AC_By =true;
}
if (iAC(NULL,0,0)<=0 && iAC(NULL,0,0)<iAC(NULL,0,1) && iAC(NULL,0,1)<iAC(NULL,0,2) || iAC(NULL,0,0)>=0 && iAC(NULL,0,0)<iAC(NULL,0,1) && iAC(NULL,0,1)<iAC(NULL,0,2) && iAC(NULL,0,2)<iAC(NULL,0,3))
{
AC_Sell =true;
}
}
// Seletsky's AC. I don't know, why he detailed it...
if(zakr_AC==true)
{
if (iAC(NULL,0,0)>=0 && iAC(NULL,0,0)>iAC(NULL,0,1) && iAC(NULL,0,1)>iAC(NULL,0,2) || iAC(NULL,0,0)<=0 && iAC(NULL,0,0)>iAC(NULL,0,1) && iAC(NULL,0,1)>iAC(NULL,0,2) && iAC(NULL,0,2)>iAC(NULL,0,3))
{
Cls_AC_Sell=true;
}
if (iAC(NULL,0,0)<=0 && iAC(NULL,0,0)<iAC(NULL,0,1) && iAC(NULL,0,1)<iAC(NULL,0,2) || iAC(NULL,0,0)>=0 && iAC(NULL,0,0)<iAC(NULL,0,1) && iAC(NULL,0,1)<iAC(NULL,0,2) && iAC(NULL,0,2)<iAC(NULL,0,3))
{
Cls_AC_By=true;
}
}
//Demarker----------------------------
if(otkr_Dema==true)
{
if (iDeMarker(NULL, 0, DeMa_period, 1)<niz_ur)
{
Dema_By =true;
}
if (iDeMarker(NULL, 0, DeMa_period, 1)>verx_ur)
{
Dema_Sell =true;
}
}
if(zakr_Dema==true)
{
if (iDeMarker(NULL, 0, DeMa_period, 1)<niz_ur)
{
Cls_Dema_Sell=true;
}
if (iDeMarker(NULL, 0, DeMa_period, 1)>verx_ur)
{
Cls_Dema_By=true;
}
}
//CCI:------------------that's how I've made a hook method here
if(otkr_CCI==true)
{
if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN,0)>iCCI(NULL, 0, CCI_period,PRICE_MEDIAN,1) && iCCI(NULL, 0, CCI_period,PRICE_MEDIAN,1)<iCCI(NULL, 0, CCI_period,PRICE_MEDIAN,2)) // À òóò êàê äèâåðãåíöèþ ëîâèòü?
{
CCI_By =true;
}
if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN,0)<iCCI(NULL, 0, CCI_period,PRICE_MEDIAN,1) && iCCI(NULL, 0, CCI_period,PRICE_MEDIAN,1)>iCCI(NULL, 0, CCI_period,PRICE_MEDIAN,2))
{
CCI_Sell =true;
}
}
if(zakr_CCI==true)
{
if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN, 1)<-CCI_Level) // Òîæå ïî êðþêó.
{
Cls_CCI_Sell=true;
}
if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN, 1)>CCI_Level) // CCI èñïîëüçóåòñÿ êàê îñöèëëÿòîð ïåðåêóï.\ïåðåïðîä. Êàê Ñòîõàñòèê.
{
Cls_CCI_By=true;
}
}
//Heh-heh, the example is here, but it's (coolface.jpg) disabled!1one
// //CCI:-------------------------------
// if(otkr_CCI==true)
// {
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN, 1)<-100)
// {
// CCI_By =true;
// }
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN,1)>100)
// {
// CCI_Sell =true;
// }
// }
//
// if(zakr_CCI==true)
// {
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN, 1)<-100)
// {
// Cls_CCI_Sell=true;
// }
// if (iCCI(NULL, 0,CCI_period,PRICE_MEDIAN,1)>100)
// {
// Cls_CCI_By=true;
// }
// }
//
//
//RSI---------------------------------------------------------------------
if(otkr_RSI==true)
{
if (iRSI(NULL,0,RSI_Period,1,0)>RSI_High)
{
RSI_By=true;
}
if (iRSI(NULL,0,RSI_Period,1,0)<RSI_Low)
{
RSI_Sell=true;
}
}
if(zakr_RSI==true)
{
if (iRSI(NULL,0,RSI_Period,1,0)>RSI_High)
{
Cls_RSI_Sell=true;
}
if (iRSI(NULL,0,RSI_Period,1,0)<RSI_Low)
{
Cls_RSI_By=true;
}
}
//MFI-------------------------------
if(otkr_MFI==true)
{
if (iMFI(NULL,0,MFI_Period,0)>MFI_High)
{
MFI_By=true;
}
if (iMFI(NULL,0,MFI_Period,0)<MFI_Low)
{
MFI_Sell=true;
}
}
if(zakr_MFI==true)
{
if (iMFI(NULL,0,MFI_Period,0)>MFI_High/2+MFI_Low/2)
{
Cls_MFI_Sell=true;
}
if (iMFI(NULL,0,MFI_Period,0)<MFI_High/2+MFI_Low/2)
{
Cls_MFI_By=true;
}
}
//WPR--------------------------------
if(otkr_WPR==true)
{
if (iWPR(NULL,0,WPR_Period,WPR_Shift)>-20)
{
WPR_By=true;
}
if (iWPR(NULL,0,WPR_Period,0)<-80)
{
WPR_Sell=true;
}
}
if(zakr_WPR==true)
{
if (iWPR(NULL,0,WPR_Period,0)>-20)
{
Cls_WPR_Sell=true;
}
if (iWPR(NULL,0,WPR_Period,0)<-80)
{
Cls_WPR_By=true;
}
}
//MACD-------------------------------
if(otkr_MACD==true)
{
if (iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,0)>iMACD(NULL,0,9,26,14,1,1,1))
{
MACD_By=true;
}
if (iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,0)<iMACD(NULL,0,9,26,14,1,1,1))
{
MACD_Sell=true;
}
}
if(zakr_MACD==true)
{
if (iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,0)>iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,1))
{
Cls_MACD_Sell=true;
}
if (iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,0)<iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,1))
{
Cls_MACD_By=true;
}
}
//OsMA-------------------------------
if(otkr_OsMA==true)
{
if (iOsMA(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,0)>iMACD(NULL,0,9,26,14,1,1,1))
{
MACD_By=true;
}
if (iOsMA(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,0)<iMACD(NULL,0,9,26,14,1,1,1))
{
MACD_Sell=true;
}
}
if(zakr_OsMA==true)
{
if (iOsMA(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,0)>iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,1))
{
Cls_MACD_Sell=true;
}
if (iOsMA(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,0)<iMACD(NULL,0,MACD_Fast,MACD_Slow,MACD_Signal,1,1,1))
{
Cls_MACD_By=true;
}
}
//ADX-------------------------------
if(otkr_ADX==true)
{
if (iADX(NULL,0,ADX_Period,1,0,0)>70)
{
ADX_By=true;
}
if (iADX(NULL,0,ADX_Period,1,0,0)<30)
{
ADX_Sell=true;
}
}
if(zakr_ADX==true)
{
if (iADX(NULL,0,ADX_Period,1,0,0)>70)
{
Cls_ADX_Sell=true;
}
if (iADX(NULL,0,ADX_Period,1,0,0)<30)
{
Cls_ADX_By=true;
}
}
//SAR-------------------------------
if(otkr_SAR==true)
{
if(iSAR(NULL,0,SAR_Step,SAR_MaxStep,0)>Close[0])
{
SAR_By=true;
}
if(iSAR(NULL,0,SAR_Step,SAR_MaxStep,0)<Close[0])
{
SAR_Sell=true;
}
}
if(zakr_SAR==true)
{
if (iSAR(NULL,0,SAR_Step,SAR_MaxStep,0)>Close[0])
{
Cls_SAR_Sell=true;
}
if(iSAR(NULL,0,SAR_Step,SAR_MaxStep,0)<Close[0])
{
Cls_SAR_By=true;
}
}
// A-a-a-nd the custom indicators. I bet you were searching for some newbie-for possibility to use custom indicators.
//--------Custom_1__------------------
if(otkr_Custom_1==true)
{
if(iCustom(NULL,0,"StochasticStack",0,0)>PRICE_CLOSE) // You know, you're supposed to tune the custom indicator by yourself.
{ // I mean, all the tunes are saved in code (as basiccal\standard)
Custom_1__By=true; // As a rule, the custom inds don't need any tunes... mostly...
} // Well, if any problems, you just need to edit an indicator simply by changing the digits "in case".
//"Theese \/ ones" // Snippet: between name ("ZZ") and last two (,0,0)) digits you can put variables
if(iCustom(NULL,0,"StochasticStack",example1,example2,0,0)<PRICE_CLOSE)// Lamest ever :)
{
Custom_1__Sell=true;
}
}
if(zakr_Custom_1==true)
{
if(iCustom(NULL,0,"StochasticStack",0,0)>PRICE_CLOSE)
{
Cls_Custom_1__By=true;// _1__ , because there are up to 16 custom inds aviliable - you can find _10_, _16_, _9__...
}
if(iCustom(NULL,0,"StochasticStack",0,0)<PRICE_CLOSE)
{
Cls_Custom_1__Sell=true;
}
}
//--------Custom_2__------------------
if(otkr_Custom_2==true)
{
if(iCustom(NULL,0,"Parabolic_ZZ",0,0)>PRICE_CLOSE) // Just don't use my "filler".
{ // It won't work anyway.
Custom_2__By=true;
}
if(iCustom(NULL,0,"Parabolic_ZZ",0,0)<PRICE_CLOSE)
{
Custom_2__Sell=true;
}
}
if(zakr_Custom_2==true)
{
if(iCustom(NULL,0,"Parabolic_ZZ",0,0)>PRICE_CLOSE) // Lamest ever :)
{
Cls_Custom_2__By=true;
}
if(iCustom(NULL,0,"Parabolic_ZZ",0,0)<PRICE_CLOSE)
{
Cls_Custom_2__Sell=true;
}
}
//--------Custom_3__------------------
if(otkr_Custom_3==true)
{
if(iCustom(NULL,0,"ZigZag",0,0)>PRICE_CLOSE)
{
Custom_3__By=true;
}
if(iCustom(NULL,0,"ZigZag",0,0)<PRICE_CLOSE)
{
Custom_3__Sell=true;
}
}
if(zakr_Custom_3==true)
{
if(iCustom(NULL,0,"ZigZag",0,0)>PRICE_CLOSE)
{
Cls_Custom_3__By=true;
}
if(iCustom(NULL,0,"ZigZag",0,0)<PRICE_CLOSE)
{
Cls_Custom_3__Sell=true;
}
}