Przeglądaj źródła

Ticket 1463, 1476

Ticket 1463 Completed
Ticket 1476 in progress
AhtashamShahzad3 2 lat temu
rodzic
commit
fe697881c3
2 zmienionych plików z 82 dodań i 14 usunięć
  1. BIN
      MK_BOS_CHOCH.ex5
  2. 82 14
      MK_BOS_CHOCH.mq5

BIN
MK_BOS_CHOCH.ex5


+ 82 - 14
MK_BOS_CHOCH.mq5

@@ -14,7 +14,14 @@ string trend;
14
 bool bearish_found = false;
14
 bool bearish_found = false;
15
 bool bullish_found = false;
15
 bool bullish_found = false;
16
 
16
 
17
+int index_of_last_high = 0;
18
+int index_of_last_low = 0;
19
+
20
+double hi;
21
+double lo;
22
+
17
 int index_of_low = 0;
23
 int index_of_low = 0;
24
+int index_of_high = 0;
18
 int high_index=0;
25
 int high_index=0;
19
 double high,low,low1,high1;
26
 double high,low,low1,high1;
20
 //+------------------------------------------------------------------+
27
 //+------------------------------------------------------------------+
@@ -42,22 +49,20 @@ void foo(int index)
42
          if(trend == "uptrend")
49
          if(trend == "uptrend")
43
            {
50
            {
44
 
51
 
45
-
46
-
47
-
48
             high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
52
             high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
49
 
53
 
50
             //double low1  = iLow(Symbol(),PERIOD_CURRENT,i);
54
             //double low1  = iLow(Symbol(),PERIOD_CURRENT,i);
51
 
55
 
52
             if(high1 > high)
56
             if(high1 > high)
53
               {
57
               {
58
+
54
                high = high1;
59
                high = high1;
55
 
60
 
56
                //  Print("high break at index value",i);
61
                //  Print("high break at index value",i);
57
                // Print("index is ",index);
62
                // Print("index is ",index);
58
 
63
 
59
                int count = (index-1) - i;
64
                int count = (index-1) - i;
60
-               Print("count is ", count);
65
+               Print("index  is  : : ", i);
61
 
66
 
62
                // Print("index updated ",index);
67
                // Print("index updated ",index);
63
 
68
 
@@ -96,8 +101,9 @@ void foo(int index)
96
                  }
101
                  }
97
 
102
 
98
                Print(" high price is ", high);
103
                Print(" high price is ", high);
104
+
99
                Print("low price is ", low);
105
                Print("low price is ", low);
100
-               Print("index of low is ", index_of_low);
106
+               Print("index of last updated low is ", index_of_low);
101
 
107
 
102
                for(int l=index_of_low; l > 0; l--)
108
                for(int l=index_of_low; l > 0; l--)
103
                  {
109
                  {
@@ -108,17 +114,24 @@ void foo(int index)
108
                     {
114
                     {
109
                      double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
115
                      double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
110
                      double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
116
                      double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
111
-                     double time1 = iTime(Symbol(),PERIOD_CURRENT,l+1);
117
+                     double time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
112
                      ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
118
                      ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
113
                      trend = "downtrend";
119
                      trend = "downtrend";
114
                      Print("choch");
120
                      Print("choch");
115
-
121
+                     index_of_last_high = i;
116
                      Print("close", close);
122
                      Print("close", close);
117
                      break;
123
                      break;
118
 
124
 
119
                     }
125
                     }
120
 
126
 
121
                  }
127
                  }
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);
131
+
132
+               Print("hy",hi, "index is : ",index_of_last_high+1);
133
+               Print("ho",lo);
134
+
122
                index = i;
135
                index = i;
123
 
136
 
124
               }
137
               }
@@ -188,7 +201,7 @@ void foo(int index)
188
                        {
201
                        {
189
                         //Print("here");
202
                         //Print("here");
190
                         high = high1;
203
                         high = high1;
191
-                        index_of_low = index - k;
204
+                        index_of_high = index - k;
192
                         Print("high is updated at index : ",index - k);
205
                         Print("high is updated at index : ",index - k);
193
 
206
 
194
                        }
207
                        }
@@ -199,9 +212,9 @@ void foo(int index)
199
 
212
 
200
                Print(" high price is ", high);
213
                Print(" high price is ", high);
201
                Print("low price is ", low);
214
                Print("low price is ", low);
202
-               Print("index of low is ", index_of_low);
215
+               Print("index of last updated high is ", index_of_high);
203
 
216
 
204
-               for(int l=index_of_low; l > 0; l--)
217
+               for(int l=index_of_high; l > 0; l--)
205
                  {
218
                  {
206
                   // print("hi");
219
                   // print("hi");
207
                   double close = iClose(Symbol(),PERIOD_CURRENT,l);
220
                   double close = iClose(Symbol(),PERIOD_CURRENT,l);
@@ -210,19 +223,23 @@ void foo(int index)
210
 
223
 
211
                      double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
224
                      double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
212
                      double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
225
                      double time = iTime(Symbol(),PERIOD_CURRENT,l+1);
213
-                     double time1 = iTime(Symbol(),PERIOD_CURRENT,l+1);
214
-                     ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
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);
215
 
229
 
216
                      trend = "uptrend";
230
                      trend = "uptrend";
217
                      Print("choch");
231
                      Print("choch");
218
                      Print(l);
232
                      Print(l);
219
-
233
+                     index_of_last_low = i;
220
                      Print("close", close);
234
                      Print("close", close);
221
                      break;
235
                      break;
222
 
236
 
223
                     }
237
                     }
224
 
238
 
225
                  }
239
                  }
240
+               hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
241
+               lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
242
+
226
                index = i;
243
                index = i;
227
 
244
 
228
               }
245
               }
@@ -240,7 +257,7 @@ void foo(int index)
240
 int OnInit()
257
 int OnInit()
241
   {
258
   {
242
 
259
 
243
-   ObjectCreate(0,"line",OBJ_VLINE,0,D'2023.07.01 10:00:27',0);
260
+//ObjectCreate(0,"line",OBJ_VLINE,0,D'2023.07.01 10:00:27',0);
244
    object_find(object_name);
261
    object_find(object_name);
245
 //Print(ObjectFind(0,"line"));  // to find the object drawn on the chart
262
 //Print(ObjectFind(0,"line"));  // to find the object drawn on the chart
246
 
263
 
@@ -252,6 +269,7 @@ int OnInit()
252
       Print("line time: ",time_of_candle);
269
       Print("line time: ",time_of_candle);
253
       int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
270
       int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
254
       Print(index);
271
       Print(index);
272
+      Print(index);
255
 
273
 
256
       //      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
274
       //      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
257
       //      Print("time is " , time_of_candle);
275
       //      Print("time is " , time_of_candle);
@@ -347,3 +365,53 @@ string checkCandle(int i)  // to check the candle is bullish or bearish
347
 //+------------------------------------------------------------------+
365
 //+------------------------------------------------------------------+
348
 
366
 
349
 //+------------------------------------------------------------------+
367
 //+------------------------------------------------------------------+
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
+//+------------------------------------------------------------------+