forked from NematilloOchilov/NOMQL4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NO13_1.mq4
174 lines (169 loc) · 19.6 KB
/
NO13_1.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
//+--------------------------------------------------------------------------------------------------+
//| NO13_1.mq4 |
//| Strategiya muallifi: .... |
//| Dasturchi: Nematillo Ochilov |
//+--------------------------------------------------------------------------------------------------+
#property copyright "Nematillo Ochilov MQL4"// |
#property link "https://t.me/MQLUZ"// |
//+--------------------------------------------------------------------------------------------------+
//| Tashqi sozlamalar |
//+--------------------------------------------------------------------------------------------------+
extern double Lots = 0.01;// Savdo hajmi
extern int Slippage=10;// Oraliq farq (spreed) o'zgarishi |
extern int MA=1000;// Moving Average Period |
extern int Savdo_Orasi=100;// Savdolar orqasidagi qadamlar |
extern int Savdo_Soni=30;//
//+--------------------------------------------------------------------------------------------------+
//| Ochiq savdo miqdorlarini aniqlash funksiyalari |
//+--------------------------------------------------------------------------------------------------+
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);
}
}
int Count_Stop() {
int u = 0;
for(int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES ) == true) {
if ((OrderType() == OP_BUYLIMIT) || (OrderType() == OP_SELLLIMIT)) {u = 1; break;}
}
}
return(u);}
void satr(string _name, string text, uint x, uint y, color rang){
long chart_ID = ChartID();
//string _name = IntegerToString(chart_ID);
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);
Sleep(600);
}
//+------------------------------------------------------------------------------------------------------+
int start()// |
{// |
//+--------------------------------------------------------------------------------------------------+
//| Ichki sozlamalar |
//+--------------------------------------------------------------------------------------------------+
//| Texnik ko'rsatgichlar sozlamasi |
//+--------------------------------------------------------------------------------------------------+
double SMA=iMA(NULL,0,MA,0,0,0,0); // |
double SMA1=iMA(NULL,0,MA,0,0,0,1); // |
double narx=MarketInfo(Symbol(),MODE_BID); //iMA(NULL,0,1,0,0,0,0);
double Lot = Lots;
//+--------------------------------------------------------------------------------------------------+
//| Sotish yoki sotib olishni aniqlash qismi |
//+--------------------------------------------------------------------------------------------------+
//Print(_Profit());
//satr("0", _Profit(), 250, 50, clrGreen);
if (0 < OrdersTotal()) {
if (Count_Stop() == 0) {
Lot = 0.05;
if ((OrderType() == OP_BUY)) {
for (int OSSL2 = Savdo_Orasi, c2 = 1; OSSL2 < Savdo_Orasi * Savdo_Soni * 3; OSSL2 += Savdo_Orasi, c2++)
{
if (c2 % 2 == 0)
Lot = Lot + 0.05;
if (!OrderSend(Symbol(), OP_BUYLIMIT, Lot, Bid - OSSL2 * Point, Slippage,
Bid - OSSL2 * Point + StopLoss * Point,
Bid - OSSL2 * Point - TakeProfit * Point,
"NO savdo ", c2, 0, Red))
Print("OrderSend OP_BUYSTOPda muammo: ", GetLastError());
}
}
else if (OrderType() == OP_SELL) {
for (int OSBL2 = Savdo_Orasi, s2 = 1; OSBL2 < Savdo_Orasi * Savdo_Soni * 3; OSBL2 += Savdo_Orasi, s2++)
{
if (s2 % 2 == 0)
Lot = Lot + 0.05;
if (!OrderSend(Symbol(), OP_SELLLIMIT, Lot, Ask + OSBL2 * Point, Slippage,
Ask + OSBL2 * Point - StopLoss * Point,
Ask + OSBL2 * Point + TakeProfit * Point, "NO savdo ", s2, 0, Aqua))
Print("OrderSend OP_SELLSTOPda muammo: ", GetLastError());
}
}
}
if ((SMA + 10 * Point > narx && narx > SMA - 10 * Point) || (SMA - 10 * Point > narx && narx > SMA + 10 * Point)){
for (int cb = OrdersTotal(); cb >= 0; cb--){
if (OrderSelect(cb, SELECT_BY_POS, MODE_TRADES ) == true){
if (OrderType() == OP_BUY){
if (!OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue))
Print("OrderClose OP_BUYda muammo: ", GetLastError());
}
if (OrderType() == OP_BUYLIMIT){
if (!OrderDelete(OrderTicket()))
Print("OrderClose OP_BUYLIMITda muammo: ", GetLastError());
}
if (OrderType() == OP_SELL){
if (!OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red))
Print("OrderClose OP_SELLda muammo: ", GetLastError());
}
if (OrderType() == OP_SELLLIMIT){
if (!OrderDelete(OrderTicket()))
Print("OrderClose OP_SELLLIMITda muammo: ", GetLastError());
}
}
}
}
return(0);}
//+--------------------------------------------------------------------------------------------------+
//| Sotish yoki sotib olish |
//+--------------------------------------------------------------------------------------------------+
else if (1 > OrdersTotal()){
if ((SMA + 90 * Point < narx) && (SMA + 110 * Point > narx)){
if (!OrderSend(Symbol(), OP_SELL, Lot, Bid, Slippage, 0, 0,
"NO savdo ", 0, 0, Red))
Print("OrderSend SELLda muammo: ", GetLastError());
}
if (OrdersTotal() == 1){
for (int OSSL = Savdo_Orasi, c = 0; OSSL < Savdo_Orasi * Savdo_Soni; OSSL += Savdo_Orasi, c++)
{
if (c % 3 == 0)
Lot = Lot + 0.01;
if (!OrderSend(Symbol(), OP_SELLLIMIT, Lot, Bid + OSSL * Point, Slippage,
0, 0,"NO savdo ", c, 0, Red))
Print("OrderSend SELLLIMITda muammo: ", GetLastError());
}
}
else if ((SMA - 90 * Point > narx) && (SMA - 110 - Point < narx)){
if (!OrderSend(Symbol(), OP_BUY, Lot, Ask, Slippage, 0, 0,
"NO savdo ", 0, 0, Aqua))
Print("OrderSend BUYda muammo: ", GetLastError());//
}
if (OrdersTotal() == 1){
for (int OSBL = Savdo_Orasi, s = 0; OSBL < Savdo_Orasi * Savdo_Soni; OSBL += Savdo_Orasi, s++)
{
if (s % 3 == 0)
Lot = Lot + 0.01;
if (!OrderSend(Symbol(), OP_BUYLIMIT, Lot, Ask - OSBL * Point, Slippage,
0, 0, "NO savdo ", s, 0, Aqua))
Print("OrderSend BUYLIMITda muammo: ", GetLastError());
}
return(0);}
return(0);}
return(0);}
// for (int cb = OrdersTotal(); cb >= 0; cb--){
//for(int i=0;i<OrdersTotal();i++)
//+--------------------------------------------------------------------------------------------------+
//| Tugadi |
//+--------------------------------------------------------------------------------------------------+