Browse Source

Ticket # 1483

in progress :
Found bug in the previous code rresolve the third condition and bos choch senario
AhtashamShahzad3 2 years ago
parent
commit
a1a2f97303
2 changed files with 449 additions and 182 deletions
  1. BIN
      MK_BOS_CHOCH.ex5
  2. 449 182
      MK_BOS_CHOCH.mq5

BIN
MK_BOS_CHOCH.ex5


+ 449 - 182
MK_BOS_CHOCH.mq5

@@ -22,9 +22,14 @@ double lo;
22 22
 
23 23
 int index_of_low = 0;
24 24
 int index_of_high = 0;
25
+
25 26
 int high_index=0;
26 27
 double high,low,low1,high1;
27 28
 
29
+int Store_last_index_of_high = 0;
30
+int Store_last_index_of_low = 0;
31
+//int ind = 0;
32
+
28 33
 bool choch = false;
29 34
 //+------------------------------------------------------------------+
30 35
 //| Expert initialization function                                   |
@@ -35,281 +40,534 @@ void foo(int index)
35 40
    for(int i=index; i > 0; i--)
36 41
      {
37 42
 
38
-      if(checkCandle(index) == "Bullish")
43
+      //ind = index;
44
+
45
+      if(trend == "uptrend")
39 46
         {
47
+         high = iHigh(Symbol(),PERIOD_CURRENT,index);
40 48
 
41
-         trend = "uptrend";
49
+         high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
42 50
 
43
-         //double high,low = 0.0;
51
+         if(high1 > high)
52
+           {
53
+            Store_last_index_of_high = i;
44 54
 
45
-         // to store high and low of the value after the object
46
-         high = iHigh(Symbol(),PERIOD_CURRENT,index);
55
+            high = high1;
47 56
 
48
-         //low =  iLow(Symbol(),PERIOD_CURRENT,index-1);
49 57
 
58
+            int count = (index-1) - i;
50 59
 
51
-         if(trend == "uptrend")
52
-           {
60
+            //Print("count",count);
53 61
 
54
-            high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
62
+            for(int j=1; j < count; j++)
63
+              {
55 64
 
56
-            //double low1  = iLow(Symbol(),PERIOD_CURRENT,i);
65
+               if(checkCandle(index-j) == "Bearish")
66
+                 {
57 67
 
58
-            if(high1 > high)
59
-              {
68
+                  low =  iLow(Symbol(),PERIOD_CURRENT,index-j);
69
+                  bearish_found = true;
60 70
 
61
-               high = high1;
71
+                  //Print("bearish is found at index ",index-j);
62 72
 
63
-               //  Print("high break at index value",i);
64
-               // Print("index is ",index);
65 73
 
66
-               int count = (index-1) - i;
67
-               Print("index  is  : : ", i);
74
+                 }
68 75
 
69
-               // Print("index updated ",index);
76
+              }
70 77
 
71
-               // Print("count",count);
78
+            if(bearish_found == true)
79
+              {
72 80
 
73
-               for(int j=1; j <= count; j++)
81
+               for(int k=1; k <= count; k++)
74 82
                  {
75 83
 
76
-                  if(checkCandle(index-j) == "Bearish")
84
+                  low1 = iLow(Symbol(),PERIOD_CURRENT,index - k);
85
+                  if(low1 <= low)
77 86
                     {
78
-                     low =  iLow(Symbol(),PERIOD_CURRENT,index-j);
79
-                     bearish_found = true;
80
-                    }
87
+                     //Print("here");
88
+                     low = low1;
89
+                     index_of_low =index- k;
90
+                     Print("low update due to 2 condition : ",index- k);
81 91
 
92
+                    }
82 93
                  }
94
+               bearish_found = false;
83 95
 
84
-               if(bearish_found == true)
85
-                 {
86
-                  //double low1 ;
87
-                  //Print("where");
88
-                  for(int k=1; k <= count; k++)
89
-                    {
96
+              }
90 97
 
91
-                     low1 = iLow(Symbol(),PERIOD_CURRENT,index - k);
92
-                     if(low1 <= low)
93
-                       {
94
-                        //Print("here");
95
-                        low = low1;
96
-                        index_of_low = index - k;
97
-                        Print("low is updated at index : ",index - k);
98
+            Print(" high price is ", high);
99
+            Print("low price is ", low);
98 100
 
99
-                       }
100
-                    }
101
-                  bearish_found = false;
101
+            Print("index of last updated low is ", index_of_low);
102
+
103
+
104
+            Print("index value is re", index);
105
+            Print("ith value is ",i);
106
+            index = i;
102 107
 
103
-                 }
104 108
 
105
-               Print(" high price is ", high);
109
+            // Print("index is ", i);
106 110
 
107
-               Print("low price is ", low);
108
-               Print("index of last updated low is ", index_of_low);
111
+            for(int l=index_of_low; l > 0; l--)
112
+              {
113
+               // Print(l);
114
+               // Print("index of low ", index_of_low," to check ", index);
115
+
116
+               double close = iClose(Symbol(),PERIOD_CURRENT,l);
117
+               double low3  = iLow(Symbol(),PERIOD_CURRENT,l);
109 118
 
110
-               for(int l=index_of_low; l > 0; l--)
119
+               if(close < low)
111 120
                  {
112
-                  // print("hi");
113
-                  double close = iClose(Symbol(),PERIOD_CURRENT,l);
114
-                  double low3  = iLow(Symbol(),PERIOD_CURRENT,l);
115 121
 
116
-                  if(close < low)
117
-                    {
118
-                     double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
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);
122
-                     trend = "downtrend";
123
-                     Print("choch");
124
-                     index_of_last_high = i;
125
-                     Print("close", close);
126
-                     choch = true;
127
-                     break;
122
+                  //double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
123
+                  //datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
124
+                  //datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
125
+                  ////ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
128 126
 
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;
141
-                     break;
142 127
 
143
-                    }
144 128
 
145
-                 }
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);
129
+                  low = iLow(Symbol(),PERIOD_CURRENT,l);
130
+                  trend = "downtrend";
131
+
132
+                  index_of_last_high = Store_last_index_of_high;
133
+                  Print("choch at index --------------------------------------------------------------------------------------- ", l);
150 134
 
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);
135
+                  choch = true;
136
+                  break;
154 137
 
155
-                  hi = 0.0;
156
-                  lo =0.0;
157
-                  choch = false;
158 138
                  }
159 139
 
140
+               if(low3 < low)
141
+                 {
142
+                  low = low3;
143
+                  Print("low update due to third condition",low);
144
+                 }
145
+
146
+              }
147
+            if(choch == true)
148
+              {
149
+               Print("here we are",index_of_last_high+1);
150
+               hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
151
+               datetime ti = iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
152
+               lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
153
+
154
+               Print(" buy and sell high index is ",index_of_last_high+1);
155
+               Print(" high price is ", hi);
156
+               Print(" low price is ", lo);
157
+               ObjectCreate(0,"line111"+iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1),OBJ_HLINE,0,ti,hi);
158
+               ObjectCreate(0,"line12"+iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1),OBJ_HLINE,0,ti,lo);
160 159
 
