-
Notifications
You must be signed in to change notification settings - Fork 2
/
Final.mql4
77 lines (67 loc) · 1.94 KB
/
Final.mql4
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
extern double lots=0.01;
extern double target=0.4;
int cbars=0;
int magic=9348670;
int dist=24;
int start() {
double profit=0;
int j=OrdersTotal()-1;
for (int i=j;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderMagicNumber()==magic && OrderSymbol()==Symbol())
profit=OrderProfit()+OrderSwap()+profit;
}
if (profit>=target)
{
j=OrdersTotal()-1;
for (i=j;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
RefreshRates();
if(OrderType()==OP_BUY && OrderMagicNumber()==magic && OrderSymbol()==Symbol())
OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
}
}
double sig = Lowest(NULL,0,MODE_LOW,dist,0);
if(cbars!=Bars && sig==1)
{
RefreshRates();
OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"buy",magic,0,Blue);
string AN="ArrBuy "+TimeToStr(CurTime());
ObjectCreate(AN,OBJ_ARROW,0,Time[1],Low[1]-6*Point,0,0,0,0);
ObjectSet(AN, OBJPROP_ARROWCODE, 233);
ObjectSet(AN, OBJPROP_COLOR , Blue);
}
profit=0;
j=OrdersTotal()-1;
for (i=j;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==Symbol())
profit=OrderProfit()+OrderSwap()+profit;
}
if (profit>=target)
{
j=OrdersTotal()-1;
for (i=j;i>=0;i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
RefreshRates();
if(OrderType()==OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==Symbol())
OrderClose(OrderTicket(),OrderLots(),Ask,3,Magenta);
}
}
sig = Highest(NULL,0,MODE_HIGH,dist,0);
if(cbars!=Bars && sig==1)
{
RefreshRates();
OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,0,"sell",magic,0,Magenta);
AN="ArrSell "+TimeToStr(CurTime());
ObjectCreate(AN,OBJ_ARROW,0,Time[1],High[1]+6*Point,0,0,0,0);
ObjectSet(AN, OBJPROP_ARROWCODE, 234);
ObjectSet(AN, OBJPROP_COLOR , Magenta);
}
cbars=Bars;
return(0);
}