-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
wpr.mq4
200 lines (160 loc) · 4.68 KB
/
wpr.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
//+------------------------------------------------------------------+
//| wpr.mq4 |
//| Eng. Ahmad Lutfi |
//| https://www.lutfipro.com |
//+------------------------------------------------------------------+
#property copyright "Eng. Ahmad Lutfi"
#property link "https://www.lutfipro.com"
#property version "1.00"
#property strict
extern double lots=1.0;
int Slippage=10;
bool IsTrading;
int ticket = -1, BuyCount,SellCount;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
string BoolToStr(bool bval) {
//+------------------------------------------------------------------+
// Converts the boolean value true or false to the string "true" or "false"
if (bval) return("true");
return("false");
}
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
static double y1 = 0;
static double m1 = 0;
static double y2 = 0;
static double m2 = 0;
if(IsNewCandle())
{
//do everything here!
//1.test wpr values now and before!
double X = iWPR(Symbol(),PERIOD_CURRENT,14,2);
double Xfin = iWPR(Symbol(),PERIOD_CURRENT,14,1);
if(OrdersTotal()==0)
{
//check if open buy was hit
if(CheckOpenBuy())
{
}
//check if open sell
if(CheckOpenSell())
{
//open sell order!
}
}
if(OrdersTotal>0 && OrdersTotal<=1) //if there's already an open Order
{
if( OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
//TODO:check for a trend change Here..
if(OrderType()==OP_BUY)
{
//check if open sell to close Buys!
if(CheckOpenSell())
{
//open sell order!
}
}
if(OrderType()==OP_SELL)
{
//check if open buy to close Sells!
if(CheckOpenBuy())
{
}
}
}
}
}
}
//+------------------------------------------------------------------+
void handleOpenOrder()
{
bool Isbuy = EMPTY_VALUE;
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
if(OrderType == OP_BUY)
{
//check
}
if(OrderType ==OP_SELL)
{
}
}
}
bool CheckOpenBuy()
{
bool flag = false;
if((X > -100 && X<-80) &&
( Xfin >-80))//Xfin > -50 &&
{
flag = true;
}
return flag;
}
bool CheckOpenSell()
{
bool flag = false;
if((X > -20 && X<0) &&
( Xfin <-20))//Xfin > -50 &&
{
flag = true;
}
return flag;
}
bool IsNewCandle()
{
static int BarsOnChart=0;
if (Bars == BarsOnChart)
return (false);
BarsOnChart = Bars;
return(true);
}
//+------------------------------------------------------------------+
//Trend Functions:
double Calc_m(double y2, double y1)
{
double m = (y2-y1)*(-1);
return m;
}
double Calc_Theta(double m1, double m2)
{
double Th1 = atan(m1);
double Th2 = atan(m2);
double Th = MathAbs(Th1 - Th2);
return Th;
}
void TrendBuyClose()
{
//1.select Order
if(response) //Order is Selected!
{
if(y2 != iWPR(Symbol(),PERIOD_CURRENT,14,1)) //check iwpr point has changed! {
y1 = y2;
y2= iWPR(Symbol(),PERIOD_CURRENT,14,1);
m2 = Calc_m(y2,y1);
//Compute 'n' Evaluate...
//-----------------------
double resultat = m1 * m2;
Print("m1= "+ DoubleToStr( m1,2) +" m2= "+DoubleToStr(m2,2) + " &Resultant is: "+DoubleToStr(resultat,2));
if(resultat <0)
{
}