-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path015 Labouchere.mq4
76 lines (66 loc) · 4.49 KB
/
015 Labouchere.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
extern double Lots=0.01;
double gad[50];
int start(){
bool lC;
for(char i=OrdersTotal()-1;i>=0;i--){ //SKIP if have existing trade
lC=OrderSelect(i,0); if(OrderSymbol()==Symbol()&&OrderMagicNumber()==0)return 0; }
double firstNum,lastNum,lS=20*Point,lT=30*Point,lD=0,betSize;
for(i=OrdersHistoryTotal()-1;i>=0;i--){
lC=OrderSelect(i,0,1);
if(OrderSymbol()==Symbol()&&OrderMagicNumber()==0)
if(OrderProfit()<0){ //[LOSE] adding in the array
for(i=ArraySize(gad)-1;i!=0;i--){
if(gad[i]!=0){
gad[i+1]=OrderLots();
break;
}
}
lD=OrderType()==0?1:0;
}else{ //[WIN] removing first and last array
for(i=0;i<ArraySize(gad);i++){
if(gad[i]>0){
gad[i]=0;
break;
}
}
for(i=ArraySize(gad)-1;i!=0;i--){
if(gad[i]>0){
gad[i]=0;
break;
}
}
lD=OrderType();
}
break;
}
for(i=0;i<ArraySize(gad);i++){
if(gad[i]>0){
firstNum=gad[i];
break;
}
}
for(i=ArraySize(gad)-1;i!=0;i--){
if(gad[i]>0){
lastNum=gad[i];
break;
}
}
if(firstNum==0){ //ran out of array
gad[0]=0.01;
gad[1]=0.02;
gad[2]=0.03;
firstNum=gad[0];
lastNum=gad[2];
}
if(firstNum==lastNum)betSize=firstNum+0.01; //bet size
else betSize=firstNum+lastNum; //use first and last num
string p;
for(i=0;i<ArraySize(gad);i++)StringAdd(p,gad[i]+",");
Print(p);
if(lD==0)lC=OrderSend(Symbol(),0,betSize,Ask,5,Ask-lS,Ask+lT);
else lC=OrderSend(Symbol(),1,betSize,Bid,5,Bid+lS,Bid-lT);
return 0;
}
/************** TO DO **************
Shift back the array if there is 0 infront
*/