161
-               index = i;
162 160
 
161
+               hi = 0.0;
162
+               lo =0.0;
163
+               choch = false;
163 164
               }
164 165
 
165
-           }
166
-         //
167 166
 
168 167
 
169
-        }
170 168
 
171
-      if(checkCandle(index) == "Bearish")
172
-        {
169
+           }
170
+
171
+        }
173 172
 
174
-         trend = "downtrend";
175 173
 
176
-         // double high,low = 0.0;
174
+      if(trend == "downtrend")
175
+        {
177 176
 
178
-         // to store high and low of the value after the object
179 177
          low = iLow(Symbol(),PERIOD_CURRENT,index);
180 178
 
181
-         //low =  iLow(Symbol(),PERIOD_CURRENT,index-1);
179
+         low1 = iLow(Symbol(),PERIOD_CURRENT,i);
182 180
 
183
-         if(trend == "downtrend")
181
+         if(low1 < low)
184 182
            {
183
+            Store_last_index_of_low = i;
185 184
 
185
+            low = low1;
186 186
 
187 187
 
188
+            int count = (index-1) - i;
188 189
 
189
-            low1 = iLow(Symbol(),PERIOD_CURRENT,i);
190
+            //Print("count",count);
190 191
 
191
-            //double low1  = iLow(Symbol(),PERIOD_CURRENT,i);
192
-
193
-            if(low1 < low)
192
+            for(int j=1; j < count; j++)
194 193
               {
195
-               low = low1;
196 194
 
197
-               //  Print("high break at index value",i);
198
-               // Print("index is ",index);
195
+               if(checkCandle(index-j) == "Bullish")
196
+                 {
199 197
 
200
-               int count = (index-1) - i;
201
-               Print("count is ", count);
198
+                  high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
199
+                  bullish_found = true;
202 200
 
203
-               // Print("index updated ",index);
201
+                  //Print("bearish is found at index ",index-j);
204 202
 
205
-               // Print("count",count);
206 203
 
207
-               for(int j=1; j <= count; j++)
208
-                 {
204
+                 }
209 205
 
210
-                  if(checkCandle(index-j) == "Bullish")
211
-                    {
212
-                     high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
213
-                     bullish_found = true;
214
-                    }
206
+              }
215 207
 
216
-                 }
208
+            if(bullish_found == true)
209
+              {
217 210
 
218
-               if(bullish_found == true)
211
+               for(int k=1; k <= count; k++)
219 212
                  {
220
-                  high1;
221
-                  //Print("where");
222
-                  for(int k=1; k <= count; k++)
223
-                    {
224 213
 
225
-                     high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
226
-                     if(high1 >= high)
227
-                       {
228
-                        //Print("here");
229
-                        high = high1;
230
-                        index_of_high = index - k;
231
-                        Print("high is updated at index : ",index - k);
214
+                  high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
215
+                  if(high1 >= high)
216
+                    {
217
+                     //Print("here");
218
+                     high = high1;
219
+                     index_of_high =index- k;
220
+                     Print("high update due to 2 condition : ",index- k);
232 221
 
233
-                       }
234 222
                     }
235
-                  bullish_found = false;
236
-
237 223
                  }
224
+               bearish_found = false;
238 225
 
239
-               Print(" high price is ", high);
240
-               Print("low price is ", low);
241
-               Print("index of last updated high is ", index_of_high);
226
+              }
242 227
 
243
-               for(int l=index_of_high; l > 0; l--)
244
-                 {
245
-                  // print("hi");
246
-                  double close = iClose(Symbol(),PERIOD_CURRENT,l);
247
-                  double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
228
+            Print(" high price is ", high);
229
+            Print("low price is ", low);
248 230
 
249
-                  if(close > high)
250
-                    {
231
+            Print("index of last updated high is ", index_of_high);
251 232
 
252
-                     double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
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 233
 
234
+            Print("index value is re", index);
235
+            Print("ith value is ",i);
236
+            index = i;
257 237
 
258
-                     trend = "uptrend";
259
-                     Print("choch");
260
-                     Print(l);
261
-                     index_of_last_low = i;
262
-                     Print("close", close);
263
-                     choch = true;
264
-                     break;
265 238
 
266
-                    }
239
+            // Print("index is ", i);
267 240
 
268
-                  if(high3 > high)
269
-                    {
270 241
 
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 242
 
243
+           }
244
+         for(int l=index_of_high; l > 0; l--)
245
+           {
246
+            //Print(l);
247
+            //Print("index of low ", index_of_high," to check ", index);
276 248
 
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;
249
+            double close = iClose(Symbol(),PERIOD_CURRENT,l);
250
+            double high3  = iHigh(Symbol(),PERIOD_CURRENT,l);
284 251
 
285
-                    }
252
+            if(close > high)
253
+              {
286 254
 
255
+               //double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
256
+               //datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
257
+               //datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
258
+               ////ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
287 259
 
288 260
 
261
+               high = iHigh(Symbol(),PERIOD_CURRENT,l);
262
+               trend = "uptrend";
289 263
 
290
-                 }
291
-               if(choch == true)
292
-                 {
264
+               index_of_last_low = Store_last_index_of_low;
265
+               Print("choch at index ", l);
293 266
 
294
-                  hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
295
-                  lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
267
+               choch = true;
268
+               break;
296 269
 
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);
270
+              }
300 271
 
301
-                  hi = 0.0;
302
-                  lo =0.0;
303
-                  choch = false;
304
-                 }
305
-               index = i;
272
+            if(high3 > high)
273
+              {
306 274
 
275
+               high = high3;
276
+               Print("high update due to third condition",high);
307 277
               }
308 278
 
309 279
            }
310
-         //
280
+         if(choch == true)
281
+           {
282
+            hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
283
+            lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
284
+
285
+            Print(" buy and sell high index is ",index_of_last_low+1);
286
+            Print(" high price is ", hi);
287
+            Print(" low price is ", lo);
288
+
289
+            hi = 0.0;
290
+            lo =0.0;
291
+            choch = false;
292
+           }
311 293
 
312 294
         }
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+      //      if(trend == "downtrend")
305
+      //        {
306
+      //         low = iLow(Symbol(),PERIOD_CURRENT,index);
307
+      //
308
+      //         low1 = iLow(Symbol(),PERIOD_CURRENT,i);
309
+      //
310
+      //         if(low1 < low)
311
+      //           {
312
+      //            Store_last_index_of_low = i;
313
+      //
314
+      //            low = low1;
315
+      //
316
+      //
317
+      //            int count = (index-1) - i;
318
+      //
319
+      //            //Print("count",count);
320
+      //
321
+      //            for(int j=1; j < count; j++)
322
+      //              {
323
+      //
324
+      //               if(checkCandle(index-j) == "Bullish")
325
+      //                 {
326
+      //
327
+      //                  high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
328
+      //                  bullish_found = true;
329
+      //
330
+      //                  //Print("bearish is found at index ",index-j);
331
+      //
332
+      //
333
+      //                 }
334
+      //
335
+      //              }
336
+      //
337
+      //            if(bullish_found == true)
338
+      //              {
339
+      //
340
+      //               for(int k=1; k < count; k++)
341
+      //                 {
342
+      //
343
+      //                  high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
344
+      //                  if(high1 >= high)
345
+      //                    {
346
+      //
347
+      //                     high = high1;
348
+      //                     index_of_high =index- k;
349
+      //                     Print(" high update due to 2 condition : ",index- k);
350
+      //
351
+      //                    }
352
+      //                 }
353
+      //               bullish_found = false;
354
+      //
355
+      //              }
356
+      //
357
+      //            Print(" high price is ", high);
358
+      //            Print("low price is ", low);
359
+      //
360
+      //            Print("index of last updated high is ", index_of_high);
361
+      //
362
+      //
363
+      //
364
+      //            index = i;
365
+      //
366
+      //
367
+      //            // Print("index is ", i);
368
+      //
369
+      //
370
+      //
371
+      //
372
+      //           }
373
+      //
374
+      //
375
+      //         for(int l=index_of_high; l >= index; l--)
376
+      //           {
377
+      //            // print("hi");
378
+      //            double close = iClose(Symbol(),PERIOD_CURRENT,l);
379
+      //            double high3  = iHigh(Symbol(),PERIOD_CURRENT,l);
380
+      //
381
+      //            if(close > high)
382
+      //              {
383
+      //
384
+      //               //double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
385
+      //               //datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
386
+      //               //datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
387
+      //               ////ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
388
+      //
389
+      //
390
+      //               high = iHigh(Symbol(),PERIOD_CURRENT,l);
391
+      //               trend = "uptrend";
392
+      //
393
+      //               index_of_last_low = Store_last_index_of_low;
394
+      //
395
+      //
396
+      //               choch = true;
397
+      //               break;
398
+      //
399
+      //              }
400
+      //
401
+      //            if(high3 > high)
402
+      //              {
403
+      //               high = high3;
404
+      //               Print("high update due to third condition",high);
405
+      //              }
406
+      //
407
+      //           }
408
+      //
409
+      //         if(choch == true)
410
+      //           {
411
+      //            hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
412
+      //            lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
413
+      //
414
+      //            Print(" buy and sell high index is ",index_of_last_low+1);
415
+      //            Print(" high price is ", hi);
416
+      //            Print(" low price is ", lo);
417
+      //
418
+      //            hi = 0.0;
419
+      //            lo =0.0;
420
+      //            choch = false;
421
+      //           }
422
+      //
423
+      //
424
+      //
425
+      //
426
+      //
427
+      //        }
428
+
429
+      //      if(checkCandle(index) == "Bearish")
430
+      //        {
431
+      //
432
+      //         trend = "downtrend";
433
+      //
434
+      //         // double high,low = 0.0;
435
+      //
436
+      //         // to store high and low of the value after the object
437
+      //         low = iLow(Symbol(),PERIOD_CURRENT,index);
438
+      //
439
+      //         //low =  iLow(Symbol(),PERIOD_CURRENT,index-1);
440
+      //
441
+      //         if(trend == "downtrend")
442
+      //           {
443
+      //
444
+      //
445
+      //
446
+      //
447
+      //            low1 = iLow(Symbol(),PERIOD_CURRENT,i);
448
+      //
449
+      //            //double low1  = iLow(Symbol(),PERIOD_CURRENT,i);
450
+      //
451
+      //            if(low1 < low)
452
+      //              {
453
+      //               low = low1;
454
+      //
455
+      //               //  Print("high break at index value",i);
456
+      //               // Print("index is ",index);
457
+      //
458
+      //               int count = (index-1) - i;
459
+      //               Print("count is ", count);
460
+      //
461
+      //               // Print("index updated ",index);
462
+      //
463
+      //               // Print("count",count);
464
+      //
465
+      //               for(int j=1; j <= count; j++)
466
+      //                 {
467
+      //
468
+      //                  if(checkCandle(index-j) == "Bullish")
469
+      //                    {
470
+      //                     high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
471
+      //                     bullish_found = true;
472
+      //                    }
473
+      //
474
+      //                 }
475
+      //
476
+      //               if(bullish_found == true)
477
+      //                 {
478
+      //                  high1;
479
+      //                  //Print("where");
480
+      //                  for(int k=1; k <= count; k++)
481
+      //                    {
482
+      //
483
+      //                     high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
484
+      //                     if(high1 >= high)
485
+      //                       {
486
+      //                        //Print("here");
487
+      //                        high = high1;
488
+      //                        index_of_high = index - k;
489
+      //                        Print("high is updated at index : ",index - k);
490
+      //
491
+      //                       }
492
+      //                    }
493
+      //                  bullish_found = false;
494
+      //
495
+      //                 }
496
+      //
497
+      //               Print(" high price is ", high);
498
+      //               Print("low price is ", low);
499
+      //               Print("index of last updated high is ", index_of_high);
500
+      //
501
+      //               for(int l=index_of_high; l > 0; l--)
502
+      //                 {
503
+      //                  // print("hi");
504
+      //                  double close = iClose(Symbol(),PERIOD_CURRENT,l);
505
+      //                  double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
506
+      //
507
+      //                  if(close > high)
508
+      //                    {
509
+      //
510
+      //                     double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
511
+      //                     datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
512
+      //                     datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
513
+      //                     //ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
514
+      //
515
+      //
516
+      //                     trend = "uptrend";
517
+      //                     Print("choch");
518
+      //                     Print(l);
519
+      //                     index_of_last_low = i;
520
+      //                     Print("close", close);
521
+      //                     choch = true;
522
+      //                     break;
523
+      //
524
+      //                    }
525
+      //
526
+      //                  if(high3 > high)
527
+      //                    {
528
+      //
529
+      //                     double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
530
+      //                     datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
531
+      //                     datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
532
+      //                     // ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
533
+      //
534
+      //
535
+      //                     trend = "uptrend";
536
+      //                     Print("choch in condition 3");
537
+      //                     Print(l);
538
+      //                     index_of_last_low = i;
539
+      //                     Print("close", close);
540
+      //                     choch = true;
541
+      //                     break;
542
+      //
543
+      //                    }
544
+      //
545
+      //
546
+      //
547
+      //
548
+      //                 }
549
+      //               if(choch == true)
550
+      //                 {
551
+      //
552
+      //                  hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
553
+      //                  lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
554
+      //
555
+      //                  Print(" buy and sell high index is ",index_of_last_low+1);
556
+      //                  Print(" high price is ", hi);
557
+      //                  Print(" low price is ", lo);
558
+      //
559
+      //                  hi = 0.0;
560
+      //                  lo = 0.0;
561
+      //                  choch = false;
562
+      //                 }
563
+      //               index = i;
564
+      //
565
+      //              }
566
+      //
567
+      //           }
568
+      //         //
569
+      //
570
+      //        }
313 571
      }
314 572
 
315 573
   }
@@ -328,10 +586,19 @@ int OnInit()
328 586
 
329 587
       datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
330 588
 
331
-     // Print("line time: ",time_of_candle);
589
+      // Print("line time: ",time_of_candle);
332 590
       int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
591
+      checkCandle(index);
592
+      if(checkCandle(index) == "Bullish")
593
+        {
594
+         trend = "uptrend";
595
+        }
596
+      if(checkCandle(index) == "Bearish")
597
+        {
598
+         trend = "downtrend";
599
+        }
333 600
       //Print(index);
334
-     // Print(index);
601
+      // Print(index);
335 602
 
336 603
       //      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
337 604
       //      Print("time is " , time_of_candle);