forked from NematilloOchilov/NOMQL4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NO12.mq4
224 lines (217 loc) · 11.2 KB
/
NO12.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
//+--------------------------------------------------------------------------------------------------+
//| NO12.mq4 |
//| Strategiya muallifi: Nematillo Ochilov |
//| Dasturchi: Nematillo Ochilov |
//+--------------------------------------------------------------------------------------------------+
#property copyright "Nematillo Ochilov MQL4"// |
#property link "https://t.me/MQLUZ"// |
//+--------------------------------------------------------------------------------------------------+
//| Tashqi sozlamalar |
//+--------------------------------------------------------------------------------------------------+
extern int TakeProfit=30;// Daromadni belgilash |
extern int StopLoss=300;// Zararni cheklash |
extern int Slippage=10;// Oraliq farq (spreed) o'zgarishi |
extern int MA=1200;// Moving Average Period |
extern int RSI=8;// RSI Period |
extern int Step=30;// Savdolar orqasidagi qadamlar |
//+--------------------------------------------------------------------------------------------------+
//| Ochiq savdo miqdorlarini aniqlash funksiyalari |
//+--------------------------------------------------------------------------------------------------+
int Count_Buy()
{
int count_buy_orders = 0;
int oob = 0;
for(int i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false)
return(0);
if (OrderType() == OP_BUY)
count_buy_orders++;
oob++;
if (OrderType() == OP_BUYLIMIT)
count_buy_orders++;
}
int cbo[2];
cbo[0] = count_buy_orders;
cbo[1] = oob;
return(cbo);
}
int Count_Sell()
{
int oos = 0;
int count_sell_orders = 0;
for (int i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false)
return(0);
if (OrderType() == OP_SELL)
count_sell_orders++;
oos++;
if (OrderType() == OP_SELLLIMIT)
count_sell_orders++;
}
int cso[2] = {count_sell_orders, oos};
return (cso);
}
double Lot(double Lots)
{
/*if (Lots == 0.01)
Lots = 0.02;
if (OrdersTotal() > 1)
Lots = 2 * OrderLots();
if (Lots > 10)
Lots = 10;*/
return (0.01);
}
void satr(string text, uint x, uint y, color rang)
{
long chart_ID=0;//ChartID();
string obj_name="Text: "+IntegerToString(y);
if (ObjectsTotal() < 1)
{
if (ObjectCreate(obj_name,OBJ_LABEL,0,0,0))
{
ObjectSetInteger(chart_ID,obj_name,OBJPROP_COLOR,rang);
ObjectSetString(chart_ID,obj_name,OBJPROP_TEXT,text);
ObjectSet(chart_ID,OBJPROP_XDISTANCE,x);
ObjectSet(chart_ID,OBJPROP_YDISTANCE,y);
ChartRedraw(chart_ID);
}
else
{
Print("Error: can't create label! code #",GetLastError());
}
}
else
{
if(!ObjectSetString(chart_ID,obj_name,OBJPROP_TEXT,text))
{
Print(__FUNCTION__, ": failed to change the text! Error code = ",GetLastError());
}
}
}
//+------------------------------------------------------------------------------------------------------+
int start()// |
{// |
//+--------------------------------------------------------------------------------------------------+
//| Ichki sozlamalar |
//+--------------------------------------------------------------------------------------------------+
//| Texnik ko'rsatgichlar sozlamasi |
//+--------------------------------------------------------------------------------------------------+
double RSI0=iRSI(NULL,0,RSI,PRICE_CLOSE,0);// |
double RSI1=iRSI(NULL,0,RSI,PRICE_OPEN,1);// |
double RSI2=iRSI(NULL,0,RSI,PRICE_OPEN,2);// |
bool RSI_BUY_CLOSE = RSI1 > 75;//RSI2 < RSI1 && RSI1 > RSI0 &&
bool RSI_SELL_CLOSE = RSI1 < 25;//RSI2 > RSI1 && RSI1 < RSI0 &&
double SMA=iMA(NULL,0,MA,0,0,0,0); // |
double AC=iAC(NULL,0,2);
double BandsU=iBands(NULL,0,20,2,0,PRICE_OPEN,MODE_UPPER,0);
double BandsL=iBands(NULL,0,20,2,0,PRICE_OPEN,MODE_LOWER,0);
bool Bands = BandsU - BandsL < 0.0025;
//+--------------------------------------------------------------------------------------------------+
//| |
//+--------------------------------------------------------------------------------------------------+
double Lots = 0.01;// Savdo hajmi
double TP = TakeProfit * Point;// Foydani cheklash |
double SL = StopLoss * Point;// Zararni cheklash |
double price=MarketInfo(Symbol(),MODE_BID); // Hozirgi narx
bool OpenBuy = false, OpenSell = false;
int CB = Count_Buy();
int CS = Count_Sell();
//+--------------------------------------------------------------------------------------------------+
//| Sotib olingan tovar haqida ma'lumotlarni saqlash |
//+--------------------------------------------------------------------------------------------------+
//+--------------------------------------------------------------------------------------------------+
//| Sotish yoki sotib olishni aniqlash qismi |
//+--------------------------------------------------------------------------------------------------+
/*satr(
"Ticket: " + IntegerToString(BuyHistory[CB][0]) +
" OpenPrice: " + DoubleToString(BuyHistory[CB][1]) +
" Lots: " + DoubleToString(BuyHistory[CB][2]) +
//" OrderType: " + IntegerToString(BuyHistory[CB][3]) +
//" OrderMagicNumber: " + IntegerToString(BuyHistory[CB][4]) +
//" OrderStopLoss: " + IntegerToString(BuyHistory[CB][5]) +
//" OrderTakeProfit: " + IntegerToString(BuyHistory[CB][6]) +
" Profit: " + DoubleToString(BuyHistory[CB][7]),
250,
1,
clrWhite);*/
if (CB == 0 && 0 == CS)
{
OpenBuy = RSI2 > 79 && RSI1 < 79 && SMA < price && AC < 0.0005;
OpenSell = RSI2 < 21 && RSI1 > 21 && SMA > price && AC > -0.0005;
}
if (CB > 0 && RSI_BUY_CLOSE)//BuyHistory[CB][7] / (BuyHistory[CB][2]*10) > Step / 5 &&
{
for( int cb = 0 ; cb < OrdersTotal() ; cb++ )
{
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES ) == true)
{
if (OrderType() == OP_BUY)
{
if (!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Aqua))
Print("OrderClose da muammo: ", GetLastError());
}
if (OrderType() == OP_BUYLIMIT)
{
if (!OrderDelete(OrderTicket()))
Print("OrderClose da muammo: ", GetLastError());
}
}
}
}
if (CS > 0 && RSI_SELL_CLOSE) //SellHistory[CS][7] / (SellHistory[CS][2]*10) > Step / 5 &&
{
for( int cs = 0 ; cs < OrdersTotal() ; cs++ )
{
if (OrderSelect(cs, SELECT_BY_POS, MODE_TRADES ) == true)
{
if (OrderType() == OP_SELL)
{
if (!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Aqua))
Print("OrderClose da muammo: ", GetLastError());
}
if (OrderType() == OP_SELLLIMIT)
{
if (!OrderDelete(OrderTicket()))
Print("OrderClose da muammo: ", GetLastError());
}
}
}
}
//+--------------------------------------------------------------------------------------------------+
//| Sotish yoki sotib olish |
//+--------------------------------------------------------------------------------------------------+
if (OpenBuy)
{
if (!OrderSend(Symbol(), OP_BUY, Lot(Lots), Ask, Slippage, Ask - SL, Ask + TP, "NO savdo ", 0, 0, Blue))
Print("OrderSend BUYda muammo: ", GetLastError());//
}
if (OrdersTotal() == 1)
{
for (int OSBL = 30; OSBL < 300; OSBL += 30)
{Lots *= 2;
if (!OrderSend(Symbol(), OP_BUYLIMIT, Lots, Ask - OSBL * Point, Slippage,
Ask - (StopLoss + OSBL) * Point, Ask - (OSBL - TakeProfit) * Point, "NO savdo ", 0, 0, Blue))
Print("OrderSend BUYLIMITda muammo: ", GetLastError());//
}
}
if (OpenSell)
{
if (!OrderSend(Symbol(), OP_SELL, Lot(Lots), Bid, Slippage, Bid + SL, Bid - TP,"NO savdo ", 0, 0, Red))
Print("OrderSend SELLda muammo: ", GetLastError());//
}
if (OrdersTotal() == 1)
{
for (int OSSL = 30; OSSL < 300; OSSL += 30)
{Lots *= 2;
if (!OrderSend(Symbol(), OP_SELLLIMIT, Lots, Bid + OSSL * Point, Slippage,
Bid + (StopLoss + OSSL) * Point, Bid + (OSSL - TakeProfit) * Point, "NO savdo ", 0, 0, Red))
Print("OrderSend SELLLIMITda muammo: ", GetLastError());//
}
}
return(0);// |
}// |
//+--------------------------------------------------------------------------------------------------+
//| Tugadi |
//+--------------------------------------------------------------------------------------------------+