Guidance on how to create Support & Resistance zones?

 

I am trying to create those zones people use when they look at a chart and pick some good lines where price seems to react as decision points for price action strategies.

I can do it intuitively on a chart as well, but am having trouble defining this problem clearly and translating it to good code.

A good S&R zone is where price has touched and created impulsive turning points. Zones shouldn't be too close together, for example let's say 100 pips between daily zones.

I want to be able to mark and draw these zones as decision points and run the rest of the strategy when we are in these zones. For example, we have been in an uptrend, we have entered a zone, and now we get a strong bearish engulfing candle, so we should probably short, etc.

I guess if I am running daily zones, I'd like to check at the beginning of the week to redraw some fresh zones if that's appropriate. I am not sure what all good parameters would be in general for SRPeriod, maxTouches, etc. and could use suggestions. 

Also the lines block everything haha, how can I make it less opacity/prettier?

Here is what I was able to come up with so far. The zones it comes up with are decent, but I am sure this can be improved. If anyone has any ideas or suggestions, please let me know!

double zones[];
void SRZones() {
   int SRPeriod = 6*30;
   int SRTf = PERIOD_D1;
   double pipsBetween = 100*(_Point*10);
   int minTouches = 2;
   int maxTouches = 20;
   double loLo = Low[iLowest(_Symbol, SRTf, MODE_LOW, SRPeriod, 0)];
   double hiHi = High[iHighest(_Symbol, SRTf, MODE_HIGH, SRPeriod, 0)];
   for (double line = loLo; line < hiHi; line += pipsBetween) {
       int touches = 0;
       for (int i = 0; i < SRPeriod; i++) {
           if (Low[i] < line && line < High[i]) {
               touches++;
           }
       }
       if (minTouches <= touches && touches <= maxTouches) {
         string objectId = "SR"+line;
         if (ObjectFind(objectId) == -1) {
            ObjectCreate(objectId, OBJ_HLINE, 0, Time[0], line);
            ObjectSet(objectId, OBJPROP_COLOR, clrDeepSkyBlue);
            ObjectSet(objectId, OBJPROP_WIDTH, touches);
            ObjectSet(objectId, OBJPROP_BACK, false);
            ArrayPush(zones, line);
         }
       }
   }
}
int InZone(int i) {
   for (int j = 0; j < ArraySize(zones); j++) {
      if (Low[i] < zones[j] && zones[j] < High[i]) {
         return j;
      }
   }
   return -1;
}

void ArrayPush(double &A[], double data) {
   ArrayResize(A, ArraySize(A) + 1);
   A[ArraySize(A) - 1] = data;
}
void OnTick() {
   if (DayOfWeek() == MONDAY) {
      ObjectsDeleteAll(0, OBJ_HLINE);
      ArrayFree(zones);
      SRZones();
   }

   if (InZone(1) != -1) {
       // execute rest of strategy
   }
}
 
I'm interested too, but unfortunately i'm not  a programmer. Keep in touch