AhtashamShahzad3 vor 2 Jahren
Ursprung
Commit
a35cee65d4
2 geänderte Dateien mit 138 neuen und 4 gelöschten Zeilen
  1. BIN
      BOS_CHOCH.ex5
  2. 138 4
      BOS_CHOCH.mq5

BIN
BOS_CHOCH.ex5


+ 138 - 4
BOS_CHOCH.mq5

@@ -603,7 +603,7 @@ void choch(int i)
603 603
          // -----------------------------------------------------------------------------------------------------------------------------------------------------------
604 604
          int chock_index = iBarShift(Symbol(), PERIOD_CURRENT, choch_index_time, false);
605 605
          chock_index++;
606
-         datetime ti = iTime(Symbol(),PERIOD_CURRENT,chock_index);
606
+         datetime lastChochTimeUp = iTime(Symbol(),PERIOD_CURRENT,chock_index);
607 607
 
608 608
          HIGH = iHigh(Symbol(),PERIOD_CURRENT,chock_index);  // save high and low of the chock prev index to compare
609 609
          LOW  = iLow(Symbol(),PERIOD_CURRENT,chock_index);
@@ -646,7 +646,7 @@ void choch(int i)
646 646
          Print("from where you end ",chock_index1);
647 647
 
648 648
          bool condition_not_match = false;
