MetaTrader 4 MT4 Expert Advisors Simplest Hedging EA ever – EA MetaTrader 4

Simplest Hedging EA ever – EA MetaTrader 4

This EA comprises only 20 lines of code, and does all its trading in two lines! if there is a simpler EA out there I would love to see it!

The EA doesn’t use any indicators. Instead, it simply and blindly opens two opposing positions at the beginning of the first new bar it comes across. It waits until both positions have closed by hitting their stop-losses or take-profit levels, and then opens the next pair of positions.

After optimisation manually select the best result where the stop-loss is lower than take-profit level, in which case each pair of trades will have one of the following outcomes.

  • Both positions win (hurrah!)
  • One wins and one loses (in which case the winner covers the losses of the loser)
  • Both lose (oh no!)

It is OK to optimise the EA using “Open prices only”, because it only trades at the opening of a new bar.

In my experiments, EURGBP 5M provides the best results, although positive results are also available from EURUSD, GBPUSD, EURCHF and probably others.

Please feel free to improve the code to your heart’s content!




Symbol EURGBP (Euro vs Great Britain Pound )
Period 5 Minutes (M5) 2009.10.01 00:00 – 2010.01.31 23:55 (2009.10.01 – 2010.02.01)
Model Every tick (the most precise method based on all available least timeframes)
Parameters lots=1; stop_loss=76; take_profit=750;

Bars in test 25154 Ticks modelled 3758809 Modelling quality 90.00%
Mismatched charts errors 0




Initial deposit 10000.00



Total net profit 7842.50 Gross profit 27413.50 Gross loss -19571.00
Profit factor 1.40 Expected payoff 76.89

Absolute drawdown 792.50 Maximal drawdown 3539.00 (23.17%) Relative drawdown 23.17% (3539.00)

Total trades 102 Short positions (won %) 51 (56.86%) Long positions (won %) 51 (19.61%)

Profit trades (% of total) 39 (38.24%) Loss trades (% of total) 63 (61.76%)
Largest profit trade 727.00 loss trade -750.00
Average profit trade 702.91 loss trade -310.65
Maximum consecutive wins (profit in money) 1 (727.00) consecutive losses (loss in money) 7 (-2543.50)
Maximal consecutive profit (count of wins) 727.00 (1) consecutive loss (count of losses) -2543.50 (7)
Average consecutive wins 1 consecutive losses 2

