-
Notifications
You must be signed in to change notification settings - Fork 2
/
NO34.mq4
200 lines (188 loc) · 16 KB
/
NO34.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
#property copyright "Nematillo Ochilov MQL4"
#property link "https://t.me/MQLUZ"
extern bool buy=true;
//extern double Lots=1;
//extern double TakeProfit1=50;
//extern double TakeProfit2=60;
////extern double TakeProfit3=50;
////extern double TakeProfit4=50;
////extern double TakeProfit5=50;
////extern double TakeProfit6=50;
////extern double TakeProfit7=50;
////extern double TakeProfit8=50;
//extern double StopLoss1=70;
//extern double StopLoss2=80;
////extern double StopLoss3=70;
////extern double StopLoss4=70;
////extern double StopLoss5=70;
////extern double StopLoss6=70;
////extern double StopLoss7=70;
////extern double StopLoss8=70;
string _Profit() {
double BuyProfit = 0, SellProfit = 0;
for(int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol()) {
if (OrderType() == OP_BUY) {
BuyProfit = +OrderProfit();
}
if (OrderType() == OP_SELL) {
SellProfit += OrderProfit();
}
}
}
}
string None = "Savdo mavjud emas";
string matn = " Buy foyda: " + DoubleToString(BuyProfit) + " Sell foyda: " + DoubleToString(SellProfit) +
" Jami: " + DoubleToString(BuyProfit + SellProfit);
if (BuyProfit != 0 || 0 != SellProfit) {
return (matn);
}
else{
return (None);
}
}
void satr(string _name, string text, uint x, uint y, color rang) {
long chart_ID = ChartID();
ObjectCreate(chart_ID,_name,OBJ_LABEL,0,0,0);
ObjectSetInteger(chart_ID,_name,OBJPROP_COLOR,rang);
ObjectSetString(chart_ID,_name,OBJPROP_TEXT,text);
ObjectSet(chart_ID,OBJPROP_XDISTANCE,x);
ObjectSet(chart_ID,OBJPROP_YDISTANCE,y);
ChartRedraw(chart_ID);
}
double Lots() {double b = AccountBalance(), l = 100000, r=b/l;
if (AccountBalance()<1000) r=0.01;
return(r);}
void osb (double _Lots, double _BSL, double _BTP, int _Magic) {
string strmagic = IntegerToString(_Magic);
if (!OrderSend(Symbol(), OP_BUY, _Lots, Ask, 10, _BSL, _BTP, "Shamdon turi: " + strmagic, _Magic, 0, Blue))
Print("OrderSend Buy " + strmagic + "-da muammo: ", GetLastError());
}
void oss (double _Lots, double _SSL, double _STP, int _Magic) {
string strmagic = IntegerToString(_Magic);
if (!OrderSend(Symbol(), OP_SELL, _Lots, Bid, 10, _SSL, _STP, "Shamdon turi: " + strmagic, _Magic, 0, Red))
Print("OrderSend Sell " + strmagic + "-da muammo: ", GetLastError());
}
int ocb(int _Magic) {
for (int cb = OrdersTotal(); cb >= 0; cb--) {
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES) == true) {
if (OrderType() == OP_BUY && OrderMagicNumber() == _Magic) {
if (!OrderClose(OrderTicket(),OrderLots(),Bid,10,Blue))
Print("OrderClose OP_BUYda muammo: ", GetLastError());
return(0);
}
}
}
return(_Magic);
}
int ocs(int _Magic) {Print(OrderMagicNumber()); Print("i" + IntegerToString(_Magic));
for (int cb = OrdersTotal(); cb >= 0; cb--) {
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES) == true) {
if (OrderType() == OP_SELL && OrderMagicNumber() == _Magic) {
if (!OrderClose(OrderTicket(),OrderLots(),Ask,10,Red))
Print("OrderClose OP_SELLda muammo: ", GetLastError());
return(0);
}
}
}
return(_Magic);
}
void omb(int _Magic) {
for (int cb = OrdersTotal(); cb >= 0; cb--) {
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES) == true) {
if (OrderType() == OP_BUY && OrderMagicNumber() == _Magic) {
if (OrderStopLoss() < OrderOpenPrice()) {
if (OrderOpenPrice() + 300 * Point < Ask) {
if (!OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() + 100 * Point,
OrderTakeProfit(), 0, Yellow))
Print("OrderModify OP_BUY START" + IntegerToString(_Magic) + "-da muammo: ", GetLastError());
}
}
}
}
}
}
void oms(int _Magic) {
for (int cb = OrdersTotal(); cb >= 0; cb--) {
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES) == true) {
if (OrderType() == OP_SELL && OrderMagicNumber() == _Magic) {
if (OrderStopLoss() > OrderOpenPrice()) {
if (OrderOpenPrice() - 300 * Point > Bid) {
if (!OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice() - 100 * Point,
OrderTakeProfit(), 0, Yellow))
Print("OrderModify OP_SELL START" + IntegerToString(_Magic) + "-da muammo: ", GetLastError());
}
}
}
}
}
}
int T_P(double OTP) {
double ret;
//Print("ret " + DoubleToString(OTP));
if (OTP < 0.0055) ret = 700;
else if (OTP > 0.0055) ret = 800;
//Print("ret " + DoubleToString(ret));
return (ret);
}
int a = 0;
int start() {
double Lot = 1; //AccountBalance() / 20000;
double RSI =iRSI(NULL,0,14,PRICE_CLOSE,0);
double MACD244 =iMACD(NULL,0,244,304,9,PRICE_OPEN,MODE_MAIN,0);
double MACD244100 =iMACD(NULL,0,244,304,9,PRICE_OPEN,MODE_MAIN,100);
double MACD =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
double MACDS =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
double MACD1 =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
double MACDS1 =iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
double Price = MarketInfo(Symbol(),MODE_ASK);
// satr("0", DoubleToString(MACD), 250, 50, clrWhite);
if (OrdersTotal() == 1 && _Profit() < 0) {
for (int cb = OrdersTotal(); cb >= 0; cb--) {
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES) == true) {
double Lots = OrderLots() * 1.33;
satr("0", IntegerToString(a), 250, 50, clrWhite);
if (OrderType() == OP_SELL) {int TP = 500;
int SL = T_P(OrderOpenPrice() - OrderTakeProfit()) ;
if (SL == 800) TP = 600;}
//satr("0", DoubleToString(OrderOpenPrice() - Price), 250, 50, clrWhite);}
if (Price - OrderOpenPrice() > 0.002) {
ocs(OrderMagicNumber());
osb(Lots, Ask - SL * Point, Ask + TP * Point, 0);
a += 1;
}
else if (OrderOpenPrice() - Price > 0.0045) {a = 0;
}
else if (OrderType() == OP_BUY) {int _TP = 500;
double _SL = T_P(OrderTakeProfit() - OrderOpenPrice());
if (_SL == 800) _TP = 600;}
if (OrderOpenPrice() - Price > 0.002) {
ocb(OrderMagicNumber());
oss(Lots, Bid + _SL * Point, Bid - _TP * Point, 0);
a += 1;
}
else if (Price - OrderOpenPrice() > 0.0045) {a = 0;
}
}
}
}
else if (OrdersTotal() < 1) {// && a == 0
if (MACD244 > 0) {
if (MACD244100 - MACD244 > 0.0005) {oss(Lot, Bid + 300 * Point, Bid - 500 * Point, 0); a = 1;}
}
if (MACD244 < 0) {
if (MACD244 - MACD244100 > 0.0005) {osb(Lot, Ask - 300 * Point, Ask + 500 * Point, 0); a = 1;}
}
}
// else if (OrdersTotal() < 1) {// && a == 0
// if (RSI > 70 && (MACDS1 < MACD1 && MACDS > MACD)) {
// oss(Lot, Bid + 300 * Point, Bid - 500 * Point, 0); a = 1;
// }
// else if (RSI < 30 && (MACDS1 > MACD1 && MACDS < MACD)) {
// osb(Lot, Ask - 300 * Point, Ask + 500 * Point, 0); a = 1;
// }
// }
return(0);
}