649
-         for(int p=chock_index - 2 ; p >=chock_index1; p--)
649
+         for(int p=chock_index - 2 ; p > chock_index1; p--)
650 650
            {
651 651
             if(iLow(Symbol(),PERIOD_CURRENT,p) < HIGH)
652 652
               {
@@ -675,7 +675,7 @@ void choch(int i)
675 675
            }
676 676
          else
677 677
            {
678
-            tp_date_time_sell = ti;
678
+            tp_date_time_sell = lastChochTimeUp;
679 679
            }
680 680
 
681 681
          //-------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1035,6 +1035,9 @@ void choch(int i)
1035 1035
          Print("from where you end ",chock_index1);
1036 1036
 
1037 1037
          bool condition_not_match = false;
1038
+         Print("time of chock_index - 2 is", iTime(Symbol(),PERIOD_CURRENT,chock_index-2));
1039
+         Print("time of current candle is ",iTime(Symbol(),PERIOD_CURRENT,1));
1040
+
1038 1041
          for(int p=chock_index -  2 ; p > chock_index1; p--)
1039 1042
            {
1040 1043
             // Print("index is ",p," time is ", iTime(Symbol(),PERIOD_CURRENT,p));
@@ -2029,7 +2032,14 @@ int OnInit()
2029 2032
       ObjectCreate(0,"low",OBJ_TREND,0,iTime(Symbol(),PERIOD_CURRENT,user_input_index),low,iTime(Symbol(),PERIOD_CURRENT,0),low);
2030 2033
       ObjectSetInteger(0,"low",OBJPROP_RAY_RIGHT,true);
2031 2034
       ObjectSetInteger(0,"low",OBJPROP_COLOR,clrRed);
2032
-      
2035
+
2036
+      choch_index_time = iTime(Symbol(),PERIOD_CURRENT,user_input_index);
2037
+
2038
+
2039
+
2040
+
2041
+
2042
+
2033 2043
       Entry_strategy(user_input_index);
2034 2044
 
2035 2045
      }
@@ -2089,9 +2099,74 @@ void OnDeinit(const int reason)
2089 2099
 //+------------------------------------------------------------------+
2090 2100
 void OnTick()
2091 2101
   {
2102
+
2092 2103
    if(NewBar() == true)
2093 2104
      {
2094 2105
 
2106
+   int dx = iBarShift(Symbol(), PERIOD_CURRENT,choch_index_time, false);
2107
+//
2108
+//      double HI = iHigh(Symbol(),PERIOD_CURRENT,dx+1);  // save high and low of the chock prev index to compare
2109
+//      double LO  = iLow(Symbol(),PERIOD_CURRENT,dx+1);
2110
+//      if(trend == "downtrend")
2111
+//        {
2112
+//         for(int p=dx-1; p >= 1; p--)
2113
+//           {
2114
+//            if(iHigh(Symbol(),PERIOD_CURRENT,p) > LO)
2115
+//              {
2116
+//               tp_date_time_sell = 0.0;
2117
+//               Print("high is ",iHigh(Symbol(),PERIOD_CURRENT,p), "and index of high is ",p);
2118
+//               Print("TArget line deleted in on tick "," at index p", " and time period is ",iTime(Symbol(),PERIOD_CURRENT,p));
2119
+//
2120
+//
2121
+//               if(object_find("target line") > 0)
2122
+//                 {
2123
+//                  ObjectDelete(0,"target line");
2124
+//                 }
2125
+//
2126
+//               if(object_find("target line1") > 0)
2127
+//                 {
2128
+//                  ObjectDelete(0,"target line1");
2129
+//                 }
2130
+//               break;
2131
+//              }
2132
+//           }
2133
+//        }
2134
+//
2135
+//      if(trend == "uptrend")
2136
+//        {
2137
+//         for(int p=dx-1; p >= 1; p--)
2138
+//           {
2139
+//            if(iLow(Symbol(),PERIOD_CURRENT,p) < HI)
2140
+//              {
2141
+//               Print("low is ",LO, "and index of low is ",p);
2142
+//               Print("Target line deleted in on tick "," at index p", " and time period is ",iTime(Symbol(),PERIOD_CURRENT,p));
2143
+//
2144
+//               tp_date_time_buy = 0.0;
2145
+//
2146
+//               if(object_find("target line") > 0)
2147
+//                 {
2148
+//                  ObjectDelete(0,"target line");
2149
+//                 }
2150
+//
2151
+//               if(object_find("target line1") > 0)
2152
+//                 {
2153
+//                  ObjectDelete(0,"target line1");
2154
+//                 }
2155
+//               break;
2156
+//
2157
+//              }
2158
+//           }
2159
+//
2160
+//        }
2161
+
2162
+
2163
+
2164
+
2165
+
2166
+
2167
+
2168
+
2169
+
2095 2170
       Entry_strategy(1);
2096 2171
 
2097 2172
       // for entry condition candel 1
@@ -2165,6 +2240,35 @@ void OnTick()
2165 2240
 
2166 2241
             if(od_1[m].EntryCon == 2 && TimeCurrent() > od_1[m].Time_of_candle_For_trade && od_1[m].Signal == "buy" && od_1[m].Time_of_candle_For_trade != 0  /*&& HIGH != 0 && LOW != 0*/)
2167 2242
               {
2243
+               if(trend == "uptrend")
2244
+                 {
2245
+                  for(int p=dx-1; p >= 1; p--)
2246
+                    {
2247
+                     double ib =iBarShift(Symbol(), PERIOD_CURRENT,tp_date_time_buy,false);
2248
+                     Print("low of the last choch index is",iLow(Symbol(),PERIOD_CURRENT,ib));
2249
+                     if(iHigh(Symbol(),PERIOD_CURRENT,p) > iLow(Symbol(),PERIOD_CURRENT,ib))
2250
+                       {
2251
+                        tp_date_time_buy = 0.0;
2252
+                        Print("high is ",iHigh(Symbol(),PERIOD_CURRENT,p)," last choch+1: ",iLow(Symbol(),PERIOD_CURRENT,ib));
2253
+                        Print("TArget line deleted in on entry 2 "," at index p", " and time period is ",iTime(Symbol(),PERIOD_CURRENT,p));
2254
+
2255
+
2256
+                        if(object_find("target line") > 0)
2257
+                          {
2258
+                           ObjectDelete(0,"target line");
2259
+                          }
2260
+
2261
+                        if(object_find("target line1") > 0)
2262
+                          {
2263
+                           ObjectDelete(0,"target line1");
2264
+                          }
2265
+                        break;
2266
+                       }
2267
+                    }
2268
+                 }
2269
+
2270
+
2271
+
2168 2272
                // Print("time is greater and signal is buy ",TimeCurrent());
2169 2273
                // Print("i am in enrtry condition 1 : ");
2170 2274
 
@@ -2198,6 +2302,36 @@ void OnTick()
2198 2302
             if(od_1[m].EntryCon == 2 && TimeCurrent() > od_1[m].Time_of_candle_For_trade && od_1[m].Signal == "sell" && od_1[m].Time_of_candle_For_trade != 0  /*&& HIGH != 0 && LOW != 0*/)
2199 2303
               {
2200 2304
 
2305
+               if(trend == "downtrend")
2306
+                 {
2307
+
2308
+                  for(int p=dx-1; p >= 1; p--)
2309
+                    {
2310
+                     double ib =iBarShift(Symbol(), PERIOD_CURRENT,tp_date_time_buy,false);
2311
+                     Print("high of the last choch index is",iHigh(Symbol(),PERIOD_CURRENT,ib));
2312
+                     if(iLow(Symbol(),PERIOD_CURRENT,p) < iHigh(Symbol(),PERIOD_CURRENT,ib))
2313
+                       {
2314
+                     //   Print("low is ",LO, "and index of low is ",p);
2315
+                        Print("Target line deleted in on entry 2 "," at index p", " and time period is ",iTime(Symbol(),PERIOD_CURRENT,p));
2316
+
2317
+                        tp_date_time_sell = 0.0;
2318
+
2319
+                        if(object_find("target line") > 0)
2320
+                          {
2321
+                           ObjectDelete(0,"target line");
2322
+                          }
2323
+
2324
+                        if(object_find("target line1") > 0)
2325
+                          {
2326
+                           ObjectDelete(0,"target line1");
2327
+                          }
2328
+                        break;
2329
+
2330
+                       }
2331
+                    }
2332
+
2333
+                 }
2334
+
2201 2335
                int reversal_indexx = iBarShift(Symbol(), PERIOD_CURRENT,od_1[m].reversal_index_date_time,false);
2202 2336
                int close_index = iBarShift(Symbol(), PERIOD_CURRENT,od_1[m].choch_index_date_time,false);
2203 2337