LINUX.ORG.RU

почините быдло-код, с-кодеры

 


0

1

как вот это запилить по-компактнее, не прессуя смайлы и, тем самым, не ухудшая читаемость

      if ( ExtremumBuffer[bar]>ExtremumBuffer[bar+1]   && ExtremumBuffer[bar]<ExtremumBuffer[bar+2]   &&
           ExtremumBuffer[bar+2]>ExtremumBuffer[bar+4] && ExtremumBuffer[bar+3]<ExtremumBuffer[bar+4]
           &&
           (
            (ExtremumBuffer[bar+4]>ExtremumBuffer[bar] && 
            (ExtremumBuffer[bar+4]-ExtremumBuffer[bar])<=MarketInfo(Symbol(),MODE_TICKSIZE)*max_percent_diff)
            ||
            (ExtremumBuffer[bar]>ExtremumBuffer[bar+4] && 
            (ExtremumBuffer[bar]-ExtremumBuffer[bar+4])<=MarketInfo(Symbol(),MODE_TICKSIZE)*max_percent_diff)
           )
           &&
           (
            (
            (ExtremumBufferShift[bar]-ExtremumBufferShift[bar+2])>(ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+4])
               &&
            ((ExtremumBufferShift[bar]-ExtremumBufferShift[bar+2])/(ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+4])*100)<=(max_percent_diff+100)
            )
            ||
            (
            (ExtremumBufferShift[bar]-ExtremumBufferShift[bar+2])<(ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+4])
               &&
            ((ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+4])/(ExtremumBufferShift[bar]-ExtremumBufferShift[bar+2])*100)<=(max_percent_diff+100)
            )
           )
           &&
           (
            (
            (ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+1])>(ExtremumBufferShift[bar+3]-ExtremumBufferShift[bar+2])
               &&
            ((ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+1])/(ExtremumBufferShift[bar+3]-ExtremumBufferShift[bar+2])*100)<=(max_percent_diff+100)
            )
            ||
            (
            (ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+1])<(ExtremumBufferShift[bar+3]-ExtremumBufferShift[bar+2])
               &&
            ((ExtremumBufferShift[bar+3]-ExtremumBufferShift[bar+2])/(ExtremumBufferShift[bar+2]-ExtremumBufferShift[bar+1])*100)<=(max_percent_diff+100)
            )
           )
           &&
           (
            (
            (ExtremumBufferShift[bar+1]-ExtremumBufferShift[bar])>(ExtremumBufferShift[bar+4]-ExtremumBufferShift[bar+3])
               &&
            ((ExtremumBufferShift[bar+1]-ExtremumBufferShift[bar])/(ExtremumBufferShift[bar+4]-ExtremumBufferShift[bar+3])*100)<=(max_percent_diff+100)
            )
            ||
            (
            (ExtremumBufferShift[bar+1]-ExtremumBufferShift[bar])>(ExtremumBufferShift[bar+4]-ExtremumBufferShift[bar+3])
               &&
            ((ExtremumBufferShift[bar+4]-ExtremumBufferShift[bar+3])/(ExtremumBufferShift[bar+1]-ExtremumBufferShift[bar])*100)<=(max_percent_diff+100)
            )
           )
         )
         {
         bla-bla-bla
         }

★★★★
Ответ на: комментарий от N
char ediffshift(double * ebufshift, int i, int j, int k, int l, double maxdiff) {
  double diff1 = ebufshift[i] - ebufshift[j];
  double diff2 = ebufshift[k] - ebufshift[l];
  if (diff1 < diff2) {
    double tmp = diff1;
    diff1 = diff2;
    diff2 = tmp;
  }
  return (100 * diff1 / diff2 < 100 + maxdiff);
}

if ((ebuf[bar] > ebuf[bar+1]) && (ebuf[bar] < ebuf[bar+2])
  && (ebuf[bar+2] > ebuf[bar+4]) && (ebuf[bar+3] < ebuf[bar+4])
  && (abs(ebuf[bar] - ebuf[bar+4]) <= MarketInfo(Symbol(), MODE_TICKSIZE) * maxdiff)
  && ediffshift(ebufshift, 0, 2, 2, 4, maxdiff)
  && ediffshift(ebufshift, 2, 1, 3, 2, maxdiff)
  && ediffshift(ebufshift, 1, 0, 4, 3, maxdiff)) {
    bla-bla-bla;
}
N
()
Ответ на: комментарий от N
char ediffshift(double * ebufshift, int bar, int i, int j, int k, int l, double maxdiff) {
  double diff1 = ebufshift[bar+i] - ebufshift[bar+j];
  double diff2 = ebufshift[bar+k] - ebufshift[bar+l];
  if (diff1 < diff2) {
    double tmp = diff1;
    diff1 = diff2;
    diff2 = tmp;
  }
  return (100 * diff1 / diff2 < 100 + maxdiff);
}

if ((ebuf[bar] > ebuf[bar+1]) && (ebuf[bar] < ebuf[bar+2])
  && (ebuf[bar+2] > ebuf[bar+4]) && (ebuf[bar+3] < ebuf[bar+4])
  && (abs(ebuf[bar] - ebuf[bar+4]) <= MarketInfo(Symbol(), MODE_TICKSIZE) * maxdiff)
  && ediffshift(ebufshift, bar, 0, 2, 2, 4, maxdiff)
  && ediffshift(ebufshift, bar, 2, 1, 3, 2, maxdiff)
  && ediffshift(ebufshift, bar, 1, 0, 4, 3, maxdiff)) {
    bla-bla-bla;
}

Fix.

N
()
Ответ на: комментарий от N
char ediffshift(double * ebufshift, int bar, int i, int j, int k, int l, double maxdiff) {
  double diff1 = ebufshift[bar+i] - ebufshift[bar+j];
  double diff2 = ebufshift[bar+k] - ebufshift[bar+l];
  if (diff1 < diff2) {
    double tmp = diff1;
    diff1 = diff2;
    diff2 = tmp;
  }
  if (diff2 != 0)
    return (100 * diff1 / diff2 < 100 + maxdiff);
  else
    return 0;
}

if ((ebuf[bar] > ebuf[bar+1]) && (ebuf[bar] < ebuf[bar+2])
  && (ebuf[bar+2] > ebuf[bar+4]) && (ebuf[bar+3] < ebuf[bar+4])
  && (abs(ebuf[bar] - ebuf[bar+4]) <= MarketInfo(Symbol(), MODE_TICKSIZE) * maxdiff)
  && ediffshift(ebufshift, bar, 0, 2, 2, 4, maxdiff)
  && ediffshift(ebufshift, bar, 2, 1, 3, 2, maxdiff)
  && ediffshift(ebufshift, bar, 1, 0, 4, 3, maxdiff)) {
    bla-bla-bla;
}

И еще один fix.

N
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.