-
Notifications
You must be signed in to change notification settings - Fork 2
/
NO13_1.mq4
136 lines (132 loc) · 15.7 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
//+--------------------------------------------------------------------------------------------------+
//| 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);
}
double OOP;
//+------------------------------------------------------------------------------------------------------+
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 ((SMA < narx) && (OOP + 200 * Point > narx)) {
int ticket_b = OrderSend(Symbol(), OP_BUYSTOP, Lot, OOP, Slippage, 0, 0, "NO savdo ", 0, 0, Aqua);
if (ticket_b < 0) {Print("OrderSend BUYda muammo: ", GetLastError());}
else {OOP = Bid + 100 * Point;}
}
else if ((SMA > narx) && (OOP - 200 * Point < narx)) {
int ticket_s = OrderSend(Symbol(), OP_SELLSTOP, Lot, OOP, Slippage, 0, 0, "NO savdo ", 0, 0, Red);
if (ticket_s < 0) {Print("OrderSend BUYda muammo: ", GetLastError());}
else {OOP = Ask + 100 * Point;}
}
else 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 - 290 * Point > narx) && (SMA - 310 - Point < narx)){
OOP = Ask + 100 * Point;
if (!OrderSend(Symbol(), OP_BUYSTOP, Lot, OOP, Slippage, 0, 0, "NO savdo ", 77777, 0, Aqua))
Print("OrderSend BUYda muammo: ", GetLastError());
}
else if ((SMA + 290 * Point < narx) && (SMA + 310 * Point > narx)){
OOP = Bid - 100 * Point;
if (!OrderSend(Symbol(), OP_SELLSTOP, Lot, OOP, Slippage, 0, 0, "NO savdo ", 77777, 0, Red))
Print("OrderSend SELLda muammo: ", GetLastError());
}
}
return(0);}
//+--------------------------------------------------------------------------------------------------+
//| Tugadi |
//+--------------------------------------------------------------------------------------------------+