-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOptmizedII_NZDUSD-GIT.mq4
629 lines (568 loc) · 27.7 KB
/
OptmizedII_NZDUSD-GIT.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
//+------------------------------------------------------------------+
//| Done_Optimized_NZDUSD.mq4 |
//| alkas |
//| alkas.gr |
//+------------------------------------------------------------------+
#property copyright "alkas"
#property link "alkas.gr"
extern double lotsize=0.05;
extern int maxnumoftrades=2;
extern int maxtradesperday=1;
extern bool range=false;
extern int magic=10;
extern int step=10; // number of pips
extern bool fivedigits=true;
extern double startprice=0.8;
extern double startprice3=100;
extern string out1="---------------END OF BASIC PARAMS-----------------";
//extern int tp=10;
//extern int sl=20;
extern int maxspread=120;
extern int slipage=1;
extern int starthour=0;
extern int startmin=0;
extern int endhour=22;
extern int endmin=0;
//+------------------------------------------------------------------+
//Print lines VARIABLES
//+------------------------------------------------------------------+
extern double endprice=2.0;
extern double endprice3=200;
//+------------------------------------------------------------------+
// Internal Static variables
//+------------------------------------------------------------------+
double borders[3000];
bool intrade=false;
double borderup=0;
double borderdown=0;
int opentradescounter=0;
bool buyroute=false;
string stringprice;
string stringspread;
double levelzero=0;
bool readyfortrade=true;
int tradesfortheday=0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
clearparams();
printlines();
createlabels();
printlabels();
printstaticlabels();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(0,OBJ_LABEL);
ObjectsDeleteAll(0,OBJ_HLINE);
clearparams();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
checktime();
if (readyfortrade==false) return;
if (tradesfortheday==maxtradesperday) return;
if (!intrade)
{
if (MarketInfo(Symbol(),MODE_SPREAD)>maxspread) {Print("Start: Spread is bigger than max spread. "+ MarketInfo(Symbol(),MODE_SPREAD));return;} //check for spread
if (borderup==0 || borderdown==0) {Print("Start: Oops! borderup or down found to be 0. I will call whereami. Borderup: "+borderup+" borderdown: "+borderdown);whereami();}
startnewtrade();
checkforwhereami();
}
else
{
if (fivedigits) {mainlogic();}
else {mainlogic100();}
}
printlabels();
//----
return(0);
}
//+------------------------------------------------------------------+
//-------------------------------------------------------------------------
//FUNCTIONS
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// CHECK TIME
//-------------------------------------------------------------------------
void checktime()
{
static bool firstwhereami=false;
if (Hour()<starthour) readyfortrade=false;
if (Hour()==starthour)
{
if (Minute()==startmin && !firstwhereami) {Print("checktime: I will start to work. I will run whereami.");whereami();firstwhereami=true;}
if (Minute()>=startmin)
{
readyfortrade=true;
}
else
{
readyfortrade=false;
}
}
if (Hour()>starthour)
{
if (Hour()<endhour) readyfortrade=true;
if (Hour()==endhour)
{
if (Minute()<=endmin)
{
readyfortrade=true;
}
else
{
readyfortrade=false;
}
}
if (Hour()>endhour)
{tradesfortheday=0;readyfortrade=false;firstwhereami=false;}
}
if (!readyfortrade && intrade==true) {Print("Checktime: Time not for trade but orders are open. I will close them.");closeorders(false);}
}
//-------------------------------------------------------------------------
// START NEW TRADE
//-------------------------------------------------------------------------
void startnewtrade()
{
if (Bid>=borderup)
{
if (range)
{
Print("startnewtrade: Bid > borderup. Range. 1st trade. I will sell now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);
sendsellorder(lotsize);
buyroute=false;
levelzero=borderup;
}
else
{
Print("startnewtrade: Bid > borderup. TREND. 1st trade. I will buy now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);
sendbuyorder(lotsize);buyroute=true;
}
}
if (Bid<=borderdown)
{
if (range)
{
Print("startnewtrade: Bid < borderdown. Range. 1st trade. I will buy now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);
sendbuyorder(lotsize);buyroute=true;levelzero=borderdown;
}
else
{
Print("startnewtrade: Bid < borderdown. TREND. 1st trade. I will sell now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);
sendsellorder(lotsize);buyroute=false;levelzero=borderdown;
}
}
}
//-------------------------------------------------------------------------
// MAIN LOGIC
//-------------------------------------------------------------------------
void mainlogic()
{
//win?
if (buyroute)
{
if (range)
{
if (Bid>=borderup) {Print("mainlogic: We WON (1 trade)! Bid > borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (opentradescounter>1 && Bid>=borderdown) {Print("mainlogic: We WON (many trades)! Bid > borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid<=borderdown-(step*opentradescounter)/10000.0) {Print("mainlogic: We LOST! Bid < borderdown. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (opentradescounter<maxnumoftrades && Bid<=borderdown-(step*opentradescounter)/10000.0) {Print("mainlogic: Bid < borderdown. Range. 1 more order. I will BUY now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);sendbuyorder(lotsize);}
}
else
{
if (Bid>=borderup + (step*opentradescounter)/10000.0) {Print("mainlogic 1: We WON (1 trade)! Bid > borderup. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (opentradescounter==1 && Bid<=borderdown) {Print("mainlogic 2: We LOST 1st trade! Bid < borderdown. TREND. I will close all orders now and SELL"+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(true);sendsellorder(lotsize*2);}
if (maxnumoftrades==opentradescounter && Bid>=borderup) {Print("mainlogic 3: We LOST! Bid > borderup. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid<=borderdown-(step)/10000.0) {Print("mainlogic 4: WE WON! Bid < borderdown. TREND. I will CLOSE ORDERS now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
}
}
else
{
if (range)
{
if (Bid<=borderdown) {Print("mainlogic: We WON! Bid < borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (opentradescounter>1 && Bid<=borderup) {Print("mainlogic: We WON (many trades)! Bid < borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderup);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid>=borderup+(step*opentradescounter)/10000.0) {Print("mainlogic: We LOST! Bid > borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (opentradescounter<maxnumoftrades && Bid>=borderup+(step*opentradescounter)/10000.0) {Print("mainlogic: Bid > borderup. Range. 1 more order. I will SELL now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);sendsellorder(lotsize);}
}
else
{
if (Bid<=borderdown - (step*opentradescounter)/10000.0) {Print("mainlogic 1: We WON (1 trade)! Bid < borderdown. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (opentradescounter==1 && Bid>=borderup) {Print("mainlogic 2: We LOST 1st trade! Bid > borderup. TREND. I will close all orders now and BUY"+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(true);sendbuyorder(lotsize*2);}
if (maxnumoftrades==opentradescounter && Bid<=borderdown) {Print("mainlogic 3: We LOST! Bid < borderdown. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderdown);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid>=borderup+(step)/10000.0) {Print("mainlogic 4: WE WON! Bid > borderup. TREND. I will CLOSE ORDERS now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
}
}
}
//-------------------------------------------------------------------------
// MAIN LOGIC100
//-------------------------------------------------------------------------
void mainlogic100()
{
//win?
if (buyroute)
{
if (range)
{
if (Bid>=borderup) {Print("mainlogic: We WON (1 trade)! Bid > borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (opentradescounter>1 && Bid>=borderdown) {Print("mainlogic: We WON (many trades)! Bid > borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid<=borderdown-(step*opentradescounter)/100.0) {Print("mainlogic: We LOST! Bid < borderdown. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (opentradescounter<maxnumoftrades && Bid<=borderdown-(step*opentradescounter)/100.0) {Print("mainlogic: Bid < borderdown. Range. 1 more order. I will BUY now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);sendbuyorder(lotsize);}
}
else
{
if (Bid>=borderup + (step*opentradescounter)/100.0) {Print("mainlogic 1: We WON (1 trade)! Bid > borderup. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (opentradescounter==1 && Bid<=borderdown) {Print("mainlogic 2: We LOST 1st trade! Bid < borderdown. TREND. I will close all orders now and SELL"+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(true);sendsellorder(lotsize*2);}
if (maxnumoftrades==opentradescounter && Bid>=borderup) {Print("mainlogic 3: We LOST! Bid > borderup. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid<=borderdown-(step)/100.0) {Print("mainlogic 4: WE WON! Bid < borderdown. TREND. I will CLOSE ORDERS now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
}
}
else
{
if (range)
{
if (Bid<=borderdown) {Print("mainlogic: We WON! Bid < borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (opentradescounter>1 && Bid<=borderup) {Print("mainlogic: We WON (many trades)! Bid < borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderup);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid>=borderup+(step*opentradescounter)/100.0) {Print("mainlogic: We LOST! Bid > borderup. Range. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
if (opentradescounter<maxnumoftrades && Bid>=borderup+(step*opentradescounter)/100.0) {Print("mainlogic: Bid > borderup. Range. 1 more order. I will SELL now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);sendsellorder(lotsize);}
}
else
{
if (Bid<=borderdown - (step*opentradescounter)/100.0) {Print("mainlogic 1: We WON (1 trade)! Bid < borderdown. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderdown: "+borderdown);closeorders(false);}
if (opentradescounter==1 && Bid>=borderup) {Print("mainlogic 2: We LOST 1st trade! Bid > borderup. TREND. I will close all orders now and BUY"+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(true);sendbuyorder(lotsize*2);}
if (maxnumoftrades==opentradescounter && Bid<=borderdown) {Print("mainlogic 3: We LOST! Bid < borderdown. TREND. I will close all orders now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderdown);closeorders(false);}
if (maxnumoftrades==opentradescounter && Bid>=borderup+(step)/100.0) {Print("mainlogic 4: WE WON! Bid > borderup. TREND. I will CLOSE ORDERS now."+ " Bid: "+Bid+" Ask: "+Ask+" borderup: "+borderup);closeorders(false);}
}
}
}
//-------------------------------------------------------------------------
// CHECK FOR WHERE AMI
//-------------------------------------------------------------------------
void checkforwhereami()
{
if (!intrade)
{
if (fivedigits)
{
if (Bid-borderdown>step/10000.0)
{
Print("Checkforwhereami: Borderdown is out of step. I will call whereami.");
Print("Checkforwhereami: Borderdown is: "+borderdown+" and BID is: "+Bid+ " and Step is: "+ DoubleToStr(step/10000.0,5));
whereami();
}
}
else
{
if (Bid-borderdown>step/100.0)
{
Print("Checkforwhereami: Borderdown is out of step. I will call whereami");
Print("Checkforwhereami: Borderdown is: "+borderdown+" and BID is: "+Bid+ " and Step is: "+ DoubleToStr(step/100.0,5));
whereami();
}
}
}
}
//-------------------------------------------------------------------------
// PRINT STATIC LABELS
//-------------------------------------------------------------------------
void printstaticlabels()
{
ObjectSetText("magic","Magic: " + magic,10,"Arial",White);
ObjectSetText("lotsize","Lot Size: " + DoubleToStr(lotsize,2),10,"Arial",White);
ObjectSetText("maxnumoftrades","Max trades per trade: " + maxnumoftrades,10,"Arial",White);
ObjectSetText("range","Range: " + range,10,"Arial",White);
ObjectSetText("maxnumoftradesperday","Max trades per day: " + maxtradesperday,10,"Arial",White);
ObjectSetText("step","Step: " + step,10,"Arial",White);
if (fivedigits) {ObjectSetText("stp","Start price: " + DoubleToStr(startprice,2),10,"Arial",White);}
else {ObjectSetText("stp","Start price: " + DoubleToStr(startprice3,2),10,"Arial",White);}
ObjectSetText("stime","Start: " +starthour+":"+startmin,10,"Arial",White);
ObjectSetText("etime","End: " +endhour+":"+endmin,10,"Arial",White);
}
//-------------------------------------------------------------------------
// PRINTLABELS
//-------------------------------------------------------------------------
void printlabels()
{
int i;
//Print Objects
if (fivedigits)
{stringprice=DoubleToStr(Bid,5);}
else
{stringprice=DoubleToStr(Bid,3); }
ObjectSetText("pricelabel",stringprice,18,"Arial",White);
stringspread=DoubleToStr(MarketInfo(Symbol(),MODE_SPREAD),0);
ObjectSetText("spreadlabel","Spread: " + stringspread,12,"Arial",White);
ObjectSetText("opentradescounter","Open trades: " + opentradescounter,10,"Arial",White);
ObjectSetText("intrade","Intrade: " + intrade,10,"Arial",White);
ObjectSetText("buyroute","Buy route: " + buyroute,10,"Arial",White);
ObjectSetText("borderup","Border up: " + DoubleToStr(borderup,5),12,"Arial",White);
ObjectSetText("borderdown","Border down: " + DoubleToStr(borderdown,5),12,"Arial",White);
ObjectSetText("tradestoday","Today traded: " + tradesfortheday+ " times",10,"Arial",White);
ObjectSetText("timenow",Hour()+":" + Minute(),10,"Arial",White);
}
//-------------------------------------------------------------------------
//Print lines
//-------------------------------------------------------------------------
void printlines()
{
Print("Print Lines");
double stp=startprice;
double enp=endprice;
double stp3=startprice3;
double enp3=endprice3;
int i=1;
if (fivedigits)
{
while (stp<=enp)
{
ObjectCreate("line"+stp, OBJ_HLINE, 0, Time[0], stp, 0, 0);
ObjectSet("line"+stp,OBJPROP_COLOR,Blue);
borders[i]=stp;
stp+=step/10000.0;
i++;
}
}
else
{
while (stp3<=enp3)
{
ObjectCreate("line"+stp3, OBJ_HLINE, 0, Time[0], stp3, 0, 0);
ObjectSet("line"+stp3,OBJPROP_COLOR,Blue);
borders[i]=stp3;
stp3+=step/100.0;
i++;
}
}
}
//-------------------------------------------------------------------------
//CLEAR PARAMS
//-------------------------------------------------------------------------
void clearparams()
{
Print("clearparams");
opentradescounter=0;
intrade=false;
}
//-------------------------------------------------------------------------
//WHERE AM I
//-------------------------------------------------------------------------
void whereami()
{
int i;
if (fivedigits)
{
for (i=1;i<=3000;i++)
{
if (Bid-borders[i]<=step/10000.0)
{
borderdown=borders[i];
borderup=borders[i]+step/10000.0;
break;
}
}
}
else
{
for (i=1;i<=3000;i++)
{
if (Bid-borders[i]<=step/100.0)
{
borderdown=borders[i];
borderup=borders[i]+step/100.0;
break;
}
}
}
Print("Whereami:I just found where i am. Borderup: "+borderup+" borderdown: "+borderdown + " and BID: "+Bid);
}
//-------------------------------------------------------------------------
// SENDBUYORDER
//-------------------------------------------------------------------------
void sendbuyorder(double lsize)
{
Print("Send buy order");
int ticket;
Print("send ASK: "+Ask+ " Bid: "+Bid+" Opentrdescnt: "+opentradescounter);
ticket=OrderSend(Symbol(),OP_BUY,lsize,Ask,slipage,0,0,"",magic,0,Green );
if(ticket<0)
{
Print("sendbuyorder: OrderSend failed with error #",GetLastError());
return(0);
}
else
{
intrade=true;
opentradescounter++;
}
}
//-------------------------------------------------------------------------
// SENDSELLORDER
//-------------------------------------------------------------------------
void sendsellorder(double lsize)
{
Print("Send sell order");
int ticket;
Print("send BID: "+Bid+ " Ask: "+Ask+" Opentrdescnt: "+opentradescounter);
ticket=OrderSend(Symbol(),OP_SELL,lsize,Bid,slipage,0,0,"",magic,0,Red);
if(ticket<0)
{
Print("sendsellorder: OrderSend failed with error #",GetLastError());
return(0);
}
else
{
intrade=true;
opentradescounter++;
}
}
//-------------------------------------------------------------------------
// CLOSEORDERS OLD
//-------------------------------------------------------------------------
void closeorders(bool middle)
{
int order_type;
int i;
string Symb=Symbol();
Print("closeorders: I will close all orders now for "+Symb);
double price;
Print("closeorders: Total orders: "+OrdersTotal());
bool allok=false;
int total = OrdersTotal();
for(i=total-1;i>=0;i--)
{
if (OrderSelect(i,SELECT_BY_POS)==true) // If the next is available
{ // Order analysis:
//----------------------------------------------------------------------- 3 --
if (OrderSymbol()!= Symb) continue; // Symbol is not ours
//----------------------------------------------------------------------- 4 --
int Ticket=OrderTicket(); // Order ticket
order_type=OrderType();
double lsize=OrderLots();
if (order_type==0) price=Bid;
if (order_type==1) price=Ask;
Print("closeorders: Bid: "+Bid+ " Ask: " + Ask);
bool Ans=OrderClose(Ticket,lsize,price,slipage,Blue);// Order closing
//-------------------------------------------------------------------------- 8 --
if (Ans==true) // Got it! :)
{
Print ("Closeorders: Closed order "," ",Ticket);allok=true;
}
else
{
int Error=GetLastError();
Print("Closeorders: Order closing failed with error code: ",Error);
allok=false;
}
}
}
if (allok && !middle) {tradesfortheday++;clearparams();Print("Closeorders: I have closed all orders. I have to find where am. ");whereami();}
//--------------
}
//-------------------------------------------------------------------------
// CREATE LABELS
//-------------------------------------------------------------------------
void createlabels()
{
Print("Create Labels");
//---- PRICE RELATIVE LABELS
ObjectCreate("pricelabel",OBJ_LABEL, 0, 0, 0);
ObjectSet( "pricelabel", OBJPROP_CORNER, 1);
ObjectSet( "pricelabel", OBJPROP_XDISTANCE,10 );
ObjectSet( "pricelabel", OBJPROP_YDISTANCE,50 );
ObjectCreate("spreadlabel",OBJ_LABEL, 0, 0, 0);
ObjectSet( "spreadlabel", OBJPROP_CORNER, 1);
ObjectSet( "spreadlabel", OBJPROP_XDISTANCE,10 );
ObjectSet( "spreadlabel", OBJPROP_YDISTANCE,80 );
ObjectCreate("borderup",OBJ_LABEL, 0, 0, 0);
ObjectSet( "borderup", OBJPROP_CORNER, 1);
ObjectSet( "borderup", OBJPROP_XDISTANCE,10 );
ObjectSet( "borderup", OBJPROP_YDISTANCE,110 );
ObjectCreate("borderdown",OBJ_LABEL, 0, 0, 0);
ObjectSet( "borderdown", OBJPROP_CORNER, 1);
ObjectSet( "borderdown", OBJPROP_XDISTANCE,10 );
ObjectSet( "borderdown", OBJPROP_YDISTANCE,130 );
//-------------------------------------------------
// STATIC LABELS
ObjectCreate("etime",OBJ_LABEL, 0, 0, 0);
ObjectSet( "etime", OBJPROP_CORNER, 3);
ObjectSet( "etime", OBJPROP_XDISTANCE,10 );
ObjectSet( "etime", OBJPROP_YDISTANCE,10 );
ObjectCreate("stime",OBJ_LABEL, 0, 0, 0);
ObjectSet( "stime", OBJPROP_CORNER, 3);
ObjectSet( "stime", OBJPROP_XDISTANCE,10 );
ObjectSet( "stime", OBJPROP_YDISTANCE,30 );
ObjectCreate("magic",OBJ_LABEL, 0, 0, 0);
ObjectSet( "magic", OBJPROP_CORNER, 3);
ObjectSet( "magic", OBJPROP_XDISTANCE,10 );
ObjectSet( "magic", OBJPROP_YDISTANCE,50 );
ObjectCreate("range",OBJ_LABEL, 0, 0, 0);
ObjectSet( "range", OBJPROP_CORNER, 3);
ObjectSet( "range", OBJPROP_XDISTANCE,10 );
ObjectSet( "range", OBJPROP_YDISTANCE,70 );
ObjectCreate("maxnumoftrades",OBJ_LABEL, 0, 0, 0);
ObjectSet( "maxnumoftrades", OBJPROP_CORNER, 3);
ObjectSet( "maxnumoftrades", OBJPROP_XDISTANCE,10 );
ObjectSet( "maxnumoftrades", OBJPROP_YDISTANCE,90 );
ObjectCreate("maxnumoftradesperday",OBJ_LABEL, 0, 0, 0);
ObjectSet( "maxnumoftradesperday", OBJPROP_CORNER, 3);
ObjectSet( "maxnumoftradesperday", OBJPROP_XDISTANCE,10 );
ObjectSet( "maxnumoftradesperday", OBJPROP_YDISTANCE,110 );
ObjectCreate("stp",OBJ_LABEL, 0, 0, 0);
ObjectSet( "stp", OBJPROP_CORNER, 3);
ObjectSet( "stp", OBJPROP_XDISTANCE,10 );
ObjectSet( "stp", OBJPROP_YDISTANCE,130 );
ObjectCreate("lotsize",OBJ_LABEL, 0, 0, 0);
ObjectSet( "lotsize", OBJPROP_CORNER, 3);
ObjectSet( "lotsize", OBJPROP_XDISTANCE,10 );
ObjectSet( "lotsize", OBJPROP_YDISTANCE,150 );
ObjectCreate("step",OBJ_LABEL, 0, 0, 0);
ObjectSet( "step", OBJPROP_CORNER, 3);
ObjectSet( "step", OBJPROP_XDISTANCE,10 );
ObjectSet( "step", OBJPROP_YDISTANCE,170 );
//-------------------------------------------------
// DYNAMIC LABELS
ObjectCreate("opentradescounter",OBJ_LABEL, 0, 0, 0);
ObjectSet( "opentradescounter", OBJPROP_CORNER, 2);
ObjectSet( "opentradescounter", OBJPROP_XDISTANCE,10 );
ObjectSet( "opentradescounter", OBJPROP_YDISTANCE,10 );
ObjectCreate("intrade",OBJ_LABEL, 0, 0, 0);
ObjectSet( "intrade", OBJPROP_CORNER, 2);
ObjectSet( "intrade", OBJPROP_XDISTANCE,10 );
ObjectSet( "intrade", OBJPROP_YDISTANCE,30 );
ObjectCreate("buyroute",OBJ_LABEL, 0, 0, 0);
ObjectSet( "buyroute", OBJPROP_CORNER, 2);
ObjectSet( "buyroute", OBJPROP_XDISTANCE,10 );
ObjectSet( "buyroute", OBJPROP_YDISTANCE,50 );
ObjectCreate("tradestoday",OBJ_LABEL, 0, 0, 0);
ObjectSet( "tradestoday", OBJPROP_CORNER, 2);
ObjectSet( "tradestoday", OBJPROP_XDISTANCE,10 );
ObjectSet( "tradestoday", OBJPROP_YDISTANCE,70 );
ObjectCreate("timenow",OBJ_LABEL, 0, 0, 0);
ObjectSet( "timenow", OBJPROP_CORNER, 2);
ObjectSet( "timenow", OBJPROP_XDISTANCE,10 );
ObjectSet( "timenow", OBJPROP_YDISTANCE,90 );
//-------------------------------------------------
//ObjectCreate("finishedfortheday",OBJ_LABEL, 0, 0, 0);
//ObjectSet( "finishedfortheday", OBJPROP_CORNER, 2);
//ObjectSet( "finishedfortheday", OBJPROP_XDISTANCE,10 );
//ObjectSet( "finishedfortheday", OBJPROP_YDISTANCE,110 );
}
//---------------------------
// END
//---------------------------