-
Notifications
You must be signed in to change notification settings - Fork 4
/
PipfiniteBreakoutEA.mq4
469 lines (464 loc) · 20.2 KB
/
PipfiniteBreakoutEA.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
//+------------------------------------------------------------------+
//| PipFinite_Based_EA 2.mq4 |
//| Copyright 2015, Master Forex |
//| https://www.mql5.com/ru/users/Master_Forex/portfolio |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Master Forex"
#property link "https://www.mql5.com/ru/users/Master_Forex/portfolio"
#property version "2.00"
#property strict
enum RiskCalc {
AA = 1//AccountBalance
, BB = 2//AccountEquity
, CC = 3//AccountFreeMargin
};
input string NameEA = "PipFinite Breakout EA";//EA Comment
input string Indicators_Parameters_ = "______________________________________________________";//Indicators Settings _______________________________________________
input string _ = "<<<<<<<<<<<<<<<<<<<<<->>>>>>>>>>>>>>>>>>>>>";//PipFinite Breakout Analyzer
input int Periods = 4; //Period
input string ___________ = "<<<<<<<<<<<<<<<<<<<<<->>>>>>>>>>>>>>>>>>>>>";//PipFinite Strength Meter
input int SMPeriod = 7; //Period
input int ThresholdLevel = 2; //Threshold Level
input string ______ = "<<<<<<<<<<<<<<<<<<<<<->>>>>>>>>>>>>>>>>>>>>";//PipFinite Exit Scope
input int bb = 1; //Volume Factor
input string ________ = "<<<<<<<<<<<<<<<<<<<<<->>>>>>>>>>>>>>>>>>>>>";//Indicator ATR
input int ATRPeriod = 14; //ATR Period
input double ATRMulti = 1.25; //ATR Multiplier
input double ATROffset = 0; //ATR Offset
input string Trade_Parameters_ = "______________________________________________________";//Trade Parameters _______________________________________________
input double StopLoss = 0; //Stop Loss
input double TakeProfit = 100; //Take Profit
input bool ExitOpposite = 1; //Exit by Opposite Signal
input bool ExitScope = 1; //Exit by PipFinite Exit Scope
input int MagicNumber = 1; //Magic Number
input int MaxOpenOrders = 1; //Max. Open Orders
input string Trailing_ = "--------------------< Trailing Stop >--------------------";//Trailing Stop Settings ............................................................................................................
input bool UseTrailing_Stop = false; //Use Trailing Stop
input double TrailingStopStart = 10; //Trailing Stop Start
input double TrailingStopStep = 10; //Trailing Stop Step
input string MM_Settings = "--------------------< Money Management >--------------------";//Money Management Settings ...........................................................................................................
input double FixedLots = 0.1; //Fixed Lot
input bool RiskLots = 1; //Use Risk % Lot
input RiskCalc Risk Type = 1; //Risk Calculate Type
input double RiskPercent = 1; //Risk %
input string Time_Filter = "--------------------< Trade Time >--------------------";//Trade Time Settings ............................................................................................................
input bool Use_Time_Filter = false; //Use Time Filter
input string Time_Start = "06:00"; //Time Start
input string Time_End = "21:59"; //Time End
input bool StoponFriday = false; //Stop/Close on Friday
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
double Drawdown, AllProfit = 0, point, ClosingArray[100], Lots, Sloss, Tprof, SLBUY = 0, buy = 0, sell = 0, buy1 = 0, sell1 = 0, buy2 = 0, sell2 = 0, buy3 = 0, sell3 = 0, risk, SLL = 0, LastLot = 0, lot = 0, atr = 0;
bool Long = false, Short = false, Long2 = false, Short2 = false, Buy = false, Sell = false, Buy2 = false, Sell2 = false, Buy3 = false, Sell3 = false;int PipValue = 1, Lot_Digits, signal, digit_lot = 0,
zz = 0, xx = 0, supp = 0, arr = 0;
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
if ((Bid < 10 && _Digits == 5) || (Bid>10 && _Digits == 3)) { PipValue = 10; }
if ((Bid < 10 && _Digits == 4) || (Bid>10 && _Digits == 2)) { PipValue = 1; }
point = Point*PipValue;
if (MarketInfo(Symbol(), MODE_LOTSTEP) >= 0.01) digit_lot = 2;
if (MarketInfo(Symbol(), MODE_LOTSTEP) >= 0.1) digit_lot = 1;
if (MarketInfo(Symbol(), MODE_LOTSTEP) >= 1) digit_lot = 0;
return(0);
}
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
//+------------------------------------------------------------------+
//| Time limited trading |
//+------------------------------------------------------------------+
bool GoodTime()
{
if (!Use_Time_Filter)return(true);
if (Use_Time_Filter)
{
if (TimeGMT() > StrToTime(Time_Start) && TimeGMT() < StrToTime(Time_End))return(true);
}
return(false);
}
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| Lot Calculate |
//+------------------------------------------------------------------+
void LotsSize()
{
Lots = FixedLots;
if (Risk Type == 1) { risk = AccountBalance(); }
if (Risk Type == 2) { risk = AccountEquity(); }
if (Risk Type == 3) { risk = AccountFreeMargin(); }
if (Lots < MarketInfo(Symbol(), MODE_MINLOT)) Lots = MarketInfo(Symbol(), MODE_MINLOT);
if (Lots > MarketInfo(Symbol(), MODE_MAXLOT)) Lots = MarketInfo(Symbol(), MODE_MAXLOT);
if (MarketInfo(Symbol(), MODE_MINLOT) < 0.1)Lot_Digits = 2;
if (RiskLots) { Lots = NormalizeDouble(risk * RiskPercent / 100000, digit_lot); }
}
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+----------------------------------------------------------------------------------+
//| CloseBuy |
//+----------------------------------------------------------------------------------+
int CloseBuyW()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_BID), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Weekend");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseSell |
//+----------------------------------------------------------------------------------+
int CloseSellW()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_SELL) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_ASK), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Weekend");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseBuy |
//+----------------------------------------------------------------------------------+
int CloseBuyD()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_BID), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Session End");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseSell |
//+----------------------------------------------------------------------------------+
int CloseSellD()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_SELL) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_ASK), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Session End");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseBuy |
//+----------------------------------------------------------------------------------+
int CloseBuyE()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_BID), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Exit Scope");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseSell |
//+----------------------------------------------------------------------------------+
int CloseSellE()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_SELL) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_ASK), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Exit Scope");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseBuy |
//+----------------------------------------------------------------------------------+
int CloseBuyO()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_BID), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Opposite Breakout Analyzer");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//+----------------------------------------------------------------------------------+
//| CloseSell |
//+----------------------------------------------------------------------------------+
int CloseSellO()
{
for (int i = OrdersTotal() - 1;i >= 0;i--) {
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_SELL) {
bool oc = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble
(MarketInfo(Symbol(), MODE_ASK), (int)MarketInfo(Symbol(), MODE_DIGITS)), 1000, Gold);
Print("Closed by Opposite Breakout Analyzer");
}
for (int x = 0;x < 100;x++)
{
if (ClosingArray[x] == 0)
{
ClosingArray[x] = OrderTicket();
break;
}
}
}
}
return(1);
}
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
void TrailingStops()
{
for (int i = 0; i < OrdersTotal(); i++)
{
bool OrSel = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY && UseTrailing_Stop && TrailingStopStep > 0 && TrailingStopStart > 0)
{
if (Bid - OrderOpenPrice() > TrailingStopStart* point && Bid - OrderOpenPrice() > TrailingStopStart * point)
{
if (OrderStopLoss() < (Bid - TrailingStopStep* point))
bool modify = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStopStep* point, OrderTakeProfit(), 0, Lime);
}
}
if (OrderType() == OP_SELL && UseTrailing_Stop && TrailingStopStep > 0 && TrailingStopStart > 0)
{
if (OrderOpenPrice() - Ask > TrailingStopStart* point && OrderOpenPrice() - Ask > TrailingStopStart * point)
{
if (OrderStopLoss() == 0 || OrderStopLoss() > Ask + TrailingStopStep* point)
bool modify = OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TrailingStopStep* point, OrderTakeProfit(), 0, Red);
}
}
}
}
}
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| get total order |
//+------------------------------------------------------------------+
int total()
{
int counter = 0;
for (int x = OrdersTotal() - 1;x >= 0;x--)
{
if (OrderSelect(x, 0) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MagicNumber)
{
counter++;
}
}
return(counter);
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
void Closer() {
for (int i = 0; i < OrdersTotal(); i++)
{
bool os = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderType() == OP_BUY)
{
if (Sell3 && ExitScope) { CloseBuyE(); }
}
if (OrderType() == OP_SELL)
{
if (Buy3 && ExitScope) { CloseSellE(); }
}
if (OrderType() == OP_BUY)
{
if (Sell2 && ExitOpposite) { CloseBuyO(); }
}
if (OrderType() == OP_SELL)
{
if (Buy2 && ExitOpposite) { CloseSellO(); }
}
}
}
}
//OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
//+------------------------------------------------------------------+
//| Open Rules |
//+------------------------------------------------------------------+
void Indicators()
{
if (!ExitScope)HideTestIndicators(true);
double buf3 = iCustom(_Symbol, 0, "Market\\PipFinite Exit Scope", "", bb, 1000, "", 3, "", DodgerBlue, Red, LimeGreen, Magenta, "", 0, 0, 0, 0, 1);
double buf4 = iCustom(_Symbol, 0, "Market\\PipFinite Exit Scope", "", bb, 1000, "", 3, "", DodgerBlue, Red, LimeGreen, Magenta, "", 0, 0, 0, 1, 1);
double buf30 = iCustom(_Symbol, 0, "Market\\PipFinite Exit Scope", "", bb, 1000, "", 3, "", DodgerBlue, Red, LimeGreen, Magenta, "", 0, 0, 0, 2, 1);
double buf40 = iCustom(_Symbol, 0, "Market\\PipFinite Exit Scope", "", bb, 1000, "", 3, "", DodgerBlue, Red, LimeGreen, Magenta, "", 0, 0, 0, 3, 1);
HideTestIndicators(false);
double buf11 = iCustom(NULL, 0, "Market\\PipFinite Breakout Analyzer", "", Periods, 1000, "", 1, 1, 0, 0, 2, 2, 8, "", DodgerBlue, HotPink, ForestGreen, Maroon, DarkSlateGray, "", 0, 0, 0, 0, 1);
double buf22 = iCustom(NULL, 0, "Market\\PipFinite Breakout Analyzer", "", Periods, 1000, "", 1, 1, 0, 0, 2, 2, 8, "", DodgerBlue, HotPink, ForestGreen, Maroon, DarkSlateGray, "", 0, 0, 0, 1, 1);
double SM1 = iCustom(Symbol(), 0, "Market\\PipFinite Strength Meter", "", SMPeriod, 1000, "", 0, 0, 8, "", LightBlue, YellowGreen, LimeGreen, Blue, Plum, HotPink, OrangeRed, Magenta, "", 0, 0, 0, 0, 0, 1);
double SM2 = iCustom(Symbol(), 0, "Market\\PipFinite Strength Meter", "", SMPeriod, 1000, "", 0, 0, 8, "", LightBlue, YellowGreen, LimeGreen, Blue, Plum, HotPink, OrangeRed, Magenta, "", 0, 0, 0, 0, 1, 1);
if (StopLoss != 0)HideTestIndicators(true);
atr = iATR(NULL, 0, ATRPeriod, 0);
HideTestIndicators(false);
// SCW changed logic so that energy level 4/-4 is ignored as well as that's overbought oversold from the energy meter
//Buy = (buf11 != EMPTY_VALUE && SM1 >= ThresholdLevel);
//Sell = (buf22 != EMPTY_VALUE && SM2 <= -ThresholdLevel);
Buy = ((buf11 != EMPTY_VALUE) && ((SM1 >= ThresholdLevel) && (SM1 < 4)));
Sell = ((buf22 != EMPTY_VALUE) && ((SM2 <= -ThresholdLevel) && (SM2 > -4)));
Buy2 = (buf11 != EMPTY_VALUE);
Sell2 = (buf22 != EMPTY_VALUE);
Buy3 = (buf30 != EMPTY_VALUE);
Sell3 = (buf40 != EMPTY_VALUE);
}
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
bool ban = false, band = false;LotsSize();Indicators();TrailingStops();
Closer();if (!GoodTime()) { CloseBuyD();CloseSellD();return(0); }
if (StoponFriday && DayOfWeek() == 5) { CloseBuyW();CloseSellW();return(0); }
//+------------------------------------------------------------------+
for (int i = OrdersTotal() - 1; i >= 0; i--)
{
if (OrderSelect(i, SELECT_BY_POS))
{
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderOpenTime() >= iTime(NULL, 0, 0)) ban = true;
}
}
}if (ban) { return(0); }
//+------------------------------------------------------------------+
for (int i = OrdersHistoryTotal() - 1;i >= 0;i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false)
{
Print("Error in history!"); break;
}
if (OrderSymbol() != Symbol() || OrderType() > OP_SELL) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if (OrderOpenTime() >= iTime(NULL, 0, 0)) band = true;
}
}if (band) { return(0); }
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
if (total() < MaxOpenOrders && GoodTime())
{
if (Buy) {
if (StopLoss == 0) { Sloss = Ask - (atr*ATRMulti) + ATROffset; }
if (StopLoss != 0) { Sloss = Ask - StopLoss * point; }
if (TakeProfit == 0) { Tprof = 0; }
else { Tprof = Bid + TakeProfit * point; }
int Tiketb = OrderSend(Symbol(), OP_BUY, Lots, Ask, PipValue, Sloss, Tprof, NameEA, MagicNumber, 0, Green);
}
if (Sell) {
if (StopLoss == 0) { Sloss = Bid + (atr*ATRMulti) + ATROffset;; }
if (StopLoss != 0) { Sloss = Bid + StopLoss * point; }
if (TakeProfit == 0) { Tprof = 0; }
else { Tprof = Ask - TakeProfit * point; }
int Tikets = OrderSend(Symbol(), OP_SELL, Lots, Bid, PipValue, Sloss, Tprof, NameEA, MagicNumber, 0, Red);
}
}
return(0);
}
//MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM