-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFxbrokerbusterV1.0.mq4
434 lines (417 loc) · 18.7 KB
/
FxbrokerbusterV1.0.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
/*
Generated by EX4-TO-MQ4 decompiler V4.0.223.1c []
Website: http://purebeam.biz
E-mail : [email protected]
*/
#property copyright "Copyright © 2009, fxbrokerbuster.Com"
#property link "http://www.fxbrokerbuster.com/"
extern string comment = "FxbrokerBuster EA";
extern int magic = 1234;
string gs_unused_88 = "Money Management";
extern double lots = 0.1;
extern bool mm = TRUE;
extern double risk = 1.5;
extern double minlot = 0.01;
extern double maxlot = 100.0;
extern string ordersmanagement = "Order Management";
extern bool ecn = FALSE;
bool gi_144 = FALSE;
bool gi_148 = FALSE;
extern int maxtrades = 10;
int gi_156 = 1;
extern bool hidesl = FALSE;
extern bool hidetp = FALSE;
extern double stoploss = 106.0;
extern double takeprofit = 37.0;
extern double trailingstart = 0.0;
extern double trailingstop = 0.0;
extern double trailingprofit = 0.0;
extern double trailingstep = 1.0;
extern double breakevengain = 19.0;
extern double breakeven = 5.0;
int gi_232 = 0;
int gi_236 = 0;
extern double maxspread = 10.0;
string gs_unused_248 = "Entry Logics";
bool gi_256 = TRUE;
int g_timeframe_260 = 0;
int gi_264 = 14;
int gi_268 = 2;
int gi_272 = 7;
int gi_276 = 75;
int gi_280 = 1;
bool gi_284 = TRUE;
int g_timeframe_288 = 0;
int gi_292 = 0;
int g_timeframe_296 = 0;
int g_period_300 = 177;
int g_ma_method_304 = MODE_SMA;
int g_applied_price_308 = PRICE_CLOSE;
int gi_312 = 1;
int gi_316 = 0;
bool gi_320 = FALSE;
int g_timeframe_324 = 0;
int gi_328 = 0;
extern string timefilter = "Time Filter";
extern int gmtshift = 1;
extern bool generalfilter = TRUE;
extern int starthour = 8;
int gi_352 = 0;
extern int endhour = 5;
int gi_360 = 0;
bool gi_364 = TRUE;
bool gi_368 = FALSE;
int gi_372 = 21;
int gi_376 = 0;
int gi_380;
int gi_384;
int gi_388;
int g_count_392;
int g_count_396;
int g_count_400;
int gi_404;
int g_ord_total_408;
int g_bars_412 = -1;
double g_ask_464;
double g_bid_472;
double g_price_488;
double g_price_496;
double g_lots_504;
string gs_552;
string gs_560;
string gs_568;
string gs_576;
string gs_584;
string gs_592;
datetime gt_unused_600;
datetime gt_unused_604;
int g_str2time_608;
int g_str2time_612;
int g_str2time_616;
int gi_620;
int gi_624;
double gd_628;
double gd_636;
int g_digits_644;
int init() {
gt_unused_600 = Time[0];
gt_unused_604 = Time[0];
g_digits_644 = Digits;
if (g_digits_644 == 3 || g_digits_644 == 5) {
gd_628 = 10.0 * Point;
gd_636 = 10;
} else {
gd_628 = Point;
gd_636 = 1;
}
return (0);
}
int start() {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
if (breakevengain > 0.0) movebreakeven(breakevengain, breakeven);
if (trailingstop > 0.0) movetrailingstop(trailingstart, trailingstop);
if (trailingprofit > 0.0) movetrailingprofit(trailingstart, trailingprofit);
if (gi_156 == 1 && TimeCurrent() - gi_620 < Period() || TimeCurrent() - gi_624 < Period()) {
g_count_392 = 1;
g_count_396 = 1;
}
if (g_bars_412 != Bars) {
g_count_392 = 0;
g_count_396 = 0;
g_bars_412 = Bars;
}
double l_ihigh_0 = iHigh(Symbol(), g_timeframe_260, iHighest(Symbol(), g_timeframe_260, MODE_HIGH, gi_264, gi_280));
double l_ilow_8 = iLow(Symbol(), g_timeframe_260, iLowest(Symbol(), g_timeframe_260, MODE_LOW, gi_264, gi_280));
double l_ima_16 = iMA(NULL, g_timeframe_296, g_period_300, 0, g_ma_method_304, g_applied_price_308, gi_316);
bool li_24 = FALSE;
bool li_28 = FALSE;
if (gi_256 == FALSE || (gi_256 && g_ask_464 > l_ihigh_0 + gi_268 * gd_628 && l_ihigh_0 - l_ilow_8 > gi_272 * gd_628 && l_ihigh_0 - l_ilow_8 < gi_276 * gd_628) && gi_284 == FALSE ||
(gi_284 && iOpen(NULL, g_timeframe_288, gi_292) < l_ima_16 && iClose(NULL, g_timeframe_288, gi_292) > l_ima_16 + gi_312 * gd_628)) {
if (gi_148) li_28 = TRUE;
else li_24 = TRUE;
}
if (gi_256 == FALSE || (gi_256 && g_bid_472 < l_ilow_8 - gi_268 * gd_628 && l_ihigh_0 - l_ilow_8 > gi_272 * gd_628 && l_ihigh_0 - l_ilow_8 < gi_276 * gd_628) && gi_284 == FALSE ||
(gi_284 && iOpen(NULL, g_timeframe_288, gi_292) > l_ima_16 && iClose(NULL, g_timeframe_288, gi_292) < l_ima_16 - gi_312 * gd_628)) {
if (gi_148) li_24 = TRUE;
else li_28 = TRUE;
}
if ((gi_144 && li_28) || (gi_148 == FALSE && gi_320 && iOpen(NULL, g_timeframe_324, gi_328) > l_ima_16 && iClose(NULL, g_timeframe_324, gi_328) < l_ima_16 && !li_24) ||
(gi_148 && gi_320 && iOpen(NULL, g_timeframe_324, gi_328) > l_ima_16 && iClose(NULL, g_timeframe_324, gi_328) < l_ima_16) && !li_24) closebuy();
if ((gi_144 && li_24) || (gi_148 == FALSE && gi_320 && iOpen(NULL, g_timeframe_324, gi_328) < l_ima_16 && iClose(NULL, g_timeframe_324, gi_328) > l_ima_16 && !li_28) ||
(gi_148 && gi_320 && iOpen(NULL, g_timeframe_324, gi_328) > l_ima_16 && iClose(NULL, g_timeframe_324, gi_328) < l_ima_16) && !li_28) closesell();
if (hidesl) hideclosebuy();
if (hidetp) hideclosesell();
if (generalfilter) {
gi_380 = starthour + gmtshift;
if (gi_380 > 23) gi_380 -= 24;
if (gi_380 < 10) gs_552 = "0" + gi_380;
if (gi_380 > 9) gs_552 = gi_380;
if (gi_352 < 10) gs_560 = "0" + gi_352;
if (gi_352 > 9) gs_560 = gi_352;
g_str2time_608 = StrToTime(gs_552 + ":" + gs_560);
gi_384 = endhour + gmtshift;
if (gi_384 > 23) gi_384 -= 24;
if (endhour < 10) gs_568 = "0" + gi_384;
if (endhour > 9) gs_568 = gi_384;
if (gi_360 < 10) gs_576 = "0" + gi_360;
if (gi_360 > 9) gs_576 = gi_360;
g_str2time_612 = StrToTime(gs_568 + ":" + gs_576);
}
if (gi_368) {
gi_388 = gi_372 + gmtshift;
if (gi_388 > 23) gi_388 -= 24;
if (gi_388 < 10) gs_584 = "0" + gi_388;
if (gi_388 > 9) gs_584 = gi_388;
if (gi_376 < 10) gs_592 = "0" + gi_376;
if (gi_376 > 9) gs_592 = gi_376;
g_str2time_616 = StrToTime(gs_584 + ":" + gs_592);
}
if ((generalfilter && (gi_380 < gi_384 && TimeCurrent() < g_str2time_608 || TimeCurrent() > g_str2time_612) || (gi_380 > gi_384 && TimeCurrent() < g_str2time_608 &&
TimeCurrent() > g_str2time_612)) || (gi_364 == FALSE && DayOfWeek() == 0) || (gi_368 && DayOfWeek() == 5 && TimeCurrent() > g_str2time_616)) return (0);
if (g_ask_464 - g_bid_472 > maxspread * gd_636 * gd_628) return (0);
if (count(OP_BUY) + count(OP_SELL) >= maxtrades) return (0);
if (mm) lots = lotsoptimized();
int li_32 = 0;
if (gi_232 > 0) li_32 = TimeCurrent() + 60 * gi_232 - 5;
if (li_24 && g_count_392 < gi_156) {
g_lots_504 = lots;
if (ecn == FALSE) gi_404 = open(OP_BUY, g_lots_504, g_ask_464, stoploss, takeprofit, li_32, Blue);
if (ecn) {
gi_404 = open(OP_BUY, g_lots_504, g_ask_464, 0, 0, li_32, Blue);
createlstoploss(stoploss);
createltakeprofit(takeprofit);
}
if (gi_404 > 0) g_count_392++;
}
if (li_28 && g_count_396 < gi_156) {
g_lots_504 = lots;
if (ecn == FALSE) gi_404 = open(OP_SELL, g_lots_504, g_bid_472, stoploss, takeprofit, li_32, Red);
if (ecn) {
gi_404 = open(OP_SELL, g_lots_504, g_bid_472, 0, 0, li_32, Red);
createsstoploss(stoploss);
createstakeprofit(takeprofit);
}
if (gi_404 > 0) g_count_396++;
}
return (0);
}
int open(int a_cmd_0, double a_lots_4, double a_price_12, int ai_20, int ai_24, int a_datetime_28, color a_color_32) {
int li_52;
int l_count_36 = 0;
int li_40 = 100;
int l_error_44 = 0;
int l_ticket_48 = 0;
if (NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2) == 0.01) li_52 = 2;
else li_52 = 1;
a_lots_4 = NormalizeDouble(a_lots_4, li_52);
if (li_52 == 2) minlot = 0.01;
if (a_lots_4 < minlot) a_lots_4 = minlot;
if (a_lots_4 > maxlot) a_lots_4 = maxlot;
if (a_cmd_0 == OP_BUY || a_cmd_0 == OP_BUYSTOP || a_cmd_0 == OP_BUYLIMIT) {
if (hidesl == FALSE && ai_20 > 0) g_price_488 = a_price_12 - ai_20 * gd_628;
else g_price_488 = 0;
if (hidetp == FALSE && ai_24 > 0) g_price_496 = a_price_12 + ai_24 * gd_628;
else g_price_496 = 0;
}
if (a_cmd_0 == OP_SELL || a_cmd_0 == OP_SELLSTOP || a_cmd_0 == OP_SELLLIMIT) {
if (hidesl == FALSE && ai_20 > 0) g_price_488 = a_price_12 + ai_20 * gd_628;
else g_price_488 = 0;
if (hidetp == FALSE && ai_24 > 0) g_price_496 = a_price_12 - ai_24 * gd_628;
else g_price_496 = 0;
}
for (l_count_36 = 0; l_count_36 < li_40; l_count_36++) {
l_ticket_48 = OrderSend(Symbol(), a_cmd_0, a_lots_4, a_price_12, gi_236 * gd_636, g_price_488, g_price_496, comment + ". Magic: " + DoubleToStr(magic, 0), magic, a_datetime_28, a_color_32);
l_error_44 = GetLastError();
if (l_error_44 == 0/* NO_ERROR */) break;
if (!((l_error_44 == 4/* SERVER_BUSY */ || l_error_44 == 137/* BROKER_BUSY */ || l_error_44 == 146/* TRADE_CONTEXT_BUSY */ || l_error_44 == 136/* OFF_QUOTES */))) break;
Sleep(1000);
}
return (l_ticket_48);
}
double lotsoptimized() {
int li_0;
double l_lots_4;
if (NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP), 2) == 0.01) li_0 = 2;
else li_0 = 1;
if (mm == TRUE) l_lots_4 = NormalizeDouble(AccountFreeMargin() / (100.0 * (NormalizeDouble(MarketInfo(Symbol(), MODE_MARGINREQUIRED), 4) + 5.0) / risk) - 0.05, li_0);
else l_lots_4 = lots;
return (l_lots_4);
}
int count(int a_cmd_0) {
g_count_400 = 0;
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderType() == a_cmd_0 && OrderMagicNumber() == magic) g_count_400++;
}
return (g_count_400);
}
return (0);
}
void closebuy() {
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), g_bid_472, gi_236 * gd_636);
}
}
}
void closesell() {
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), g_ask_464, gi_236 * gd_636);
}
}
}
void hideclosebuy() {
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == OP_BUY && (takeprofit > 0.0 && OrderProfit() > 10.0 * (takeprofit * OrderLots())) ||
(stoploss > 0.0 && OrderProfit() < 10.0 * ((-1.0 * stoploss) * OrderLots()) - 10.0 * (MarketInfo(Symbol(), MODE_SPREAD) * OrderLots()) / gd_636)) OrderClose(OrderTicket(), OrderLots(), g_bid_472, gi_236 * gd_636);
}
}
}
void hideclosesell() {
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() == OP_SELL && (takeprofit > 0.0 && OrderProfit() > 10.0 * (takeprofit * OrderLots())) ||
(stoploss > 0.0 && OrderProfit() < 10.0 * ((-1.0 * stoploss) * OrderLots()) - 10.0 * (MarketInfo(Symbol(), MODE_SPREAD) * OrderLots()) / gd_636)) OrderClose(OrderTicket(), OrderLots(), g_ask_464, gi_236 * gd_636);
}
}
}
void movebreakeven(int ai_0, int ai_4) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_BUY) {
if (NormalizeDouble(g_bid_472 - OrderOpenPrice(), g_digits_644) < NormalizeDouble(ai_0 * gd_628, g_digits_644)) continue;
if (!(NormalizeDouble(OrderStopLoss() - OrderOpenPrice(), g_digits_644) < NormalizeDouble(ai_4 * gd_628, g_digits_644) || OrderStopLoss() == 0.0)) continue;
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() + ai_4 * gd_628, g_digits_644), OrderTakeProfit(), 0, Blue);
return;
}
if (NormalizeDouble(OrderOpenPrice() - g_ask_464, g_digits_644) >= NormalizeDouble(ai_0 * gd_628, g_digits_644)) {
if (NormalizeDouble(OrderOpenPrice() - OrderStopLoss(), g_digits_644) < NormalizeDouble(ai_4 * gd_628, g_digits_644) || OrderStopLoss() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(OrderOpenPrice() - ai_4 * gd_628, g_digits_644), OrderTakeProfit(), 0, Red);
return;
}
}
}
}
}
}
void movetrailingstop(double ad_0, double ad_8) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
if (OrdersTotal() > 0) {
for (g_ord_total_408 = OrdersTotal(); g_ord_total_408 >= 0; g_ord_total_408--) {
OrderSelect(g_ord_total_408, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_BUY) {
if (!(NormalizeDouble(g_ask_464, g_digits_644) > NormalizeDouble(OrderOpenPrice() + ad_0 * gd_628, g_digits_644) && NormalizeDouble(OrderStopLoss(), g_digits_644) < NormalizeDouble(g_bid_472 - (ad_8 +
trailingstep) * gd_628, g_digits_644))) continue;
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(g_bid_472 - ad_8 * gd_628, g_digits_644), OrderTakeProfit(), 0, Blue);
return;
}
if (NormalizeDouble(g_bid_472, g_digits_644) < NormalizeDouble(OrderOpenPrice() - ad_0 * gd_628, g_digits_644) && NormalizeDouble(OrderStopLoss(), g_digits_644) > NormalizeDouble(g_ask_464 +
(ad_8 + trailingstep) * gd_628, g_digits_644) || OrderStopLoss() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(g_ask_464 + ad_8 * gd_628, g_digits_644), OrderTakeProfit(), 0, Red);
return;
}
}
}
}
}
void movetrailingprofit(double ad_0, double ad_8) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
for (int l_pos_16 = 0; l_pos_16 < OrdersTotal(); l_pos_16++) {
if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_BUY) {
if (NormalizeDouble(g_bid_472 - OrderOpenPrice(), g_digits_644) <= NormalizeDouble((-1.0 * ad_0) * gd_628, g_digits_644))
if (NormalizeDouble(OrderTakeProfit(), g_digits_644) > NormalizeDouble(g_bid_472 + (ad_8 + trailingstep) * gd_628, g_digits_644) || NormalizeDouble(OrderTakeProfit(), g_digits_644) == 0.0) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(g_bid_472 + ad_8 * gd_628, g_digits_644), 0, Blue);
}
if (OrderType() == OP_SELL) {
if (NormalizeDouble(OrderOpenPrice() - g_ask_464, g_digits_644) <= NormalizeDouble((-1.0 * ad_0) * gd_628, g_digits_644))
if (NormalizeDouble(OrderTakeProfit(), g_digits_644) < NormalizeDouble(g_ask_464 - (ad_8 + trailingstep) * gd_628, g_digits_644)) OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(g_ask_464 - ad_8 * gd_628, g_digits_644), 0, Red);
}
}
}
}
}
void createlstoploss(int ai_0) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_BUY) {
if (OrderStopLoss() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(g_ask_464 - ai_0 * gd_628, g_digits_644), OrderTakeProfit(), 0, Red);
return;
}
}
}
}
}
void createsstoploss(int ai_0) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_SELL) {
if (OrderStopLoss() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(g_bid_472 + ai_0 * gd_628, g_digits_644), OrderTakeProfit(), 0, Red);
return;
}
}
}
}
}
void createltakeprofit(int ai_0) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
for (int l_pos_4 = 0; l_pos_4 < OrdersTotal(); l_pos_4++) {
OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_BUY) {
if (OrderTakeProfit() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(g_ask_464 + ai_0 * gd_628, g_digits_644), 0, Red);
return;
}
}
}
}
}
void createstakeprofit(int ai_0) {
RefreshRates();
g_ask_464 = MarketInfo(Symbol(), MODE_ASK);
g_bid_472 = MarketInfo(Symbol(), MODE_BID);
int l_ord_total_4 = OrdersTotal();
for (int l_pos_8 = 0; l_pos_8 < OrdersTotal(); l_pos_8++) {
OrderSelect(l_pos_8, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == magic) {
if (OrderType() == OP_SELL) {
if (OrderTakeProfit() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), NormalizeDouble(g_bid_472 - ai_0 * gd_628, g_digits_644), 0, Red);
return;
}
}
}
}
}