소스 검색

ticket # 1476

AhtashamShahzad3 2 년 전
부모
커밋
1af51b61eb
4개의 변경된 파일413개의 추가작업 그리고 693개의 파일을 삭제
  1. BIN
      BOS_CHOCH.ex5
  2. 413 0
      BOS_CHOCH.mq5
  3. BIN
      MK_BOS_CHOCH.ex5
  4. 0 693
      MK_BOS_CHOCH.mq5

BIN
BOS_CHOCH.ex5


+ 413 - 0
BOS_CHOCH.mq5

@@ -0,0 +1,413 @@
1
+//+------------------------------------------------------------------+
2
+//|                                                 MK_BOS_CHOCH.mq5 |
3
+//|                                  Copyright 2023, MetaQuotes Ltd. |
4
+//|                                             https://www.mql5.com |
5
+//+------------------------------------------------------------------+
6
+#property copyright "Copyright 2023, MetaQuotes Ltd."
7
+#property link      "https://www.mql5.com"
8
+#property version   "1.00"
9
+
10
+sinput string              str = "<><><><><><> Object Name <><><><><><>";
11
+input string object_name = "line";
12
+
13
+string trend;
14
+bool bearish_found = false;
15
+bool bullish_found = false;
16
+
17
+int index_of_last_high = 0;
18
+int index_of_last_low = 0;
19
+
20
+double hi;
21
+double lo;
22
+
23
+int index_of_low = 0;
24
+int index_of_high = 0;
25
+
26
+int high_index=0;
27
+int low_index =0;
28
+double high,low,low1,high1,low2,high2;
29
+
30
+int Store_bos_last_index = 0;
31
+//int ind = 0;
32
+
33
+bool choch = false;
34
+int index = 0;
35
+//+------------------------------------------------------------------+
36
+//| Expert initialization function                                   |
37
+//+------------------------------------------------------------------+
38
+void Bos(int i)
39
+  {
40
+
41
+   if(trend == "uptrend")
42
+     {
43
+
44
+
45
+      high = iHigh(Symbol(),PERIOD_CURRENT,high_index);
46
+
47
+      high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
48
+
49
+
50
+      if(high1 > high)
51
+        {
52
+         high = high1;
53
+
54
+         ObjectCreate(0,"line1"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),high);
55
+         ObjectSetString(0,"line1"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"bos");
56
+
57
+         Store_bos_last_index = i;
58
+
59
+
60
+
61
+
62
+         int count = (high_index-1) - i;
63
+
64
+         for(int j=1; j <= count; j++)
65
+           {
66
+
67
+            if(checkCandle(high_index-j) == "Bearish")
68
+              {
69
+
70
+               low =  iLow(Symbol(),PERIOD_CURRENT,high_index-j);
71
+               bearish_found = true;
72
+
73
+
74
+              }
75
+
76
+           }
77
+
78
+         if(bearish_found == true)
79
+           {
80
+
81
+            for(int k=1; k < count; k++)
82
+              {
83
+
84
+               low1 = iLow(Symbol(),PERIOD_CURRENT,high_index - k);
85
+               if(low1 <= low)
86
+                 {
87
+
88
+                  low = low1;
89
+                  index_of_low =high_index- k;
90
+
91
+                 }
92
+              }
93
+            bearish_found = false;
94
+
95
+           }
96
+
97
+         Print(" high price is ", high);
98
+         Print("low price is ", low);
99
+
100
+
101
+         high_index = i;
102
+
103
+
104
+
105
+        }
106
+
107
+     }
108
+
109
+   if(trend == "downtrend")
110
+     {
111
+
112
+
113
+      low = iLow(Symbol(),PERIOD_CURRENT,low_index);
114
+
115
+      low1 = iLow(Symbol(),PERIOD_CURRENT,i);
116
+
117
+
118
+      if(low1 < low)
119
+        {
120
+         Store_bos_last_index = i;
121
+
122
+
123
+         low = low1;
124
+
125
+         ObjectCreate(0,"line2"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),low);
126
+         ObjectSetString(0,"line2"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"bos");
127
+         int count = (low_index-1) - i;
128
+
129
+
130
+         for(int j=1; j <= count; j++)
131
+           {
132
+
133
+            if(checkCandle(low_index-j) == "Bullish")
134
+              {
135
+
136
+               high =  iHigh(Symbol(),PERIOD_CURRENT,low_index-j);
137
+               bullish_found = true;
138
+
139
+
140
+
141
+              }
142
+
143
+           }
144
+
145
+         if(bullish_found == true)
146
+           {
147
+
148
+            for(int k=1; k < count; k++)
149
+              {
150
+
151
+               high1 = iHigh(Symbol(),PERIOD_CURRENT,low_index - k);
152
+               if(high1 >= high)
153
+                 {
154
+
155
+                  high = high1;
156
+                  index_of_high = low_index - k;
157
+
158
+
159
+                 }
160
+              }
161
+            bullish_found = false;
162
+
163
+           }
164
+         Print("low price is ", low);
165
+         Print(" high price is ", high);
166
+
167
+
168
+
169
+         low_index = i;
170
+
171
+
172
+
173
+        }
174
+
175
+     }
176
+
177
+
178
+  }
179
+
180
+//+------------------------------------------------------------------+
181
+//|                                                                  |
182
+//+------------------------------------------------------------------+
183
+void choch(int i)
184
+  {
185
+
186
+   if(trend == "uptrend")
187
+     {
188
+      double close = iClose(Symbol(),PERIOD_CURRENT,i);
189
+
190
+      if(close < low)
191
+        {
192
+
193
+         ObjectCreate(0,"line3"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),close);
194
+         ObjectSetString(0,"line3"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"choch");
195
+         ObjectCreate(0,"line8"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_ARROW_DOWN,0,iTime(Symbol(),PERIOD_CURRENT,i),iHigh(Symbol(),PERIOD_CURRENT,i)+100*Point());
196
+         ObjectSetInteger(0,"line8"+iTime(Symbol(),PERIOD_CURRENT,i),OBJPROP_COLOR,clrRed);
197
+         Print("last bos index is ",Store_bos_last_index);
198
+         hi = iHigh(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
199
+         lo = iLow(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
200
+         low = iLow(Symbol(),PERIOD_CURRENT,i);
201
+         Print("low update due to choch : ", low);
202
+         trend = "downtrend";
203
+         Print("choch at uptrend index --- ", iTime(Symbol(),PERIOD_CURRENT,i));
204
+        }
205
+
206
+     }
207
+
208
+
209
+
210
+
211
+   if(trend == "downtrend")
212
+     {
213
+
214
+      double close = iClose(Symbol(),PERIOD_CURRENT,i);
215
+
216
+      if(close > high)
217
+        {
218
+
219
+         ObjectCreate(0,"line4"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),close);
220
+         ObjectSetString(0,"line4"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"choch");
221
+
222
+         ObjectCreate(0,"line7"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_ARROW_UP,0,iTime(Symbol(),PERIOD_CURRENT,i),iLow(Symbol(),PERIOD_CURRENT,i)-100*Point());
223
+         ObjectSetInteger(0,"line7"+iTime(Symbol(),PERIOD_CURRENT,i),OBJPROP_COLOR,clrGreen);
224
+
225
+         Print("last bos index is ",Store_bos_last_index);
226
+
227
+         hi = iHigh(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
228
+         lo = iLow(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
229
+
230
+
231
+
232
+         high = iHigh(Symbol(),PERIOD_CURRENT,i);
233
+         trend = "uptrend";
234
+
235
+         Print("high is update due to choch : ", high);
236
+         Print("choch at downtrend index ---- ", iTime(Symbol(),PERIOD_CURRENT,i));
237
+
238
+        }
239
+
240
+     }
241
+
242
+
243
+
244
+  }
245
+//+------------------------------------------------------------------+
246
+//|                                                                  |
247
+//+------------------------------------------------------------------+
248
+void third_Condition(int i)
249
+  {
250
+
251
+   if(trend == "uptrend")
252
+     {
253
+      low2 = iLow(Symbol(),PERIOD_CURRENT,i);
254
+
255
+      if(low2 < low)
256
+        {
257
+         ObjectCreate(0,"line5"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),low2);
258
+         ObjectSetString(0,"line5"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"3_C");
259
+         low = low2;
260
+         Print("low update due to third condition",low);
261
+        }
262
+     }
263
+
264
+   if(trend == "downtrend")
265
+     {
266
+      high2 = iHigh(Symbol(),PERIOD_CURRENT,i);
267
+
268
+      if(high2 > high)
269
+        {
270
+         ObjectCreate(0,"line6"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),high2);
271
+         ObjectSetString(0,"line6"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"3_C");
272
+         high = high2;
273
+         Print("high update due to third condition",high);
274
+        }
275
+     }
276
+
277
+  }
278
+//+------------------------------------------------------------------+
279
+//|                                                                  |
280
+//+------------------------------------------------------------------+
281
+void foo(int value)
282
+  {
283
+   int l = 0;
284
+
285
+   for(int i=value-1; i > 0; i--)
286
+     {
287
+      //Print("hi");
288
+      //if(l < 2)
289
+        {
290
+
291
+         Bos(i);
292
+         choch(i);
293
+         third_Condition(i);
294
+
295
+
296
+         l++;
297
+
298
+        }
299
+      //Bos(i);
300
+
301
+
302
+
303
+     }
304
+
305
+  }
306
+//+------------------------------------------------------------------+
307
+//|                                                                  |
308
+//+------------------------------------------------------------------+
309
+int OnInit()
310
+  {
311
+
312
+   object_find(object_name);
313
+
314
+   if(object_find(object_name) == true)
315
+     {
316
+
317
+      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
318
+
319
+      index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
320
+      checkCandle(index);
321
+      if(checkCandle(index) == "Bullish")
322
+        {
323
+         trend = "uptrend";
324
+        }
325
+      if(checkCandle(index) == "Bearish")
326
+        {
327
+         trend = "downtrend";
328
+        }
329
+      high = iHigh(Symbol(),PERIOD_CURRENT,index);
330
+      low = iLow(Symbol(),PERIOD_CURRENT,index);
331
+      high_index = index;
332
+      low_index = index;
333
+
334
+
335
+      foo(index);
336
+
337
+     }
338
+   else
339
+     {
340
+      Print("Object Not Found");
341
+     }
342
+
343
+   return(INIT_SUCCEEDED);
344
+  }
345
+//+------------------------------------------------------------------+
346
+//| Expert deinitialization function                                 |
347
+//+------------------------------------------------------------------+
348
+void OnDeinit(const int reason)
349
+  {
350
+//---
351
+
352
+  }
353
+//+------------------------------------------------------------------+
354
+//| Expert tick function                                             |
355
+//+------------------------------------------------------------------+
356
+void OnTick()
357
+  {
358
+
359
+
360
+  }
361
+
362
+//+------------------------------------------------------------------+
363
+//|                                                                  |
364
+//+------------------------------------------------------------------+
365
+bool NewBar()
366
+  {
367
+   static datetime Last_bar ;
368
+   datetime Current_bar = iTime(Symbol(), PERIOD_CURRENT,0);
369
+   if(Current_bar != Last_bar)
370
+     {
371
+      Last_bar = Current_bar;
372
+      return (true);
373
+     }
374
+   else
375
+     {
376
+      return (false);
377
+     }
378
+  }
379
+
380
+//+------------------------------------------------------------------+
381
+//|                                                                  |
382
+//+------------------------------------------------------------------+
383
+bool object_find(string obj)    // to find object placed by user in the chart
384
+  {
385
+   if(ObjectFind(0,obj) >= 0)
386
+     {
387
+      return true;
388
+     }
389
+   return false;
390
+
391
+  }
392
+//+------------------------------------------------------------------+
393
+//|                                                                  |
394
+//+------------------------------------------------------------------+
395
+string checkCandle(int i)  // to check the candle is bullish or bearish
396
+  {
397
+   double  close = iClose(Symbol(),PERIOD_CURRENT,i);
398
+   double  open  = iOpen(Symbol(),PERIOD_CURRENT,i);
399
+
400
+   if(close > open)
401
+     {
402
+      return "Bullish";
403
+     }
404
+   else
405
+      if(close < open)
406
+        {
407
+         return "Bearish";
408
+        }
409
+   return "empty";
410
+  }
411
+//+------------------------------------------------------------------+
412
+
413
+//+------------------------------------------------------------------+