# Time Type Order Size Price S / L T / P Profit Balance
1 2009.10.01 00:00 buy 1 1.00 0.91598 0.91522 0.92317
2 2009.10.01 00:00 sell 2 1.00 0.91567 0.92317 0.90848
3 2009.10.01 05:46 s/l 1 1.00 0.91522 0.91522 0.92317 -76.00 9924.00
4 2009.10.01 14:35 t/p 2 1.00 0.90848 0.92317 0.90848 719.00 10643.00
5 2009.10.01 14:40 buy 3 1.00 0.90956 0.90880 0.91675
6 2009.10.01 14:40 sell 4 1.00 0.90925 0.91675 0.90206
7 2009.10.02 10:38 s/l 4 1.00 0.91675 0.91675 0.90206 -749.00 9894.00
8 2009.10.02 10:38 t/p 3 1.00 0.91675 0.90880 0.91675 717.50 10611.50
9 2009.10.02 10:40 buy 5 1.00 0.91717 0.91641 0.92436
10 2009.10.02 10:40 sell 6 1.00 0.91686 0.92436 0.90967
11 2009.10.02 11:10 s/l 5 1.00 0.91641 0.91641 0.92436 -76.00 10535.50
12 2009.10.06 09:22 s/l 6 1.00 0.92436 0.92436 0.90967 -748.00 9787.50
13 2009.10.06 09:25 buy 7 1.00 0.92455 0.92379 0.93174
14 2009.10.06 09:25 sell 8 1.00 0.92424 0.93174 0.91705
15 2009.10.06 09:31 s/l 7 1.00 0.92379 0.92379 0.93174 -76.00 9711.50
16 2009.10.08 13:30 t/p 8 1.00 0.91705 0.93174 0.91705 723.00 10434.50
17 2009.10.08 13:35 buy 9 1.00 0.91703 0.91627 0.92422
18 2009.10.08 13:35 sell 10 1.00 0.91672 0.92422 0.90953
19 2009.10.09 09:30 s/l 10 1.00 0.92422 0.92422 0.90953 -749.00 9685.50
20 2009.10.09 09:41 t/p 9 1.00 0.92422 0.91627 0.92422 717.50 10403.00
21 2009.10.09 09:45 buy 11 1.00 0.92443 0.92367 0.93162
22 2009.10.09 09:45 sell 12 1.00 0.92412 0.93162 0.91693
23 2009.10.09 09:48 s/l 11 1.00 0.92367 0.92367 0.93162 -76.00 10327.00
24 2009.10.12 07:12 s/l 12 1.00 0.93162 0.93162 0.91693 -749.00 9578.00
25 2009.10.12 07:15 buy 13 1.00 0.93174 0.93098 0.93893
26 2009.10.12 07:15 sell 14 1.00 0.93143 0.93893 0.92424
27 2009.10.13 06:35 s/l 14 1.00 0.93893 0.93893 0.92424 -749.00 8829.00
28 2009.10.13 08:25 t/p 13 1.00 0.93893 0.93098 0.93893 717.50 9546.50
29 2009.10.13 08:30 buy 15 1.00 0.93908 0.93832 0.94627
30 2009.10.13 08:30 sell 16 1.00 0.93877 0.94627 0.93158
31 2009.10.13 09:39 s/l 15 1.00 0.93832 0.93832 0.94627 -76.00 9470.50
32 2009.10.14 06:21 t/p 16 1.00 0.93158 0.94627 0.93158 720.00 10190.50
33 2009.10.14 06:25 buy 17 1.00 0.93186 0.93110 0.93905
34 2009.10.14 06:25 sell 18 1.00 0.93155 0.93905 0.92436
35 2009.10.14 08:32 s/l 17 1.00 0.93110 0.93110 0.93905 -76.00 10114.50
36 2009.10.15 07:55 t/p 18 1.00 0.92436 0.93905 0.92436 722.00 10836.50
37 2009.10.15 08:00 buy 19 1.00 0.92423 0.92347 0.93142
38 2009.10.15 08:00 sell 20 1.00 0.92392 0.93142 0.91673
39 2009.10.15 08:04 s/l 19 1.00 0.92347 0.92347 0.93142 -76.00 10760.50
40 2009.10.15 11:05 t/p 20 1.00 0.91673 0.93142 0.91673 719.00 11479.50
41 2009.10.15 11:10 buy 21 1.00 0.91579 0.91503 0.92298
42 2009.10.15 11:10 sell 22 1.00 0.91548 0.92298 0.90829
43 2009.10.15 11:38 s/l 21 1.00 0.91503 0.91503 0.92298 -76.00 11403.50
44 2009.10.20 14:04 t/p 22 1.00 0.90829 0.92298 0.90829 722.00 12125.50
45 2009.10.20 14:05 buy 23 1.00 0.90799 0.90723 0.91518
46 2009.10.20 14:05 sell 24 1.00 0.90768 0.91518 0.90049
47 2009.10.20 14:06 s/l 23 1.00 0.90723 0.90723 0.91518 -76.00 12049.50
48 2009.10.21 11:43 t/p 24 1.00 0.90049 0.91518 0.90049 720.00 12769.50
49 2009.10.21 11:45 buy 25 1.00 0.90029 0.89953 0.90748
50 2009.10.21 11:45 sell 26 1.00 0.89998 0.90748 0.89279
51 2009.10.23 09:30 s/l 26 1.00 0.90748 0.90748 0.89279 -746.00 12023.50
52 2009.10.23 09:30 t/p 25 1.00 0.90748 0.89953 0.90748 713.00 12736.50
53 2009.10.23 09:35 buy 27 1.00 0.91004 0.90928 0.91723
54 2009.10.23 09:35 sell 28 1.00 0.90973 0.91723 0.90254
55 2009.10.23 10:38 s/l 28 1.00 0.91723 0.91723 0.90254 -750.00 11986.50
56 2009.10.23 10:39 t/p 27 1.00 0.91723 0.90928 0.91723 719.00 12705.50
57 2009.10.23 10:40 buy 29 1.00 0.91778 0.91702 0.92497
58 2009.10.23 10:40 sell 30 1.00 0.91747 0.92497 0.91028
59 2009.10.23 10:41 s/l 29 1.00 0.91702 0.91702 0.92497 -76.00 12629.50
60 2009.10.26 17:43 t/p 30 1.00 0.91028 0.92497 0.91028 720.00 13349.50
61 2009.10.26 17:45 buy 31 1.00 0.91028 0.90952 0.91747
62 2009.10.26 17:45 sell 32 1.00 0.90997 0.91747 0.90278
63 2009.10.26 17:47 s/l 31 1.00 0.90952 0.90952 0.91747 -76.00 13273.50
64 2009.10.28 13:51 t/p 32 1.00 0.90278 0.91747 0.90278 721.00 13994.50
65 2009.10.28 13:55 buy 33 1.00 0.90266 0.90190 0.90985
66 2009.10.28 13:55 sell 34 1.00 0.90235 0.90985 0.89516
67 2009.10.28 14:49 s/l 33 1.00 0.90190 0.90190 0.90985 -76.00 13918.50
68 2009.10.29 11:37 t/p 34 1.00 0.89516 0.90985 0.89516 722.00 14640.50
69 2009.10.29 11:40 buy 35 1.00 0.89459 0.89383 0.90178
70 2009.10.29 11:40 sell 36 1.00 0.89428 0.90178 0.88709
71 2009.10.29 11:42 s/l 35 1.00 0.89383 0.89383 0.90178 -76.00 14564.50
72 2009.11.02 08:08 s/l 36 1.00 0.90178 0.90178 0.88709 -748.00 13816.50
73 2009.11.02 08:10 buy 37 1.00 0.90189 0.90113 0.90908
74 2009.11.02 08:10 sell 38 1.00 0.90158 0.90908 0.89439
75 2009.11.02 08:21 s/l 37 1.00 0.90113 0.90113 0.90908 -76.00 13740.50
76 2009.11.03 15:33 t/p 38 1.00 0.89439 0.90908 0.89439 720.00 14460.50
77 2009.11.03 15:35 buy 39 1.00 0.89488 0.89412 0.90207
78 2009.11.03 15:35 sell 40 1.00 0.89457 0.90207 0.88738
79 2009.11.03 16:27 s/l 39 1.00 0.89412 0.89412 0.90207 -76.00 14384.50
80 2009.11.11 10:40 s/l 40 1.00 0.90207 0.90207 0.88738 -742.00 13642.50
81 2009.11.11 10:45 buy 41 1.00 0.90271 0.90195 0.90990
82 2009.11.11 10:45 sell 42 1.00 0.90240 0.90990 0.89521
83 2009.11.11 10:46 s/l 41 1.00 0.90195 0.90195 0.90990 -76.00 13566.50
84 2009.11.12 20:35 t/p 42 1.00 0.89521 0.90990 0.89521 722.00 14288.50
85 2009.11.12 20:40 buy 43 1.00 0.89521 0.89445 0.90240
86 2009.11.12 20:40 sell 44 1.00 0.89490 0.90240 0.88771
87 2009.11.12 21:23 s/l 43 1.00 0.89445 0.89445 0.90240 -76.00 14212.50
88 2009.11.16 17:23 t/p 44 1.00 0.88771 0.90240 0.88771 721.00 14933.50
89 2009.11.16 17:25 buy 45 1.00 0.88814 0.88738 0.89533
90 2009.11.16 17:25 sell 46 1.00 0.88783 0.89533 0.88064
91 2009.11.17 07:42 s/l 45 1.00 0.88738 0.88738 0.89533 -77.50 14856.00
92 2009.11.19 14:20 s/l 46 1.00 0.89533 0.89533 0.88064 -745.00 14111.00
93 2009.11.19 14:25 buy 47 1.00 0.89519 0.89443 0.90238
94 2009.11.19 14:25 sell 48 1.00 0.89488 0.90238 0.88769
95 2009.11.19 14:35 s/l 47 1.00 0.89443 0.89443 0.90238 -76.00 14035.00
96 2009.11.23 01:16 s/l 48 1.00 0.90238 0.90238 0.88769 -748.00 13287.00
97 2009.11.23 01:20 buy 49 1.00 0.90224 0.90148 0.90943
98 2009.11.23 01:20 sell 50 1.00 0.90193 0.90943 0.89474
99 2009.11.23 01:33 s/l 49 1.00 0.90148 0.90148 0.90943 -76.00 13211.00
100 2009.11.26 07:37 s/l 50 1.00 0.90943 0.90943 0.89474 -745.00 12466.00
101 2009.11.26 07:40 buy 51 1.00 0.90938 0.90862 0.91657
102 2009.11.26 07:40 sell 52 1.00 0.90907 0.91657 0.90188
103 2009.11.26 07:42 s/l 51 1.00 0.90862 0.90862 0.91657 -76.00 12390.00
104 2009.12.04 14:00 t/p 52 1.00 0.90188 0.91657 0.90188 727.00 13117.00
105 2009.12.04 14:05 buy 53 1.00 0.90186 0.90110 0.90905
106 2009.12.04 14:05 sell 54 1.00 0.90155 0.90905 0.89436
107 2009.12.04 14:17 s/l 53 1.00 0.90110 0.90110 0.90905 -76.00 13041.00
108 2009.12.08 10:00 s/l 54 1.00 0.90905 0.90905 0.89436 -748.00 12293.00
109 2009.12.08 10:05 buy 55 1.00 0.90896 0.90820 0.91615
110 2009.12.08 10:05 sell 56 1.00 0.90865 0.91615 0.90146
111 2009.12.08 10:35 s/l 55 1.00 0.90820 0.90820 0.91615 -76.00 12217.00
112 2009.12.09 13:03 t/p 56 1.00 0.90146 0.91615 0.90146 720.00 12937.00
113 2009.12.09 13:05 buy 57 1.00 0.90099 0.90023 0.90818
114 2009.12.09 13:05 sell 58 1.00 0.90068 0.90818 0.89349
115 2009.12.09 14:57 s/l 58 1.00 0.90818 0.90818 0.89349 -750.00 12187.00
116 2009.12.09 15:05 t/p 57 1.00 0.90818 0.90023 0.90818 719.00 12906.00
117 2009.12.09 15:10 buy 59 1.00 0.90822 0.90746 0.91541
118 2009.12.09 15:10 sell 60 1.00 0.90791 0.91541 0.90072
119 2009.12.09 16:39 s/l 59 1.00 0.90746 0.90746 0.91541 -76.00 12830.00
120 2009.12.11 15:19 t/p 60 1.00 0.90072 0.91541 0.90072 723.00 13553.00
121 2009.12.11 15:20 buy 61 1.00 0.90067 0.89991 0.90786
122 2009.12.11 15:20 sell 62 1.00 0.90036 0.90786 0.89317
123 2009.12.11 16:09 s/l 61 1.00 0.89991 0.89991 0.90786 -76.00 13477.00
124 2009.12.15 20:54 t/p 62 1.00 0.89317 0.90786 0.89317 721.00 14198.00
125 2009.12.15 20:55 buy 63 1.00 0.89321 0.89245 0.90040
126 2009.12.15 20:55 sell 64 1.00 0.89290 0.90040 0.88571
127 2009.12.16 10:02 s/l 63 1.00 0.89245 0.89245 0.90040 -77.50 14120.50
128 2009.12.17 04:32 t/p 64 1.00 0.88571 0.90040 0.88571 723.00 14843.50
129 2009.12.17 04:35 buy 65 1.00 0.88570 0.88494 0.89289
130 2009.12.17 04:35 sell 66 1.00 0.88539 0.89289 0.87820
131 2009.12.21 12:45 s/l 66 1.00 0.89289 0.89289 0.87820 -748.00 14095.50
132 2009.12.22 10:00 t/p 65 1.00 0.89289 0.88494 0.89289 714.50 14810.00
133 2009.12.22 10:05 buy 67 1.00 0.89387 0.89311 0.90106
134 2009.12.22 10:05 sell 68 1.00 0.89356 0.90106 0.88637
135 2009.12.22 11:12 s/l 67 1.00 0.89311 0.89311 0.90106 -76.00 14734.00
136 2009.12.24 10:30 s/l 68 1.00 0.90106 0.90106 0.88637 -746.00 13988.00
137 2009.12.24 10:35 buy 69 1.00 0.90060 0.89984 0.90779
138 2009.12.24 10:35 sell 70 1.00 0.90029 0.90779 0.89310
139 2009.12.24 10:44 s/l 69 1.00 0.89984 0.89984 0.90779 -76.00 13912.00
140 2009.12.30 15:53 t/p 70 1.00 0.89310 0.90779 0.89310 723.00 14635.00
141 2009.12.30 15:55 buy 71 1.00 0.89346 0.89270 0.90065
142 2009.12.30 15:55 sell 72 1.00 0.89315 0.90065 0.88596
143 2009.12.30 16:15 s/l 71 1.00 0.89270 0.89270 0.90065 -76.00 14559.00
144 2009.12.31 17:15 t/p 72 1.00 0.88596 0.90065 0.88596 722.00 15281.00
145 2009.12.31 17:20 buy 73 1.00 0.88625 0.88549 0.89344
146 2009.12.31 17:20 sell 74 1.00 0.88594 0.89344 0.87875
147 2010.01.04 15:27 s/l 74 1.00 0.89344 0.89344 0.87875 -748.00 14533.00
148 2010.01.04 15:33 t/p 73 1.00 0.89344 0.88549 0.89344 716.00 15249.00
149 2010.01.04 15:35 buy 75 1.00 0.89397 0.89321 0.90116
150 2010.01.04 15:35 sell 76 1.00 0.89366 0.90116 0.88647
151 2010.01.05 10:40 s/l 76 1.00 0.90116 0.90116 0.88647 -749.00 14500.00
152 2010.01.05 10:51 t/p 75 1.00 0.90116 0.89321 0.90116 717.50 15217.50
153 2010.01.05 10:55 buy 77 1.00 0.90101 0.90025 0.90820
154 2010.01.05 10:55 sell 78 1.00 0.90070 0.90820 0.89351
155 2010.01.05 11:27 s/l 77 1.00 0.90025 0.90025 0.90820 -76.00 15141.50
156 2010.01.06 08:28 t/p 78 1.00 0.89351 0.90820 0.89351 720.00 15861.50
157 2010.01.06 08:30 buy 79 1.00 0.89346 0.89270 0.90065
158 2010.01.06 08:30 sell 80 1.00 0.89315 0.90065 0.88596
159 2010.01.06 08:30 s/l 79 1.00 0.89270 0.89270 0.90065 -76.00 15785.50
160 2010.01.06 15:01 s/l 80 1.00 0.90065 0.90065 0.88596 -750.00 15035.50
161 2010.01.06 15:05 buy 81 1.00 0.90012 0.89936 0.90731
162 2010.01.06 15:05 sell 82 1.00 0.89981 0.90731 0.89262
163 2010.01.06 15:30 s/l 81 1.00 0.89936 0.89936 0.90731 -76.00 14959.50
164 2010.01.08 11:06 t/p 82 1.00 0.89262 0.90731 0.89262 723.00 15682.50
165 2010.01.08 11:10 buy 83 1.00 0.89280 0.89204 0.89999
166 2010.01.08 11:10 sell 84 1.00 0.89249 0.89999 0.88530
167 2010.01.08 18:13 s/l 84 1.00 0.89999 0.89999 0.88530 -750.00 14932.50
168 2010.01.08 18:15 t/p 83 1.00 0.89999 0.89204 0.89999 719.00 15651.50
169 2010.01.08 18:20 buy 85 1.00 0.90039 0.89963 0.90758
170 2010.01.08 18:20 sell 86 1.00 0.90008 0.90758 0.89289
171 2010.01.08 18:23 s/l 85 1.00 0.89963 0.89963 0.90758 -76.00 15575.50
172 2010.01.13 08:18 t/p 86 1.00 0.89289 0.90758 0.89289 722.00 16297.50
173 2010.01.13 08:20 buy 87 1.00 0.89292 0.89216 0.90011
174 2010.01.13 08:20 sell 88 1.00 0.89261 0.90011 0.88542
175 2010.01.13 09:32 s/l 87 1.00 0.89216 0.89216 0.90011 -76.00 16221.50
176 2010.01.15 02:20 t/p 88 1.00 0.88542 0.90011 0.88542 723.00 16944.50
177 2010.01.15 02:25 buy 89 1.00 0.88443 0.88367 0.89162
178 2010.01.15 02:25 sell 90 1.00 0.88412 0.89162 0.87693
179 2010.01.15 02:25 s/l 89 1.00 0.88367 0.88367 0.89162 -76.00 16868.50
180 2010.01.19 02:22 t/p 90 1.00 0.87693 0.89162 0.87693 721.00 17589.50
181 2010.01.19 02:25 buy 91 1.00 0.87710 0.87634 0.88429
182 2010.01.19 02:25 sell 92 1.00 0.87679 0.88429 0.86960
183 2010.01.19 07:01 s/l 91 1.00 0.87634 0.87634 0.88429 -76.00 17513.50
184 2010.01.20 11:56 t/p 92 1.00 0.86960 0.88429 0.86960 720.00 18233.50
185 2010.01.20 12:00 buy 93 1.00 0.86950 0.86874 0.87669
186 2010.01.20 12:00 sell 94 1.00 0.86919 0.87669 0.86200
187 2010.01.20 12:04 s/l 93 1.00 0.86874 0.86874 0.87669 -76.00 18157.50
188 2010.01.22 12:31 s/l 94 1.00 0.87669 0.87669 0.86200 -746.00 17411.50
189 2010.01.22 12:35 buy 95 1.00 0.87708 0.87632 0.88427
190 2010.01.22 12:35 sell 96 1.00 0.87677 0.88427 0.86958
191 2010.01.22 12:36 s/l 95 1.00 0.87632 0.87632 0.88427 -76.00 17335.50
192 2010.01.26 04:53 t/p 96 1.00 0.86958 0.88427 0.86958 721.00 18056.50
193 2010.01.26 04:55 buy 97 1.00 0.86959 0.86883 0.87678
194 2010.01.26 04:55 sell 98 1.00 0.86928 0.87678 0.86209
195 2010.01.26 05:16 s/l 97 1.00 0.86883 0.86883 0.87678 -76.00 17980.50
196 2010.01.28 10:24 t/p 98 1.00 0.86209 0.87678 0.86209 723.00 18703.50
197 2010.01.28 10:25 buy 99 1.00 0.86225 0.86149 0.86944
198 2010.01.28 10:25 sell 100 1.00 0.86194 0.86944 0.85475
199 2010.01.28 11:24 s/l 99 1.00 0.86149 0.86149 0.86944 -76.00 18627.50
200 2010.01.31 22:09 s/l 100 1.00 0.86944 0.86944 0.85475 -749.00 17878.50
201 2010.01.31 22:09 buy 101 1.00 0.86953 0.86877 0.87672
202 2010.01.31 22:09 sell 102 1.00 0.86922 0.87672 0.86203
203 2010.01.31 22:44 s/l 101 1.00 0.86877 0.86877 0.87672 -76.00 17802.50
204 2010.01.31 23:59 close at stop 102 1.00 0.86882 0.87672 0.86203 40.00 17842.50
Alternative:   Chande_Kroll_Stop_v1_HTF - indicator MetaTrader 5
📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks