|
|
@@ -24,6 +24,8 @@ int index_of_low = 0;
|
|
24
|
24
|
int index_of_high = 0;
|
|
25
|
25
|
int high_index=0;
|
|
26
|
26
|
double high,low,low1,high1;
|
|
|
27
|
+
|
|
|
28
|
+bool choch = false;
|
|
27
|
29
|
//+------------------------------------------------------------------+
|
|
28
|
30
|
//| Expert initialization function |
|
|
29
|
31
|
//+------------------------------------------------------------------+
|
|
|
@@ -109,28 +111,52 @@ void foo(int index)
|
|
109
|
111
|
{
|
|
110
|
112
|
// print("hi");
|
|
111
|
113
|
double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
114
|
+ double low3 = iLow(Symbol(),PERIOD_CURRENT,l);
|
|
112
|
115
|
|
|
113
|
116
|
if(close < low)
|
|
114
|
117
|
{
|
|
115
|
118
|
double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
116
|
|
- double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
117
|
|
- double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
118
|
|
- ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
|
119
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
120
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
121
|
+ //ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
119
|
122
|
trend = "downtrend";
|
|
120
|
123
|
Print("choch");
|
|
121
|
124
|
index_of_last_high = i;
|
|
122
|
125
|
Print("close", close);
|
|
|
126
|
+ choch = true;
|
|
|
127
|
+ break;
|
|
|
128
|
+
|
|
|
129
|
+ }
|
|
|
130
|
+ if(low3 < low)
|
|
|
131
|
+ {
|
|
|
132
|
+ double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
133
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
134
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
135
|
+ //ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
|
|
|
136
|
+ trend = "downtrend";
|
|
|
137
|
+ Print("choch in condition 3");
|
|
|
138
|
+ index_of_last_high = i;
|
|
|
139
|
+ Print("close", close);
|
|
|
140
|
+ choch = true;
|
|
123
|
141
|
break;
|
|
124
|
142
|
|
|
125
|
143
|
}
|
|
126
|
144
|
|
|
127
|
145
|
}
|
|
128
|
|
- Print("index of last updated high is : ",index_of_last_high);
|
|
129
|
|
- hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
130
|
|
- lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
146
|
+ if(choch == true)
|
|
|
147
|
+ {
|
|
|
148
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
149
|
+ lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
|
|
|
150
|
+
|
|
|
151
|
+ Print(" buy and sell high index is ",index_of_last_high+1);
|
|
|
152
|
+ Print(" high price is ", hi);
|
|
|
153
|
+ Print(" low price is ", lo);
|
|
|
154
|
+
|
|
|
155
|
+ hi = 0.0;
|
|
|
156
|
+ lo =0.0;
|
|
|
157
|
+ choch = false;
|
|
|
158
|
+ }
|
|
131
|
159
|
|
|
132
|
|
- Print("hy",hi, "index is : ",index_of_last_high+1);
|
|
133
|
|
- Print("ho",lo);
|
|
134
|
160
|
|
|
135
|
161
|
index = i;
|
|
136
|
162
|
|
|
|
@@ -197,7 +223,7 @@ void foo(int index)
|
|
197
|
223
|
{
|
|
198
|
224
|
|
|
199
|
225
|
high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
|
|
200
|
|
- if(high1 > high)
|
|
|
226
|
+ if(high1 >= high)
|
|
201
|
227
|
{
|
|
202
|
228
|
//Print("here");
|
|
203
|
229
|
high = high1;
|
|
|
@@ -218,28 +244,64 @@ void foo(int index)
|
|
218
|
244
|
{
|
|
219
|
245
|
// print("hi");
|
|
220
|
246
|
double close = iClose(Symbol(),PERIOD_CURRENT,l);
|
|
|
247
|
+ double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
|
248
|
+
|
|
221
|
249
|
if(close > high)
|
|
222
|
250
|
{
|
|
223
|
251
|
|
|
224
|
252
|
double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
225
|
|
- double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
226
|
|
- double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
227
|
|
- bool a = ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
228
|
|
- Print("object created : ", a);
|
|
|
253
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
254
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
255
|
+ //ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
256
|
+
|
|
229
|
257
|
|
|
230
|
258
|
trend = "uptrend";
|
|
231
|
259
|
Print("choch");
|
|
232
|
260
|
Print(l);
|
|
233
|
261
|
index_of_last_low = i;
|
|
234
|
262
|
Print("close", close);
|
|
|
263
|
+ choch = true;
|
|
235
|
264
|
break;
|
|
236
|
265
|
|
|
237
|
266
|
}
|
|
238
|
267
|
|
|
|
268
|
+ if(high3 > high)
|
|
|
269
|
+ {
|
|
|
270
|
+
|
|
|
271
|
+ double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
272
|
+ datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
|
|
|
273
|
+ datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
|
|
|
274
|
+ // ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
|
|
|
275
|
+
|
|
|
276
|
+
|
|
|
277
|
+ trend = "uptrend";
|
|
|
278
|
+ Print("choch in condition 3");
|
|
|
279
|
+ Print(l);
|
|
|
280
|
+ index_of_last_low = i;
|
|
|
281
|
+ Print("close", close);
|
|
|
282
|
+ choch = true;
|
|
|
283
|
+ break;
|
|
|
284
|
+
|
|
|
285
|
+ }
|
|
|
286
|
+
|
|
|
287
|
+
|
|
|
288
|
+
|
|
|
289
|
+
|
|
239
|
290
|
}
|
|
240
|
|
- hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
241
|
|
- lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
291
|
+ if(choch == true)
|
|
|
292
|
+ {
|
|
|
293
|
+
|
|
|
294
|
+ hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
295
|
+ lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
|
|
|
296
|
+
|
|
|
297
|
+ Print(" buy and sell high index is ",index_of_last_low+1);
|
|
|
298
|
+ Print(" high price is ", hi);
|
|
|
299
|
+ Print(" low price is ", lo);
|
|
242
|
300
|
|
|
|
301
|
+ hi = 0.0;
|
|
|
302
|
+ lo =0.0;
|
|
|
303
|
+ choch = false;
|
|
|
304
|
+ }
|
|
243
|
305
|
index = i;
|
|
244
|
306
|
|
|
245
|
307
|
}
|
|
|
@@ -266,10 +328,10 @@ int OnInit()
|
|
266
|
328
|
|
|
267
|
329
|
datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
268
|
330
|
|
|
269
|
|
- Print("line time: ",time_of_candle);
|
|
|
331
|
+ // Print("line time: ",time_of_candle);
|
|
270
|
332
|
int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
|
|
271
|
|
- Print(index);
|
|
272
|
|
- Print(index);
|
|
|
333
|
+ //Print(index);
|
|
|
334
|
+ // Print(index);
|
|
273
|
335
|
|
|
274
|
336
|
// datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
|
|
275
|
337
|
// Print("time is " , time_of_candle);
|
|
|
@@ -285,8 +347,6 @@ int OnInit()
|
|
285
|
347
|
Print("Object Not Found");
|
|
286
|
348
|
}
|
|
287
|
349
|
|
|
288
|
|
-
|
|
289
|
|
-
|
|
290
|
350
|
return(INIT_SUCCEEDED);
|
|
291
|
351
|
}
|
|
292
|
352
|
//+------------------------------------------------------------------+
|
|
|
@@ -312,7 +372,6 @@ void OnTick()
|
|
312
|
372
|
|
|
313
|
373
|
}
|
|
314
|
374
|
|
|
315
|
|
-
|
|
316
|
375
|
//+------------------------------------------------------------------+
|
|
317
|
376
|
//| |
|
|
318
|
377
|
//+------------------------------------------------------------------+
|
|
|
@@ -365,53 +424,3 @@ string checkCandle(int i) // to check the candle is bullish or bearish
|
|
365
|
424
|
//+------------------------------------------------------------------+
|
|
366
|
425
|
|
|
367
|
426
|
//+------------------------------------------------------------------+
|
|
368
|
|
-
|
|
369
|
|
-
|
|
370
|
|
-
|
|
371
|
|
-
|
|
372
|
|
-
|
|
373
|
|
-
|
|
374
|
|
-/////////////////////////////////////
|
|
375
|
|
-//void third condition()
|
|
376
|
|
-// {
|
|
377
|
|
-// if(checkCandle(index) == "Bearish")
|
|
378
|
|
-// {
|
|
379
|
|
-//
|
|
380
|
|
-// trend = "downtrend";
|
|
381
|
|
-//
|
|
382
|
|
-// // double high,low = 0.0;
|
|
383
|
|
-//
|
|
384
|
|
-// // to store high and low of the value after the object
|
|
385
|
|
-// low = iLow(Symbol(),PERIOD_CURRENT,index);
|
|
386
|
|
-//
|
|
387
|
|
-// //low = iLow(Symbol(),PERIOD_CURRENT,index-1);
|
|
388
|
|
-//
|
|
389
|
|
-// if(trend == "downtrend")
|
|
390
|
|
-// {
|
|
391
|
|
-//
|
|
392
|
|
-// low1 = iLow(Symbol(),PERIOD_CURRENT,i);
|
|
393
|
|
-//
|
|
394
|
|
-//
|
|
395
|
|
-// if(low1 < low)
|
|
396
|
|
-// {
|
|
397
|
|
-// low = low1;
|
|
398
|
|
-// for(int l=i; l > 0; l--)
|
|
399
|
|
-// {
|
|
400
|
|
-// // print("hi");
|
|
401
|
|
-// double high2 = iHigh(Symbol(),PERIOD_CURRENT,l);
|
|
402
|
|
-// if(high2 > high)
|
|
403
|
|
-// {
|
|
404
|
|
-//
|
|
405
|
|
-// high = high2;
|
|
406
|
|
-//
|
|
407
|
|
-// }
|
|
408
|
|
-//
|
|
409
|
|
-// }
|
|
410
|
|
-// }
|
|
411
|
|
-//
|
|
412
|
|
-// }
|
|
413
|
|
-// //
|
|
414
|
|
-// }
|
|
415
|
|
-//
|
|
416
|
|
-// }
|
|
417
|
|
-//+------------------------------------------------------------------+
|