ソースを参照

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 @@
+//+------------------------------------------------------------------+
+//|                                                 MK_BOS_CHOCH.mq5 |
+//|                                  Copyright 2023, MetaQuotes Ltd. |
+//|                                             https://www.mql5.com |
+//+------------------------------------------------------------------+
+#property copyright "Copyright 2023, MetaQuotes Ltd."
+#property link      "https://www.mql5.com"
+#property version   "1.00"
+
+sinput string              str = "<><><><><><> Object Name <><><><><><>";
+input string object_name = "line";
+
+string trend;
+bool bearish_found = false;
+bool bullish_found = false;
+
+int index_of_last_high = 0;
+int index_of_last_low = 0;
+
+double hi;
+double lo;
+
+int index_of_low = 0;
+int index_of_high = 0;
+
+int high_index=0;
+int low_index =0;
+double high,low,low1,high1,low2,high2;
+
+int Store_bos_last_index = 0;
+//int ind = 0;
+
+bool choch = false;
+int index = 0;
+//+------------------------------------------------------------------+
+//| Expert initialization function                                   |
+//+------------------------------------------------------------------+
+void Bos(int i)
+  {
+
+   if(trend == "uptrend")
+     {
+
+
+      high = iHigh(Symbol(),PERIOD_CURRENT,high_index);
+
+      high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
+
+
+      if(high1 > high)
+        {
+         high = high1;
+
+         ObjectCreate(0,"line1"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),high);
+         ObjectSetString(0,"line1"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"bos");
+
+         Store_bos_last_index = i;
+
+
+
+
+         int count = (high_index-1) - i;
+
+         for(int j=1; j <= count; j++)
+           {
+
+            if(checkCandle(high_index-j) == "Bearish")
+              {
+
+               low =  iLow(Symbol(),PERIOD_CURRENT,high_index-j);
+               bearish_found = true;
+
+
+              }
+
+           }
+
+         if(bearish_found == true)
+           {
+
+            for(int k=1; k < count; k++)
+              {
+
+               low1 = iLow(Symbol(),PERIOD_CURRENT,high_index - k);
+               if(low1 <= low)
+                 {
+
+                  low = low1;
+                  index_of_low =high_index- k;
+
+                 }
+              }
+            bearish_found = false;
+
+           }
+
+         Print(" high price is ", high);
+         Print("low price is ", low);
+
+
+         high_index = i;
+
+
+
+        }
+
+     }
+
+   if(trend == "downtrend")
+     {
+
+
+      low = iLow(Symbol(),PERIOD_CURRENT,low_index);
+
+      low1 = iLow(Symbol(),PERIOD_CURRENT,i);
+
+
+      if(low1 < low)
+        {
+         Store_bos_last_index = i;
+
+
+         low = low1;
+
+         ObjectCreate(0,"line2"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),low);
+         ObjectSetString(0,"line2"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"bos");
+         int count = (low_index-1) - i;
+
+
+         for(int j=1; j <= count; j++)
+           {
+
+            if(checkCandle(low_index-j) == "Bullish")
+              {
+
+               high =  iHigh(Symbol(),PERIOD_CURRENT,low_index-j);
+               bullish_found = true;
+
+
+
+              }
+
+           }
+
+         if(bullish_found == true)
+           {
+
+            for(int k=1; k < count; k++)
+              {
+
+               high1 = iHigh(Symbol(),PERIOD_CURRENT,low_index - k);
+               if(high1 >= high)
+                 {
+
+                  high = high1;
+                  index_of_high = low_index - k;
+
+
+                 }
+              }
+            bullish_found = false;
+
+           }
+         Print("low price is ", low);
+         Print(" high price is ", high);
+
+
+
+         low_index = i;
+
+
+
+        }
+
+     }
+
+
+  }
+
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+void choch(int i)
+  {
+
+   if(trend == "uptrend")
+     {
+      double close = iClose(Symbol(),PERIOD_CURRENT,i);
+
+      if(close < low)
+        {
+
+         ObjectCreate(0,"line3"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),close);
+         ObjectSetString(0,"line3"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"choch");
+         ObjectCreate(0,"line8"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_ARROW_DOWN,0,iTime(Symbol(),PERIOD_CURRENT,i),iHigh(Symbol(),PERIOD_CURRENT,i)+100*Point());
+         ObjectSetInteger(0,"line8"+iTime(Symbol(),PERIOD_CURRENT,i),OBJPROP_COLOR,clrRed);
+         Print("last bos index is ",Store_bos_last_index);
+         hi = iHigh(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
+         lo = iLow(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
+         low = iLow(Symbol(),PERIOD_CURRENT,i);
+         Print("low update due to choch : ", low);
+         trend = "downtrend";
+         Print("choch at uptrend index --- ", iTime(Symbol(),PERIOD_CURRENT,i));
+        }
+
+     }
+
+
+
+
+   if(trend == "downtrend")
+     {
+
+      double close = iClose(Symbol(),PERIOD_CURRENT,i);
+
+      if(close > high)
+        {
+
+         ObjectCreate(0,"line4"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),close);
+         ObjectSetString(0,"line4"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"choch");
+
+         ObjectCreate(0,"line7"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_ARROW_UP,0,iTime(Symbol(),PERIOD_CURRENT,i),iLow(Symbol(),PERIOD_CURRENT,i)-100*Point());
+         ObjectSetInteger(0,"line7"+iTime(Symbol(),PERIOD_CURRENT,i),OBJPROP_COLOR,clrGreen);
+
+         Print("last bos index is ",Store_bos_last_index);
+
+         hi = iHigh(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
+         lo = iLow(Symbol(),PERIOD_CURRENT,Store_bos_last_index+1);
+
+
+
+         high = iHigh(Symbol(),PERIOD_CURRENT,i);
+         trend = "uptrend";
+
+         Print("high is update due to choch : ", high);
+         Print("choch at downtrend index ---- ", iTime(Symbol(),PERIOD_CURRENT,i));
+
+        }
+
+     }
+
+
+
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+void third_Condition(int i)
+  {
+
+   if(trend == "uptrend")
+     {
+      low2 = iLow(Symbol(),PERIOD_CURRENT,i);
+
+      if(low2 < low)
+        {
+         ObjectCreate(0,"line5"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),low2);
+         ObjectSetString(0,"line5"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"3_C");
+         low = low2;
+         Print("low update due to third condition",low);
+        }
+     }
+
+   if(trend == "downtrend")
+     {
+      high2 = iHigh(Symbol(),PERIOD_CURRENT,i);
+
+      if(high2 > high)
+        {
+         ObjectCreate(0,"line6"+iTime(Symbol(),PERIOD_CURRENT,i),OBJ_TEXT,0,iTime(Symbol(),PERIOD_CURRENT,i),high2);
+         ObjectSetString(0,"line6"+iTime(Symbol(),PERIOD_CURRENT,i), OBJPROP_TEXT,"3_C");
+         high = high2;
+         Print("high update due to third condition",high);
+        }
+     }
+
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+void foo(int value)
+  {
+   int l = 0;
+
+   for(int i=value-1; i > 0; i--)
+     {
+      //Print("hi");
+      //if(l < 2)
+        {
+
+         Bos(i);
+         choch(i);
+         third_Condition(i);
+
+
+         l++;
+
+        }
+      //Bos(i);
+
+
+
+     }
+
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+int OnInit()
+  {
+
+   object_find(object_name);
+
+   if(object_find(object_name) == true)
+     {
+
+      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
+
+      index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
+      checkCandle(index);
+      if(checkCandle(index) == "Bullish")
+        {
+         trend = "uptrend";
+        }
+      if(checkCandle(index) == "Bearish")
+        {
+         trend = "downtrend";
+        }
+      high = iHigh(Symbol(),PERIOD_CURRENT,index);
+      low = iLow(Symbol(),PERIOD_CURRENT,index);
+      high_index = index;
+      low_index = index;
+
+
+      foo(index);
+
+     }
+   else
+     {
+      Print("Object Not Found");
+     }
+
+   return(INIT_SUCCEEDED);
+  }
+//+------------------------------------------------------------------+
+//| Expert deinitialization function                                 |
+//+------------------------------------------------------------------+
+void OnDeinit(const int reason)
+  {
+//---
+
+  }
+//+------------------------------------------------------------------+
+//| Expert tick function                                             |
+//+------------------------------------------------------------------+
+void OnTick()
+  {
+
+
+  }
+
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+bool NewBar()
+  {
+   static datetime Last_bar ;
+   datetime Current_bar = iTime(Symbol(), PERIOD_CURRENT,0);
+   if(Current_bar != Last_bar)
+     {
+      Last_bar = Current_bar;
+      return (true);
+     }
+   else
+     {
+      return (false);
+     }
+  }
+
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+bool object_find(string obj)    // to find object placed by user in the chart
+  {
+   if(ObjectFind(0,obj) >= 0)
+     {
+      return true;
+     }
+   return false;
+
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+string checkCandle(int i)  // to check the candle is bullish or bearish
+  {
+   double  close = iClose(Symbol(),PERIOD_CURRENT,i);
+   double  open  = iOpen(Symbol(),PERIOD_CURRENT,i);
+
+   if(close > open)
+     {
+      return "Bullish";
+     }
+   else
+      if(close < open)
+        {
+         return "Bearish";
+        }
+   return "empty";
+  }
+//+------------------------------------------------------------------+
+
+//+------------------------------------------------------------------+

BIN
MK_BOS_CHOCH.ex5


+ 0 - 693
MK_BOS_CHOCH.mq5

@@ -1,693 +0,0 @@
-//+------------------------------------------------------------------+
-//|                                                 MK_BOS_CHOCH.mq5 |
-//|                                  Copyright 2023, MetaQuotes Ltd. |
-//|                                             https://www.mql5.com |
-//+------------------------------------------------------------------+
-#property copyright "Copyright 2023, MetaQuotes Ltd."
-#property link      "https://www.mql5.com"
-#property version   "1.00"
-
-sinput string              str = "<><><><><><> Object Name <><><><><><>";
-input string object_name = "line";
-
-string trend;
-bool bearish_found = false;
-bool bullish_found = false;
-
-int index_of_last_high = 0;
-int index_of_last_low = 0;
-
-double hi;
-double lo;
-
-int index_of_low = 0;
-int index_of_high = 0;
-
-int high_index=0;
-double high,low,low1,high1;
-
-int Store_last_index_of_high = 0;
-int Store_last_index_of_low = 0;
-//int ind = 0;
-
-bool choch = false;
-//+------------------------------------------------------------------+
-//| Expert initialization function                                   |
-//+------------------------------------------------------------------+
-void foo(int index)
-  {
-
-   for(int i=index; i > 0; i--)
-     {
-
-      //ind = index;
-
-      if(trend == "uptrend")
-        {
-         high = iHigh(Symbol(),PERIOD_CURRENT,index);
-
-         high1 = iHigh(Symbol(),PERIOD_CURRENT,i);
-
-         if(high1 > high)
-           {
-            Store_last_index_of_high = i;
-
-            high = high1;
-
-
-            int count = (index-1) - i;
-
-            //Print("count",count);
-
-            for(int j=1; j < count; j++)
-              {
-
-               if(checkCandle(index-j) == "Bearish")
-                 {
-
-                  low =  iLow(Symbol(),PERIOD_CURRENT,index-j);
-                  bearish_found = true;
-
-                  //Print("bearish is found at index ",index-j);
-
-
-                 }
-
-              }
-
-            if(bearish_found == true)
-              {
-
-               for(int k=1; k <= count; k++)
-                 {
-
-                  low1 = iLow(Symbol(),PERIOD_CURRENT,index - k);
-                  if(low1 <= low)
-                    {
-                     //Print("here");
-                     low = low1;
-                     index_of_low =index- k;
-                     Print("low update due to 2 condition : ",index- k);
-
-                    }
-                 }
-               bearish_found = false;
-
-              }
-
-            Print(" high price is ", high);
-            Print("low price is ", low);
-
-            Print("index of last updated low is ", index_of_low);
-
-
-            Print("index value is re", index);
-            Print("ith value is ",i);
-            index = i;
-
-
-            // Print("index is ", i);
-
-            for(int l=index_of_low; l > 0; l--)
-              {
-               // Print(l);
-               // Print("index of low ", index_of_low," to check ", index);
-
-               double close = iClose(Symbol(),PERIOD_CURRENT,l);
-               double low3  = iLow(Symbol(),PERIOD_CURRENT,l);
-
-               if(close < low)
-                 {
-
-                  //double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
-                  //datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
-                  //datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
-                  ////ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
-
-
-
-                  low = iLow(Symbol(),PERIOD_CURRENT,l);
-                  trend = "downtrend";
-
-                  index_of_last_high = Store_last_index_of_high;
-                  Print("choch at index --------------------------------------------------------------------------------------- ", l);
-
-                  choch = true;
-                  break;
-
-                 }
-
-               if(low3 < low)
-                 {
-                  low = low3;
-                  Print("low update due to third condition",low);
-                 }
-
-              }
-            if(choch == true)
-              {
-               Print("here we are",index_of_last_high+1);
-               hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
-               datetime ti = iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
-               lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_high+1);
-
-               Print(" buy and sell high index is ",index_of_last_high+1);
-               Print(" high price is ", hi);
-               Print(" low price is ", lo);
-               ObjectCreate(0,"line111"+iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1),OBJ_HLINE,0,ti,hi);
-               ObjectCreate(0,"line12"+iTime(Symbol(),PERIOD_CURRENT,index_of_last_high+1),OBJ_HLINE,0,ti,lo);
-
-
-               hi = 0.0;
-               lo =0.0;
-               choch = false;
-              }
-
-
-
-
-           }
-
-        }
-
-
-      if(trend == "downtrend")
-        {
-
-         low = iLow(Symbol(),PERIOD_CURRENT,index);
-
-         low1 = iLow(Symbol(),PERIOD_CURRENT,i);
-
-         if(low1 < low)
-           {
-            Store_last_index_of_low = i;
-
-            low = low1;
-
-
-            int count = (index-1) - i;
-
-            //Print("count",count);
-
-            for(int j=1; j < count; j++)
-              {
-
-               if(checkCandle(index-j) == "Bullish")
-                 {
-
-                  high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
-                  bullish_found = true;
-
-                  //Print("bearish is found at index ",index-j);
-
-
-                 }
-
-              }
-
-            if(bullish_found == true)
-              {
-
-               for(int k=1; k <= count; k++)
-                 {
-
-                  high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
-                  if(high1 >= high)
-                    {
-                     //Print("here");
-                     high = high1;
-                     index_of_high =index- k;
-                     Print("high update due to 2 condition : ",index- k);
-
-                    }
-                 }
-               bearish_found = false;
-
-              }
-
-            Print(" high price is ", high);
-            Print("low price is ", low);
-
-            Print("index of last updated high is ", index_of_high);
-
-
-            Print("index value is re", index);
-            Print("ith value is ",i);
-            index = i;
-
-
-            // Print("index is ", i);
-
-
-
-           }
-         for(int l=index_of_high; l > 0; l--)
-           {
-            //Print(l);
-            //Print("index of low ", index_of_high," to check ", index);
-
-            double close = iClose(Symbol(),PERIOD_CURRENT,l);
-            double high3  = iHigh(Symbol(),PERIOD_CURRENT,l);
-
-            if(close > high)
-              {
-
-               //double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
-               //datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
-               //datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
-               ////ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
-
-
-               high = iHigh(Symbol(),PERIOD_CURRENT,l);
-               trend = "uptrend";
-
-               index_of_last_low = Store_last_index_of_low;
-               Print("choch at index ", l);
-
-               choch = true;
-               break;
-
-              }
-
-            if(high3 > high)
-              {
-
-               high = high3;
-               Print("high update due to third condition",high);
-              }
-
-           }
-         if(choch == true)
-           {
-            hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
-            lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
-
-            Print(" buy and sell high index is ",index_of_last_low+1);
-            Print(" high price is ", hi);
-            Print(" low price is ", lo);
-
-            hi = 0.0;
-            lo =0.0;
-            choch = false;
-           }
-
-        }
-
-
-
-
-
-
-
-
-
-      //      if(trend == "downtrend")
-      //        {
-      //         low = iLow(Symbol(),PERIOD_CURRENT,index);
-      //
-      //         low1 = iLow(Symbol(),PERIOD_CURRENT,i);
-      //
-      //         if(low1 < low)
-      //           {
-      //            Store_last_index_of_low = i;
-      //
-      //            low = low1;
-      //
-      //
-      //            int count = (index-1) - i;
-      //
-      //            //Print("count",count);
-      //
-      //            for(int j=1; j < count; j++)
-      //              {
-      //
-      //               if(checkCandle(index-j) == "Bullish")
-      //                 {
-      //
-      //                  high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
-      //                  bullish_found = true;
-      //
-      //                  //Print("bearish is found at index ",index-j);
-      //
-      //
-      //                 }
-      //
-      //              }
-      //
-      //            if(bullish_found == true)
-      //              {
-      //
-      //               for(int k=1; k < count; k++)
-      //                 {
-      //
-      //                  high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
-      //                  if(high1 >= high)
-      //                    {
-      //
-      //                     high = high1;
-      //                     index_of_high =index- k;
-      //                     Print(" high update due to 2 condition : ",index- k);
-      //
-      //                    }
-      //                 }
-      //               bullish_found = false;
-      //
-      //              }
-      //
-      //            Print(" high price is ", high);
-      //            Print("low price is ", low);
-      //
-      //            Print("index of last updated high is ", index_of_high);
-      //
-      //
-      //
-      //            index = i;
-      //
-      //
-      //            // Print("index is ", i);
-      //
-      //
-      //
-      //
-      //           }
-      //
-      //
-      //         for(int l=index_of_high; l >= index; l--)
-      //           {
-      //            // print("hi");
-      //            double close = iClose(Symbol(),PERIOD_CURRENT,l);
-      //            double high3  = iHigh(Symbol(),PERIOD_CURRENT,l);
-      //
-      //            if(close > high)
-      //              {
-      //
-      //               //double price_low = iLow(Symbol(),PERIOD_CURRENT,l+1);
-      //               //datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
-      //               //datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
-      //               ////ObjectCreate(0,"tline1",OBJ_TREND,0,time,price_low,time1,price_low);
-      //
-      //
-      //               high = iHigh(Symbol(),PERIOD_CURRENT,l);
-      //               trend = "uptrend";
-      //
-      //               index_of_last_low = Store_last_index_of_low;
-      //
-      //
-      //               choch = true;
-      //               break;
-      //
-      //              }
-      //
-      //            if(high3 > high)
-      //              {
-      //               high = high3;
-      //               Print("high update due to third condition",high);
-      //              }
-      //
-      //           }
-      //
-      //         if(choch == true)
-      //           {
-      //            hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
-      //            lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
-      //
-      //            Print(" buy and sell high index is ",index_of_last_low+1);
-      //            Print(" high price is ", hi);
-      //            Print(" low price is ", lo);
-      //
-      //            hi = 0.0;
-      //            lo =0.0;
-      //            choch = false;
-      //           }
-      //
-      //
-      //
-      //
-      //
-      //        }
-
-      //      if(checkCandle(index) == "Bearish")
-      //        {
-      //
-      //         trend = "downtrend";
-      //
-      //         // double high,low = 0.0;
-      //
-      //         // to store high and low of the value after the object
-      //         low = iLow(Symbol(),PERIOD_CURRENT,index);
-      //
-      //         //low =  iLow(Symbol(),PERIOD_CURRENT,index-1);
-      //
-      //         if(trend == "downtrend")
-      //           {
-      //
-      //
-      //
-      //
-      //            low1 = iLow(Symbol(),PERIOD_CURRENT,i);
-      //
-      //            //double low1  = iLow(Symbol(),PERIOD_CURRENT,i);
-      //
-      //            if(low1 < low)
-      //              {
-      //               low = low1;
-      //
-      //               //  Print("high break at index value",i);
-      //               // Print("index is ",index);
-      //
-      //               int count = (index-1) - i;
-      //               Print("count is ", count);
-      //
-      //               // Print("index updated ",index);
-      //
-      //               // Print("count",count);
-      //
-      //               for(int j=1; j <= count; j++)
-      //                 {
-      //
-      //                  if(checkCandle(index-j) == "Bullish")
-      //                    {
-      //                     high =  iHigh(Symbol(),PERIOD_CURRENT,index-j);
-      //                     bullish_found = true;
-      //                    }
-      //
-      //                 }
-      //
-      //               if(bullish_found == true)
-      //                 {
-      //                  high1;
-      //                  //Print("where");
-      //                  for(int k=1; k <= count; k++)
-      //                    {
-      //
-      //                     high1 = iHigh(Symbol(),PERIOD_CURRENT,index - k);
-      //                     if(high1 >= high)
-      //                       {
-      //                        //Print("here");
-      //                        high = high1;
-      //                        index_of_high = index - k;
-      //                        Print("high is updated at index : ",index - k);
-      //
-      //                       }
-      //                    }
-      //                  bullish_found = false;
-      //
-      //                 }
-      //
-      //               Print(" high price is ", high);
-      //               Print("low price is ", low);
-      //               Print("index of last updated high is ", index_of_high);
-      //
-      //               for(int l=index_of_high; l > 0; l--)
-      //                 {
-      //                  // print("hi");
-      //                  double close = iClose(Symbol(),PERIOD_CURRENT,l);
-      //                  double high3 = iHigh(Symbol(),PERIOD_CURRENT,l);
-      //
-      //                  if(close > high)
-      //                    {
-      //
-      //                     double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
-      //                     datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
-      //                     datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
-      //                     //ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
-      //
-      //
-      //                     trend = "uptrend";
-      //                     Print("choch");
-      //                     Print(l);
-      //                     index_of_last_low = i;
-      //                     Print("close", close);
-      //                     choch = true;
-      //                     break;
-      //
-      //                    }
-      //
-      //                  if(high3 > high)
-      //                    {
-      //
-      //                     double price_high = iLow(Symbol(),PERIOD_CURRENT,l+1);
-      //                     datetime time = iTime(Symbol(),PERIOD_CURRENT,l+1);
-      //                     datetime time1 = iTime(Symbol(),PERIOD_CURRENT,l-1);
-      //                     // ObjectCreate(0,"tline2",OBJ_TREND,0,time,price_high,time1,price_high);
-      //
-      //
-      //                     trend = "uptrend";
-      //                     Print("choch in condition 3");
-      //                     Print(l);
-      //                     index_of_last_low = i;
-      //                     Print("close", close);
-      //                     choch = true;
-      //                     break;
-      //
-      //                    }
-      //
-      //
-      //
-      //
-      //                 }
-      //               if(choch == true)
-      //                 {
-      //
-      //                  hi = iHigh(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
-      //                  lo = iLow(Symbol(),PERIOD_CURRENT,index_of_last_low+1);
-      //
-      //                  Print(" buy and sell high index is ",index_of_last_low+1);
-      //                  Print(" high price is ", hi);
-      //                  Print(" low price is ", lo);
-      //
-      //                  hi = 0.0;
-      //                  lo = 0.0;
-      //                  choch = false;
-      //                 }
-      //               index = i;
-      //
-      //              }
-      //
-      //           }
-      //         //
-      //
-      //        }
-     }
-
-  }
-//+------------------------------------------------------------------+
-//|                                                                  |
-//+------------------------------------------------------------------+
-int OnInit()
-  {
-
-//ObjectCreate(0,"line",OBJ_VLINE,0,D'2023.07.01 10:00:27',0);
-   object_find(object_name);
-//Print(ObjectFind(0,"line"));  // to find the object drawn on the chart
-
-   if(object_find(object_name) == true)
-     {
-
-      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
-
-      // Print("line time: ",time_of_candle);
-      int index = iBarShift(Symbol(), PERIOD_CURRENT, time_of_candle, false);
-      checkCandle(index);
-      if(checkCandle(index) == "Bullish")
-        {
-         trend = "uptrend";
-        }
-      if(checkCandle(index) == "Bearish")
-        {
-         trend = "downtrend";
-        }
-      //Print(index);
-      // Print(index);
-
-      //      datetime time_of_candle = (datetime)ObjectGetInteger(0,"line",OBJPROP_TIME,0);
-      //      Print("time is " , time_of_candle);
-      //
-      //      int index = iBarShift(0, PERIOD_CURRENT,time_of_candle, true);
-
-      //  Print("index is " , index);
-      foo(index);
-
-     }
-   else
-     {
-      Print("Object Not Found");
-     }
-
-   return(INIT_SUCCEEDED);
-  }
-//+------------------------------------------------------------------+
-//| Expert deinitialization function                                 |
-//+------------------------------------------------------------------+
-void OnDeinit(const int reason)
-  {
-//---
-
-  }
-//+------------------------------------------------------------------+
-//| Expert tick function                                             |
-//+------------------------------------------------------------------+
-void OnTick()
-  {
-   if(NewBar())
-     {
-      ObjectSetInteger(0,"tline1",OBJPROP_TIME,iTime(Symbol(), PERIOD_CURRENT,0));
-
-      ObjectSetInteger(0,"tline2",OBJPROP_TIME,iTime(Symbol(), PERIOD_CURRENT,0));
-     }
-
-
-  }
-
-//+------------------------------------------------------------------+
-//|                                                                  |
-//+------------------------------------------------------------------+
-bool NewBar()
-  {
-   static datetime Last_bar ;
-   datetime Current_bar = iTime(Symbol(), PERIOD_CURRENT,0);
-   if(Current_bar != Last_bar)
-     {
-      Last_bar = Current_bar;
-      return (true);
-     }
-   else
-     {
-      return (false);
-     }
-  }
-
-//+------------------------------------------------------------------+
-//|                                                                  |
-//+------------------------------------------------------------------+
-bool object_find(string obj)    // to find object placed by user in the chart
-  {
-   if(ObjectFind(0,obj) >= 0)
-     {
-      return true;
-     }
-   return false;
-
-  }
-//+------------------------------------------------------------------+
-//|                                                                  |
-//+------------------------------------------------------------------+
-string checkCandle(int i)  // to check the candle is bullish or bearish
-  {
-   double  close = iClose(Symbol(),PERIOD_CURRENT,i);
-   double  open  = iOpen(Symbol(),PERIOD_CURRENT,i);
-
-   if(close > open)
-     {
-      return "Bullish";
-     }
-   else
-      if(close < open)
-        {
-         return "Bearish";
-        }
-   return "empty";
-  }
-//+------------------------------------------------------------------+
-
-//+------------------------------------------------------------------+