BIN
MK_BOS_CHOCH.ex5


+ 0 - 693
MK_BOS_CHOCH.mq5

@@ -1,693 +0,0 @@
1
-//+------------------------------------------------------------------+
2
-//|                                                 MK_BOS_CHOCH.mq5 |
3
-//|                                  Copyright 2023, MetaQuotes Ltd. |
4
-//|                                             https://www.mql5.com |
5
-//+------------------------------------------------------------------+
6
-#property copyright "Copyright 2023, MetaQuotes Ltd."
7
-#property link      "https://www.mql5.com"
8
-#property version   "1.00"
9
-
10
-sinput string              str = "<><><><><><> Object Name <><><><><><>";
11
-input string object_name = "line";
12
-
13
-string trend;
14
-bool bearish_found = false;
15
-bool bullish_found = false;
16
-
17
-int index_of_last_high = 0;
18
-int index_of_last_low = 0;
19
-
20
-double hi;
21
-double lo;
22
-
23
-int index_of_low = 0;
24
-int index_of_high = 0;
25
-
26
-int high_index=0;
27
-double high,low,low1,high1;
28
-
29
-int Store_last_index_of_high = 0;
30
-int Store_last_index_of_low = 0;
31
-//int ind = 0;
32
-
33
-bool choch = false;
34
-//+------------------------------------------------------------------+
35
-//| Expert initialization function                                   |
36
-//+------------------------------------------------------------------+
37
-void foo(int index)
38
-  {
39
-
40
-   for(int i=index; i > 0; i--)
41
-     {
42
-
43
-      //ind = index;
44
-
45
-      if(trend == "uptrend")
46
-        {
47
-         high = iHigh(Symbol(),PERIOD_CURRENT,index);
48
-
49
-         high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
50
-
51
-         if(high1 > high)
52
-           {
53
-            Store_last_index_of_high = i;
54
-
55
-            high = high1;
56
-
57
-
58
-            int count = (index-1) - i;
59
-
60
-            //Print("count",count);
61
-
62
-            for(int j=1; j < count; j++)
63
-              {
64
-
65
-               if(checkCandle(index-j) == "Bearish")
66
-                 {
67
-
68
-                  low =  iLow(Symbol(),PERIOD_CURRENT,index-j);
69
-                  bearish_found = true;
70
-
71
-                  //Print("bearish is found at index ",index-j);
72
-
73
-
74
-                 }
75
-
76
-              }
77
-
78
-            if(bearish_found == true)
79
-              {
80
-
81
-               for(int k=1; k <= count; k++)
82
-                 {
83
-
84
-                  low1 = iLow(Symbol(),PERIOD_CURRENT,index - k);
85
-                  if(low1 <= low)
86
-                    {
87
-                     //Print("here");
88
-                     low = low1;
89
-                     index_of_low =index- k;
90
-                     Print("low update due to 2 condition : ",index- k);
91
-
92
-                    }
93
-                 }
94
-               bearish_found = false;
95
-
96
-              }
97
-
98
-            Print(" high price is ", high);
99
-            Print("low price is ", low);
100
-
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;
107
-
108
-
109
-            // Print("index is ", i);
110
-
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);
118
-
119
-               if(close < low)
120
-                 {
121
-
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);
126
-
127
-
128
-
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);
134
-
135
-                  choch = true;
136
-                  break;
137
-
138
-                 }
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);
159
-
160
-
161
-               hi = 0.0;
162
-               lo =0.0;
163
-               choch = false;
164
-              }
165
-
166
-
167
-
168
-
169
-           }
170
-
171
-        }
172
-
173
-
174
-      if(trend == "downtrend")
175
-        {
176
-
177
-         low = iLow(Symbol(),PERIOD_CURRENT,index);
178
-
179
-         low1 = iLow(Symbol(),PERIOD_CURRENT,i);
180
-
181
-         if(low1 < low)
182
-           {
183
-            Store_last_index_of_low = i;
184
-
185
-            low = low1;
186
-
187
-
188
-            int count = (index-1) - i;
189
-
190
-            //Print("count",count);
191
-
192
-            for(int j=1; j < count; j++)
193
-              {
194
-
195
-               if(checkCandle(index-j) == "Bullish")
196
-                 {
197
-
198
-                  high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
199
-                  bullish_found = true;
200
-
201
-                  //Print("bearish is found at index ",index-j);
202
-
203
-
204
-                 }
205
-
206
-              }
207
-
208
-            if(bullish_found == true)
209
-              {
210
-
211
-               for(int k=1; k <= count; k++)
212
-                 {
213
-
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);
221
-
222
-                    }
223
-                 }
224
-               bearish_found = false;
225
-
226
-              }
227
-
228
-            Print(" high price is ", high);
229
-            Print("low price is ", low);
230
-
231
-            Print("index of last updated high is ", index_of_high);
232
-
233
-
234
-            Print("index value is re", index);
235
-            Print("ith value is ",i);
236
-            index = i;
237
-
238
-
239
-            // Print("index is ", i);
240
-
241
-
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);
248
-
249
-            double close = iClose(Symbol(),PERIOD_CURRENT,l);
250
-            double high3  = iHigh(Symbol(),PERIOD_CURRENT,l);
251
-
252
-            if(close > high)
253
-              {
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);
259
-
260
-
261
-               high = iHigh(Symbol(),PERIOD_CURRENT,l);
262
-               trend = "uptrend";
263
-
264
-               index_of_last_low = Store_last_index_of_low;
265
-               Print("choch at index ", l);
266
-
267
-               choch = true;
268
-               break;
269
-
270
-              }
271
-
272
-            if(high3 > high)
273
-              {
274
-
275
-               high = high3;
276
-               Print("high update due to third condition",high);
277
-              }
278
-
279
-           }
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
-           }
293
-
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
-      //        }
571
-     }
572
-
573
-  }
574
-//+------------------------------------------------------------------+
575
-//|                                                                  |
576
-//+------------------------------------------------------------------+
577
-int OnInit()
578
-  {
579
-
580
-//ObjectCreate(0,"line",OBJ_VLINE,0,D'2023.07.01 10:00:27',0);
581
-   object_find(object_name);
582
-//Print(ObjectFind(0,"line"));  // to find the object drawn on the chart
583
-
584
-   if(object_find(object_name) == true)
585
-     {
586
-
587
-      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
588
-
589
-      // Print("line time: ",time_of_candle);
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
-        }
600
-      //Print(index);
601
-      // Print(index);
602
-
603
-      //      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
604
-      //      Print("time is " , time_of_candle);
605
-      //
606
-      //      int index = iBarShift(0, PERIOD_CURRENT,time_of_candle, true);
607
-
608
-      //  Print("index is " , index);
609
-      foo(index);
610
-
611
-     }
612
-   else
613
-     {
614
-      Print("Object Not Found");
615
-     }
616
-
617
-   return(INIT_SUCCEEDED);
618
-  }
619
-//+------------------------------------------------------------------+
620
-//| Expert deinitialization function                                 |
621
-//+------------------------------------------------------------------+
622
-void OnDeinit(const int reason)
623
-  {
624
-//---
625
-
626
-  }
627
-//+------------------------------------------------------------------+
628
-//| Expert tick function                                             |
629
-//+------------------------------------------------------------------+
630
-void OnTick()
631
-  {
632
-   if(NewBar())
633
-     {
634
-      ObjectSetInteger(0,"tline1",OBJPROP_TIME,iTime(Symbol(), PERIOD_CURRENT,0));
635
-
636
-      ObjectSetInteger(0,"tline2",OBJPROP_TIME,iTime(Symbol(), PERIOD_CURRENT,0));
637
-     }
638
-
639
-
640
-  }
641
-
642
-//+------------------------------------------------------------------+
643
-//|                                                                  |
644
-//+------------------------------------------------------------------+
645
-bool NewBar()
646
-  {
647
-   static datetime Last_bar ;
648
-   datetime Current_bar = iTime(Symbol(), PERIOD_CURRENT,0);
649
-   if(Current_bar != Last_bar)
650
-     {
651
-      Last_bar = Current_bar;
652
-      return (true);
653
-     }
654
-   else
655
-     {
656
-      return (false);
657
-     }
658
-  }
659
-
660
-//+------------------------------------------------------------------+
661
-//|                                                                  |
662
-//+------------------------------------------------------------------+
663
-bool object_find(string obj)    // to find object placed by user in the chart
664
-  {
665
-   if(ObjectFind(0,obj) >= 0)
666
-     {
667
-      return true;
668
-     }
669
-   return false;
670
-
671
-  }
672
-//+------------------------------------------------------------------+
673
-//|                                                                  |
674
-//+------------------------------------------------------------------+
675
-string checkCandle(int i)  // to check the candle is bullish or bearish
676
-  {
677
-   double  close = iClose(Symbol(),PERIOD_CURRENT,i);
678
-   double  open  = iOpen(Symbol(),PERIOD_CURRENT,i);
679
-
680
-   if(close > open)
681
-     {
682
-      return "Bullish";
683
-     }
684
-   else
685
-      if(close < open)
686
-        {
687
-         return "Bearish";
688
-        }
689
-   return "empty";
690
-  }
691
-//+------------------------------------------------------------------+
692
-
693
-//+------------------------------------------------------------------+