-
Notifications
You must be signed in to change notification settings - Fork 1
/
10PipsPro.mq4
158 lines (154 loc) · 7.01 KB
/
10PipsPro.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
/*
Generated by EX4-TO-MQ4 decompiler ONE FILE V4.0.218.3
EX4 ID : 04E20A41724C2645BAEB3FDF008C44EC
Website: http://purebeam.biz
E-mail : [email protected]
*/
#property copyright "Expert Advisor Builder"
#property link "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"
extern int MagicNumber = 0;
extern bool SignalMail = FALSE;
extern bool EachTickMode = FALSE;
extern double Lots = 1.0;
extern int Slippage = 3;
extern bool UseStopLoss = TRUE;
extern int StopLoss = 300;
extern bool UseTakeProfit = TRUE;
extern int TakeProfit = 10;
extern bool UseTrailingStop = FALSE;
extern int TrailingStop = 30;
extern bool UseMM = TRUE;
extern double Risk = 30.0;
int g_bars_136;
int gi_140;
bool gi_144 = FALSE;
int init() {
g_bars_136 = Bars;
if (EachTickMode) gi_140 = 0;
else gi_140 = 1;
return (0);
}
int deinit() {
return (0);
}
int start() {
int l_ticket_8;
double l_price_12;
double l_price_20;
int li_0 = 0;
string ls_28 = "2015.08.30";
int l_str2time_36 = StrToTime(ls_28);
if (TimeCurrent() >= l_str2time_36) {
Alert("The version has been expired!");
return (0);
}
bool l_bool_40 = IsDemo();
if (!l_bool_40) {
Alert("You can not use 10PipsPro EA with a real account!");
return (0);
}
if (UseMM == TRUE) {
Lots = AccountEquity() * Risk / StopLoss / 1000.0;
if (Lots > 0.1) Lots = NormalizeDouble(Lots, 1);
else Lots = NormalizeDouble(Lots, 2);
}
if (EachTickMode && Bars != g_bars_136) gi_144 = FALSE;
int l_ord_total_4 = OrdersTotal();
li_0 = 0;
double l_istochastic_44 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0);
double l_istochastic_52 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0);
double l_istochastic_60 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0);
double l_istochastic_68 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0);
double l_istochastic_76 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0);
double l_istochastic_84 = iStochastic(NULL, PERIOD_M15, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0);
double l_istochastic_92 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_140 + 0);
double l_istochastic_100 = iStochastic(NULL, PERIOD_H1, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, gi_140 + 0);
bool li_108 = FALSE;
for (int l_pos_112 = 0; l_pos_112 < l_ord_total_4; l_pos_112++) {
OrderSelect(l_pos_112, SELECT_BY_POS, MODE_TRADES);
if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
li_108 = TRUE;
if (OrderType() == OP_BUY) {
if (li_0 == 3 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) g_bars_136 = Bars;
li_108 = FALSE;
} else {
if (UseTrailingStop && TrailingStop > 0) {
if (Bid - OrderOpenPrice() > Point * TrailingStop) {
if (OrderStopLoss() < Bid - Point * TrailingStop) {
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
if (!EachTickMode) g_bars_136 = Bars;
}
}
}
}
} else {
if (li_0 == 4 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) {
OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
if (!EachTickMode) g_bars_136 = Bars;
li_108 = FALSE;
} else {
if (UseTrailingStop && TrailingStop > 0) {
if (OrderOpenPrice() - Ask > Point * TrailingStop) {
if (OrderStopLoss() > Ask + Point * TrailingStop || OrderStopLoss() == 0.0) {
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
if (!EachTickMode) g_bars_136 = Bars;
}
}
}
}
}
}
}
if (l_istochastic_44 > l_istochastic_52 && l_istochastic_60 > l_istochastic_68) li_0 = 1;
if (l_istochastic_76 < l_istochastic_84 && l_istochastic_92 < l_istochastic_100) li_0 = 2;
if (li_0 == 1 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) {
if (!li_108) {
if (AccountFreeMargin() < 1000.0 * Lots) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return (0);
}
if (UseStopLoss) l_price_12 = Ask - StopLoss * Point;
else l_price_12 = 0.0;
if (UseTakeProfit) l_price_20 = Ask + TakeProfit * Point;
else l_price_20 = 0.0;
l_ticket_8 = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, l_price_12, l_price_20, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
if (l_ticket_8 > 0) {
if (OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES)) {
Print("BUY order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
} else Print("Error opening BUY order : ", GetLastError());
}
if (EachTickMode) gi_144 = TRUE;
if (!EachTickMode) g_bars_136 = Bars;
return (0);
}
}
if (li_0 == 2 && (EachTickMode && !gi_144) || (!EachTickMode && Bars != g_bars_136)) {
if (!li_108) {
if (AccountFreeMargin() < 1000.0 * Lots) {
Print("We have no money. Free Margin = ", AccountFreeMargin());
return (0);
}
if (UseStopLoss) l_price_12 = Bid + StopLoss * Point;
else l_price_12 = 0.0;
if (UseTakeProfit) l_price_20 = Bid - TakeProfit * Point;
else l_price_20 = 0.0;
l_ticket_8 = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, l_price_12, l_price_20, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
if (l_ticket_8 > 0) {
if (OrderSelect(l_ticket_8, SELECT_BY_TICKET, MODE_TRADES)) {
Print("SELL order opened : ", OrderOpenPrice());
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
} else Print("Error opening SELL order : ", GetLastError());
}
if (EachTickMode) gi_144 = TRUE;
if (!EachTickMode) g_bars_136 = Bars;
return (0);
}
}
if (!EachTickMode) g_bars_136 = Bars;
return (0);
}