TRUE Forex

Просмотр кода форекс индикатора !XPS v7 PRICE CHANNEL THREE.mq4

// +----------------------------------------------------------------------------------------+ //
// |    .-._______                           XARD777                          _______.-.    | //
// |---( )_)______)                 Knowledge of the ancients                (______(_( )---| //
// |  (    ()___)                              \¦/                             (___()    )  | //
// |       ()__)                              (o o)                             (__()       | //
// |--(___()_)__________________________oOOo___(_)___oOOo_________________________(_()___)--| //
// |_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|_____|____|_____| //
// |                                                                                   2011 | //
// |----------------------------------------------------------------------------------------| //
// |                 File:     !XPS v7 PRICE CHANNEL THREE.mq4                              | //
// | Programming language:     MQL4                                                         | //
// | Development platform:     MetaTrader 4                                                 | //
// |          End product:     THIS SOFTWARE IS FOR USE ONLY BY XARD777                     | //
// |                                                                                        | //
// |                                                         [Xard777 Proprietory Software] | //
// +----------------------------------------------------------------------------------------+ //

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 White
#property indicator_width1 4
#property indicator_color2 Yellow
#property indicator_width2 4
#property indicator_color3 White
#property indicator_width3 1
#property indicator_color4 Yellow
#property indicator_width4 1
#property indicator_color5 CLR_NONE
#property indicator_color6 CLR_NONE

int TimeFrame = 0;
int UpBandPrice = 2;
int LoBandPrice = 3;
int UpBandPeriod = 9;
int LoBandPeriod = 9;
double UpBandRisk = 0.3;
double LoBandRisk = 0.3;
int UpBandPreSmooth = 1;
int LoBandPreSmooth = 1;
int UpBandMAMode = 0;
int LoBandMAMode = 0;
extern int SignalMode = 1;
extern int StopMode = 1;
int BarsMode = 1;
extern int AlertMode = 1;
extern int WarningMode = 0;
double AUTOSELECT;
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
double g_ibuf_160[];
double g_ibuf_164[];
double g_ibuf_168[];
double g_ibuf_172[];
double gda_176[][12];
double gda_180[][2];
double gda_184[][2];
double gda_188[][2];
double gda_192[][2];
int gi_196;
int gi_200;
int gi_204;
int gi_208;
string gs_212;
string gs_220;
int g_datetime_228;
bool gi_232 = FALSE;
bool gi_236 = FALSE;
string gs_240;

int init() {
   if (StopMode > 0) {
      SetIndexStyle(0, DRAW_LINE);
      SetIndexStyle(1, DRAW_LINE);
   }
   if (SignalMode > 0) {
      SetIndexStyle(2, DRAW_ARROW);
      SetIndexArrow(2, 108);
      SetIndexStyle(3, DRAW_ARROW);
      SetIndexArrow(3, 108);
   }
   if (BarsMode > 0) {
      SetIndexStyle(4, DRAW_NONE);
      SetIndexStyle(5, DRAW_NONE);
   }
   if (TimeFrame == 0 || TimeFrame < Period()) TimeFrame = Period();
   gi_196 = MathMax(UpBandPeriod + UpBandPreSmooth, LoBandPreSmooth) * TimeFrame / Period();
   switch (LoBandMAMode) {
   case 1:
      gs_212 = "EMA(";
      break;
   case 2:
      gs_212 = "Wilder(";
      break;
   case 3:
      gs_212 = "LWMA(";
      break;
   case 4:
      gs_212 = "SineWMA(";
      break;
   case 5:
      gs_212 = "TriMA(";
      break;
   case 6:
      gs_212 = "LSMA(";
      break;
   case 7:
      gs_212 = "SMMA(";
      break;
   case 8:
      gs_212 = "HMA(";
      break;
   case 9:
      gs_212 = "ZeroLagEMA(";
      break;
   case 10:
      gs_212 = "DEMA(";
      break;
   case 11:
      gs_212 = "T3(";
      break;
   case 12:
      gs_212 = "InstTrend(";
      break;
   case 13:
      gs_212 = "Median(";
      break;
   case 14:
      gs_212 = "GeometricMean(";
      break;
   case 15:
      gs_212 = "REMA(";
      break;
   case 16:
      gs_212 = "ILRS(";
      break;
   case 17:
      gs_212 = "IE/2(";
      break;
   case 18:
      gs_212 = "TriMA_gen(";
      break;
   case 19:
      gs_212 = "VWMA(";
      break;
   case 20:
      gs_212 = "JSmooth(";
      break;
   default:
      LoBandMAMode = FALSE;
      gs_212 = "SMA(";
   }
   switch (UpBandMAMode) {
   case 1:
      gs_220 = "EMA(";
      break;
   case 2:
      gs_220 = "Wilder(";
      break;
   case 3:
      gs_220 = "LWMA(";
      break;
   case 4:
      gs_220 = "SineWMA(";
      break;
   case 5:
      gs_220 = "TriMA(";
      break;
   case 6:
      gs_220 = "LSMA(";
      break;
   case 7:
      gs_220 = "SMMA(";
      break;
   case 8:
      gs_220 = "HMA(";
      break;
   case 9:
      gs_220 = "ZeroLagEMA(";
      break;
   case 10:
      gs_220 = "DEMA(";
      break;
   case 11:
      gs_220 = "T3(";
      break;
   case 12:
      gs_220 = "InstTrend(";
      break;
   case 13:
      gs_220 = "Median(";
      break;
   case 14:
      gs_220 = "GeometricMean(";
      break;
   case 15:
      gs_220 = "REMA(";
      break;
   case 16:
      gs_220 = "ILRS(";
      break;
   case 17:
      gs_220 = "IE/2(";
      break;
   case 18:
      gs_220 = "TriMA_gen(";
      break;
   case 19:
      gs_220 = "VWMA(";
      break;
   case 20:
      gs_220 = "JSmooth(";
      break;
   default:
      UpBandMAMode = FALSE;
      gs_220 = "SMA(";
   }
   switch (TimeFrame) {
   case 1:
      gs_240 = "M1";
      break;
   case 5:
      gs_240 = "M5";
      break;
   case 15:
      gs_240 = "M15";
      break;
   case 30:
      gs_240 = "M30";
      break;
   case 60:
      gs_240 = "H1";
      break;
   case 240:
      gs_240 = "H4";
      break;
   case 1440:
      gs_240 = "D1";
      break;
   case 10080:
      gs_240 = "W1";
      break;
   case 43200:
      gs_240 = "MN1";
      break;
   default:
      gs_240 = "Current";
   }
   
   //-----------------------------
   
   switch ( Period() )
   {
   case     1: TimeFrame = PERIOD_H1;break;
   case     5: TimeFrame = PERIOD_H4;break;
   case    15: TimeFrame = PERIOD_D1;break;
   case    30: TimeFrame = PERIOD_W1;break;
   case    60: TimeFrame = PERIOD_W1;break;
   case   240: TimeFrame = PERIOD_MN1;break;
   case  1440: TimeFrame = PERIOD_MN1;break;
   case 10080: TimeFrame = PERIOD_MN1;break;
   default   : TimeFrame = PERIOD_D1;break;
   }
   
   //-----------------------------
   
   
   SetIndexDrawBegin(0, gi_196);
   SetIndexLabel(0, "UpTrend[" + gs_240 + "](" + LoBandPrice + "," + gs_212 + LoBandPeriod + "," + DoubleToStr(LoBandRisk, 4) + ")");
   SetIndexLabel(1, "DnTrend[" + gs_240 + "](" + UpBandPrice + "," + gs_220 + UpBandPeriod + "," + DoubleToStr(UpBandRisk, 4) + ")");
   if (SignalMode > 0) {
      SetIndexLabel(2, "UpSignal[" + gs_240 + "](" + LoBandPrice + "," + gs_212 + LoBandPeriod + "," + DoubleToStr(LoBandRisk, 4) + ")");
      SetIndexLabel(3, "DnSignal[" + gs_240 + "](" + UpBandPrice + "," + gs_220 + UpBandPeriod + "," + DoubleToStr(UpBandRisk, 4) + ")");
   }
   SetIndexDrawBegin(0, gi_196);
   SetIndexDrawBegin(1, gi_196);
   IndicatorBuffers(7);
   if (StopMode > 0) {
      SetIndexBuffer(0, g_ibuf_148);
      SetIndexBuffer(1, g_ibuf_152);
   }
   if (SignalMode > 0) {
      SetIndexBuffer(2, g_ibuf_156);
      SetIndexBuffer(3, g_ibuf_160);
      SetIndexDrawBegin(2, gi_196);
      SetIndexDrawBegin(3, gi_196);
   }
   if (BarsMode > 0) {
      SetIndexBuffer(4, g_ibuf_164);
      SetIndexBuffer(5, g_ibuf_168);
   }
   SetIndexBuffer(6, g_ibuf_172);
   return (0);
}

int start() {
   int li_0;
   int l_index_12;
   double lda_20[];
   double lda_24[];
   double lda_28[];
   double lda_32[];
   double lda_36[];
   double lda_40[];
   double lda_44[];
   double lda_48[];
   double lda_52[];
   double lda_56[];
   double lda_60[];
   double ld_72;
   double ld_80;
   double ld_88;
   double ld_96;
   string ls_104;
   int li_16 = IndicatorCounted();
   if (TimeFrame != Period()) gi_200 = iBars(NULL, TimeFrame);
   else gi_200 = Bars;
   if (gi_200 != gi_204) {
      ArrayResize(lda_20, gi_200);
      ArrayResize(lda_24, gi_200);
      ArrayResize(lda_28, gi_200);
      ArrayResize(lda_32, gi_200);
      ArrayResize(lda_36, gi_200);
      ArrayResize(lda_40, gi_200);
      ArrayResize(lda_60, gi_200);
      ArrayResize(lda_52, gi_200);
      ArrayResize(lda_56, gi_200);
      if (SignalMode > 0) {
         ArrayResize(lda_44, gi_200);
         ArrayResize(lda_48, gi_200);
      }
      if (UpBandMAMode == 10 || UpBandMAMode == 11 || UpBandMAMode == 20 || LoBandMAMode == 10 || LoBandMAMode == 11 || LoBandMAMode == 20) ArrayResize(gda_176, gi_200);
      if ((UpBandPrice > PRICE_WEIGHTED && UpBandPrice <= 10) || (LoBandPrice > PRICE_WEIGHTED && LoBandPrice <= 10)) {
         ArrayResize(gda_180, gi_200);
         ArrayResize(gda_184, gi_200);
         ArrayResize(gda_188, gi_200);
         ArrayResize(gda_192, gi_200);
      }
      gi_204 = gi_200;
   }
   if (li_16 < 1) {
      for (int l_index_8 = Bars - 1; l_index_8 > 0; l_index_8--) {
         g_ibuf_148[l_index_8] = EMPTY_VALUE;
         g_ibuf_152[l_index_8] = EMPTY_VALUE;
         g_ibuf_156[l_index_8] = EMPTY_VALUE;
         g_ibuf_160[l_index_8] = EMPTY_VALUE;
      }
      gi_208 = 0;
   }
   if (gi_208 > 0) gi_208--;
   for (int li_4 = gi_208; li_4 < gi_200; li_4++) {
      if (UpBandPrice <= PRICE_WEIGHTED) lda_20[li_4] = iMA(NULL, TimeFrame, 1, 0, MODE_SMA, UpBandPrice, gi_200 - li_4 - 1);
      else
         if (UpBandPrice > PRICE_WEIGHTED && UpBandPrice <= 10) lda_20[li_4] = HeikenAshi(0, TimeFrame, UpBandPrice - 7, gi_200 - li_4 - 1);
      if (LoBandPrice <= PRICE_WEIGHTED) lda_24[li_4] = iMA(NULL, TimeFrame, 1, 0, MODE_SMA, LoBandPrice, gi_200 - li_4 - 1);
      else
         if (LoBandPrice > PRICE_WEIGHTED && LoBandPrice <= 10) lda_24[li_4] = HeikenAshi(1, TimeFrame, LoBandPrice - 7, gi_200 - li_4 - 1);
      switch (UpBandMAMode) {
      case 1:
         lda_28[li_4] = EMA(lda_20[li_4], lda_28, UpBandPreSmooth, li_4);
         break;
      case 2:
         lda_28[li_4] = Wilder(lda_20, lda_28, UpBandPreSmooth, li_4);
         break;
      case 3:
         lda_28[li_4] = LWMA(lda_20, UpBandPreSmooth, li_4);
         break;
      case 4:
         lda_28[li_4] = SineWMA(lda_20, UpBandPreSmooth, li_4);
         break;
      case 5:
         lda_28[li_4] = TriMA(lda_20, UpBandPreSmooth, li_4);
         break;
      case 6:
         lda_28[li_4] = LSMA(lda_20, UpBandPreSmooth, li_4);
         break;
      case 7:
         lda_28[li_4] = SMMA(lda_20, lda_28, UpBandPreSmooth, li_4);
         break;
      case 8:
         lda_28[li_4] = HMA(lda_20, UpBandPreSmooth, li_4);
         break;
      case 9:
         lda_28[li_4] = ZeroLagEMA(lda_20, lda_28, UpBandPreSmooth, li_4);
         break;
      case 10:
         lda_28[li_4] = DEMA(0, lda_20[li_4], UpBandPreSmooth, 1, li_4);
         break;
      case 11:
         lda_28[li_4] = T3(0, lda_20[li_4], UpBandPreSmooth, 0.7, li_4);
         break;
      case 12:
         lda_28[li_4] = ITrend(lda_20, lda_28, UpBandPreSmooth, li_4);
         break;
      case 13:
         lda_28[li_4] = Median(lda_20, UpBandPreSmooth, li_4);
         break;
      case 14:
         lda_28[li_4] = GeoMean(lda_20, UpBandPreSmooth, li_4);
         break;
      case 15:
         lda_28[li_4] = REMA(lda_20[li_4], lda_28, UpBandPreSmooth, 0.5, li_4);
         break;
      case 16:
         lda_28[li_4] = ILRS(lda_20, UpBandPreSmooth, li_4);
         break;
      case 17:
         lda_28[li_4] = IE2(lda_20, UpBandPreSmooth, li_4);
         break;
      case 18:
         lda_28[li_4] = TriMA_gen(lda_20, UpBandPreSmooth, li_4);
         break;
      case 19:
         lda_28[li_4] = VWMA(lda_20, UpBandPreSmooth, li_4);
         break;
      case 20:
         lda_28[li_4] = JSmooth(0, lda_20[li_4], UpBandPreSmooth, 1, li_4);
         break;
      default:
         lda_28[li_4] = SMA(lda_20, UpBandPreSmooth, li_4);
      }
      switch (LoBandMAMode) {
      case 1:
         lda_32[li_4] = EMA(lda_24[li_4], lda_32, LoBandPreSmooth, li_4);
         break;
      case 2:
         lda_32[li_4] = Wilder(lda_24, lda_32, LoBandPreSmooth, li_4);
         break;
      case 3:
         lda_32[li_4] = LWMA(lda_24, LoBandPreSmooth, li_4);
         break;
      case 4:
         lda_32[li_4] = SineWMA(lda_24, LoBandPreSmooth, li_4);
         break;
      case 5:
         lda_32[li_4] = TriMA(lda_24, LoBandPreSmooth, li_4);
         break;
      case 6:
         lda_32[li_4] = LSMA(lda_24, LoBandPreSmooth, li_4);
         break;
      case 7:
         lda_32[li_4] = SMMA(lda_24, lda_32, LoBandPreSmooth, li_4);
         break;
      case 8:
         lda_32[li_4] = HMA(lda_24, LoBandPreSmooth, li_4);
         break;
      case 9:
         lda_32[li_4] = ZeroLagEMA(lda_24, lda_32, LoBandPreSmooth, li_4);
         break;
      case 10:
         lda_32[li_4] = DEMA(6, lda_24[li_4], LoBandPreSmooth, 1, li_4);
         break;
      case 11:
         lda_32[li_4] = T3(6, lda_24[li_4], LoBandPreSmooth, 0.7, li_4);
         break;
      case 12:
         lda_32[li_4] = ITrend(lda_24, lda_32, LoBandPreSmooth, li_4);
         break;
      case 13:
         lda_32[li_4] = Median(lda_24, LoBandPreSmooth, li_4);
         break;
      case 14:
         lda_32[li_4] = GeoMean(lda_24, LoBandPreSmooth, li_4);
         break;
      case 15:
         lda_32[li_4] = REMA(lda_24[li_4], lda_32, LoBandPreSmooth, 0.5, li_4);
         break;
      case 16:
         lda_32[li_4] = ILRS(lda_24, LoBandPreSmooth, li_4);
         break;
      case 17:
         lda_32[li_4] = IE2(lda_24, LoBandPreSmooth, li_4);
         break;
      case 18:
         lda_32[li_4] = TriMA_gen(lda_24, LoBandPreSmooth, li_4);
         break;
      case 19:
         lda_32[li_4] = VWMA(lda_24, LoBandPreSmooth, li_4);
         break;
      case 20:
         lda_32[li_4] = JSmooth(6, lda_24[li_4], LoBandPreSmooth, 1, li_4);
         break;
      default:
         lda_32[li_4] = SMA(lda_24, LoBandPreSmooth, li_4);
      }
      ld_72 = 0;
      for (l_index_8 = 0; l_index_8 < UpBandPeriod; l_index_8++)
         if (lda_28[li_4 - l_index_8] > ld_72) ld_72 = lda_28[li_4 - l_index_8];
      ld_80 = 100000000;
      for (l_index_8 = 0; l_index_8 < LoBandPeriod; l_index_8++)
         if (lda_32[li_4 - l_index_8] < ld_80) ld_80 = lda_32[li_4 - l_index_8];
      lda_36[li_4] = ld_72 - (ld_72 - ld_80) * UpBandRisk;
      lda_40[li_4] = ld_80 + (ld_72 - ld_80) * LoBandRisk;
      lda_60[li_4] = lda_60[li_4 - 1];
      if (UpBandRisk == 0.0) {
         if (iClose(NULL, TimeFrame, gi_200 - li_4 - 1) > lda_36[li_4 - 1] && lda_60[li_4 - 1] <= 0.0) lda_60[li_4] = 1;
      } else
         if (iClose(NULL, TimeFrame, gi_200 - li_4 - 1) > lda_36[li_4] && lda_60[li_4 - 1] <= 0.0) lda_60[li_4] = 1;
      if (LoBandRisk == 0.0) {
         if (iClose(NULL, TimeFrame, gi_200 - li_4 - 1) < lda_40[li_4 - 1] && lda_60[li_4 - 1] >= 0.0) lda_60[li_4] = -1;
      } else
         if (iClose(NULL, TimeFrame, gi_200 - li_4 - 1) < lda_40[li_4] && lda_60[li_4 - 1] >= 0.0) lda_60[li_4] = -1;
      if (lda_60[li_4] > 0.0) {
         if (lda_40[li_4] < lda_40[li_4 - 1]) lda_40[li_4] = lda_40[li_4 - 1];
         lda_52[li_4] = lda_40[li_4];
         if (lda_60[li_4 - 1] <= 0.0 && SignalMode > 0) {
            lda_44[li_4] = lda_40[li_4];
            if (WarningMode > 0 && li_4 == gi_200 - 1) PlaySound("alert.wav");
         } else lda_44[li_4] = EMPTY_VALUE;
         lda_48[li_4] = EMPTY_VALUE;
         lda_56[li_4] = EMPTY_VALUE;
      } else {
         if (lda_60[li_4] < 0.0) {
            if (lda_36[li_4] > lda_36[li_4 - 1]) lda_36[li_4] = lda_36[li_4 - 1];
            lda_56[li_4] = lda_36[li_4];
            if (lda_60[li_4 - 1] >= 0.0 && SignalMode > 0) {
               lda_48[li_4] = lda_36[li_4];
               if (WarningMode > 0 && li_4 == gi_200 - 1) PlaySound("alert.wav");
            } else lda_48[li_4] = EMPTY_VALUE;
            lda_52[li_4] = EMPTY_VALUE;
            lda_44[li_4] = EMPTY_VALUE;
         }
      }
      if (TimeFrame == Period()) {
         g_ibuf_148[gi_200 - li_4 - 1] = lda_52[li_4];
         g_ibuf_152[gi_200 - li_4 - 1] = lda_56[li_4];
         if (SignalMode > 0) {
            g_ibuf_156[gi_200 - li_4 - 1] = lda_44[li_4];
            g_ibuf_160[gi_200 - li_4 - 1] = lda_48[li_4];
         }
         if (BarsMode > 0) {
            if (lda_60[li_4] < 0.0) {
               if (LoBandRisk > 0.0) ld_88 = lda_40[li_4];
               else ld_88 = (lda_36[li_4] + lda_40[li_4]) / 2.0;
               if (Close[gi_200 - li_4 - 1] < ld_88) {
                  g_ibuf_164[gi_200 - li_4 - 1] = Low[gi_200 - li_4 - 1];
                  g_ibuf_168[gi_200 - li_4 - 1] = High[gi_200 - li_4 - 1];
               } else {
                  g_ibuf_164[gi_200 - li_4 - 1] = EMPTY_VALUE;
                  g_ibuf_168[gi_200 - li_4 - 1] = EMPTY_VALUE;
               }
            }
            if (lda_60[li_4] > 0.0) {
               if (UpBandRisk > 0.0) ld_96 = lda_36[li_4];
               else ld_96 = (lda_36[li_4] + lda_40[li_4]) / 2.0;
               if (Close[gi_200 - li_4 - 1] > ld_96) {
                  g_ibuf_164[gi_200 - li_4 - 1] = High[gi_200 - li_4 - 1];
                  g_ibuf_168[gi_200 - li_4 - 1] = Low[gi_200 - li_4 - 1];
               } else {
                  g_ibuf_164[gi_200 - li_4 - 1] = EMPTY_VALUE;
                  g_ibuf_168[gi_200 - li_4 - 1] = EMPTY_VALUE;
               }
            }
         }
         g_ibuf_172[gi_200 - li_4 - 1] = lda_60[li_4];
      }
   }
   gi_208 = gi_200 - 1;
   if (TimeFrame > Period()) {
      if (li_16 > 0) li_16--;
      li_0 = Bars - li_16 + TimeFrame / Period() - 1;
      l_index_12 = 0;
      for (li_4 = 0; l_index_12 < li_0; l_index_12++) {
         if (Time[l_index_12] < iTime(NULL, TimeFrame, li_4)) li_4++;
         g_ibuf_148[l_index_12] = lda_52[gi_200 - li_4 - 1];
         g_ibuf_152[l_index_12] = lda_56[gi_200 - li_4 - 1];
         if (SignalMode > 0) {
            g_ibuf_156[l_index_12] = lda_44[gi_200 - li_4 - 1];
            g_ibuf_160[l_index_12] = lda_48[gi_200 - li_4 - 1];
         }
         if (BarsMode > 0) {
            if (lda_60[gi_200 - li_4 - 1] > 0.0) {
               if (UpBandRisk > 0.0) ld_96 = lda_36[gi_200 - li_4 - 1];
               else ld_96 = (lda_36[gi_200 - li_4 - 1] + (lda_40[gi_200 - li_4 - 1])) / 2.0;
               if (Close[l_index_12] > ld_96) {
                  g_ibuf_164[l_index_12] = High[l_index_12];
                  g_ibuf_168[l_index_12] = Low[l_index_12];
               } else {
                  g_ibuf_164[l_index_12] = EMPTY_VALUE;
                  g_ibuf_168[l_index_12] = EMPTY_VALUE;
               }
            }
            if (lda_60[gi_200 - li_4 - 1] < 0.0) {
               if (LoBandRisk > 0.0) ld_88 = lda_40[gi_200 - li_4 - 1];
               else ld_88 = (lda_36[gi_200 - li_4 - 1] + (lda_40[gi_200 - li_4 - 1])) / 2.0;
               if (Close[l_index_12] < ld_88) {
                  g_ibuf_164[l_index_12] = Low[l_index_12];
                  g_ibuf_168[l_index_12] = High[l_index_12];
               } else {
                  g_ibuf_164[l_index_12] = EMPTY_VALUE;
                  g_ibuf_168[l_index_12] = EMPTY_VALUE;
               }
            }
         }
         g_ibuf_172[l_index_12] = lda_60[gi_200 - li_4 - 1];
      }
   }
   if (lda_60[gi_200 - 3] < 0.0 && lda_60[gi_200 - 2] > 0.0 && (!gi_232) && AlertMode == 1) {
      ls_104 = " " + Symbol() + " " + gs_240 + ": BEWARE!!! PRICE CHANNEL THREE is Now UP!!!";
      if (isNewBar()) Alert(ls_104);
      gi_232 = TRUE;
      gi_236 = FALSE;
   } else {
      if (lda_60[gi_200 - 3] > 0.0 && lda_60[gi_200 - 2] < 0.0 && (!gi_236) && AlertMode == 1) {
         ls_104 = " " + Symbol() + " " + gs_240 + ": BEWARE!!! PRICE CHANNEL THREE is Now DOWN!!!";
         if (isNewBar()) Alert(ls_104);
         gi_236 = TRUE;
         gi_232 = FALSE;
      }
   }
   return (0);
}

double SMA(double ada_0[], int ai_4, int ai_8) {
   double ld_12 = 0;
   for (int l_count_20 = 0; l_count_20 < ai_4; l_count_20++) ld_12 += ada_0[ai_8 - l_count_20];
   return (ld_12 / ai_4);
}

double EMA(double ad_0, double ada_8[], int ai_12, int ai_16) {
   double ld_ret_20;
   if (ai_16 == 2) ld_ret_20 = ad_0;
   else
      if (ai_16 > 2) ld_ret_20 = ada_8[ai_16 - 1] + 2.0 / (ai_12 + 1) * (ad_0 - (ada_8[ai_16 - 1]));
   return (ld_ret_20);
}

double Wilder(double ada_0[], double ada_4[], int ai_8, int ai_12) {
   double ld_ret_16;
   if (ai_12 == ai_8) ld_ret_16 = SMA(ada_0, ai_8, ai_12);
   else
      if (ai_12 > ai_8) ld_ret_16 = ada_4[ai_12 - 1] + (ada_0[ai_12] - (ada_4[ai_12 - 1])) / ai_8;
   return (ld_ret_16);
}

double LWMA(double ada_0[], int ai_4, int ai_8) {
   double ld_ret_32;
   double ld_12 = 0;
   double ld_20 = 0;
   for (int l_count_28 = 0; l_count_28 < ai_4; l_count_28++) {
      ld_20 += ai_4 - l_count_28;
      ld_12 += (ada_0[ai_8 - l_count_28]) * (ai_4 - l_count_28);
   }
   if (ld_20 > 0.0) ld_ret_32 = ld_12 / ld_20;
   else ld_ret_32 = 0;
   return (ld_ret_32);
}

double SineWMA(double ada_0[], int ai_4, int ai_8) {
   double ld_ret_40;
   double ld_12 = 3.1415926535;
   double ld_20 = 0;
   double ld_28 = 0;
   for (int l_count_36 = 0; l_count_36 < ai_4; l_count_36++) {
      ld_28 += MathSin(ld_12 * (l_count_36 + 1) / (ai_4 + 1));
      ld_20 += (ada_0[ai_8 - l_count_36]) * MathSin(ld_12 * (l_count_36 + 1) / (ai_4 + 1));
   }
   if (ld_28 > 0.0) ld_ret_40 = ld_20 / ld_28;
   else ld_ret_40 = 0;
   return (ld_ret_40);
}

double TriMA(double ada_0[], int ai_4, int ai_8) {
   double ld_12;
   int li_20 = MathCeil((ai_4 + 1) / 2.0);
   double ld_24 = 0;
   for (int l_count_32 = 0; l_count_32 < li_20; l_count_32++) {
      ld_12 = SMA(ada_0, li_20, ai_8 - l_count_32);
      ld_24 += ld_12;
   }
   double ld_ret_36 = ld_24 / li_20;
   return (ld_ret_36);
}

double LSMA(double ada_0[], int ai_4, int ai_8) {
   double ld_12 = 0;
   for (int li_20 = ai_4; li_20 >= 1; li_20--) ld_12 += (li_20 - (ai_4 + 1) / 3.0) * (ada_0[ai_8 - ai_4 + li_20]);
   double ld_ret_24 = 6.0 * ld_12 / (ai_4 * (ai_4 + 1));
   return (ld_ret_24);
}

double SMMA(double ada_0[], double ada_4[], int ai_8, int ai_12) {
   double ld_ret_16;
   double ld_24;
   if (ai_12 == ai_8) ld_ret_16 = SMA(ada_0, ai_8, ai_12);
   else {
      if (ai_12 > ai_8) {
         ld_24 = 0;
         for (int l_count_32 = 0; l_count_32 < ai_8; l_count_32++) ld_24 += ada_0[ai_12 - l_count_32 - 1];
         ld_ret_16 = (ld_24 - (ada_4[ai_12 - 1]) + ada_0[ai_12]) / ai_8;
      }
   }
   return (ld_ret_16);
}

double HMA(double ada_0[], int ai_4, int ai_8) {
   double lda_12[];
   double ld_ret_20;
   int li_16 = MathSqrt(ai_4);
   ArrayResize(lda_12, li_16);
   if (ai_8 == ai_4) ld_ret_20 = ada_0[ai_8];
   else {
      if (ai_8 > ai_4) {
         for (int l_count_28 = 0; l_count_28 < li_16; l_count_28++) lda_12[li_16 - l_count_28 - 1] = 2.0 * LWMA(ada_0, ai_4 / 2, ai_8 - l_count_28) - LWMA(ada_0, ai_4, ai_8 - l_count_28);
         ld_ret_20 = LWMA(lda_12, li_16, li_16 - 1);
      }
   }
   return (ld_ret_20);
}

double ZeroLagEMA(double ada_0[], double ada_4[], int ai_8, int ai_12) {
   double ld_ret_28;
   double ld_16 = 2.0 / (ai_8 + 1);
   int li_24 = (ai_8 - 1) / 2.0;
   if (ai_12 == li_24) ld_ret_28 = ada_0[ai_12];
   else
      if (ai_12 > li_24) ld_ret_28 = ld_16 * (2.0 * ada_0[ai_12] - (ada_0[ai_12 - li_24])) + (1 - ld_16) * (ada_4[ai_12 - 1]);
   return (ld_ret_28);
}

double DEMA(int ai_0, double ad_4, int ai_12, double ad_16, int ai_24) {
   double ld_ret_28;
   if (ai_24 == 2) {
      ld_ret_28 = ad_4;
      gda_176[ai_24][ai_0] = ld_ret_28;
      gda_176[ai_24][ai_0 + 1] = ld_ret_28;
   } else {
      if (ai_24 > 2) {
         gda_176[ai_24][ai_0] = gda_176[ai_24 - 1][ai_0] + 2.0 / (ai_12 + 1) * (ad_4 - (gda_176[ai_24 - 1][ai_0]));
         gda_176[ai_24][ai_0 + 1] = gda_176[ai_24 - 1][ai_0 + 1] + 2.0 / (ai_12 + 1) * (gda_176[ai_24][ai_0] - (gda_176[ai_24 - 1][ai_0 + 1]));
         ld_ret_28 = (ad_16 + 1.0) * gda_176[ai_24][ai_0] - ad_16 * (gda_176[ai_24][ai_0 + 1]);
      }
   }
   return (ld_ret_28);
}

double T3(int ai_0, double ad_4, int ai_12, double ad_16, int ai_24) {
   double ld_ret_28;
   double ld_40;
   double ld_48;
   if (ai_24 == 2) {
      ld_ret_28 = ad_4;
      for (int l_count_36 = 0; l_count_36 <= 5; l_count_36++) gda_176[ai_24][l_count_36] = ld_ret_28;
   } else {
      if (ai_24 > 2) {
         ld_40 = DEMA(ai_0, ad_4, ai_12, ad_16, ai_24);
         ld_48 = DEMA(ai_0 + 2, ld_40, ai_12, ad_16, ai_24);
         ld_ret_28 = DEMA(ai_0 + 4, ld_48, ai_12, ad_16, ai_24);
      }
   }
   return (ld_ret_28);
}

double ITrend(double ada_0[], double ada_4[], int ai_8, int ai_12) {
   double ld_ret_24;
   double ld_16 = 2.0 / (ai_8 + 1);
   if (ai_12 > 7) ld_ret_24 = (ld_16 - ld_16 / 4.0 * ld_16) * ada_0[ai_12] + ld_16 / 2.0 * ld_16 * (ada_0[ai_12 - 1]) - (ld_16 - 0.75 * ld_16 * ld_16) * (ada_0[ai_12 - 2]) + 2.0 * (1 - ld_16) * (ada_4[ai_12 - 1]) - (1 - ld_16) * (1 - ld_16) * (ada_4[ai_12 - 2]);
   else ld_ret_24 = (ada_0[ai_12] + 2.0 * (ada_0[ai_12 - 1]) + (ada_0[ai_12 - 2])) / 4.0;
   return (ld_ret_24);
}

double Median(double ada_0[], int ai_4, int ai_8) {
   double lda_12[];
   double ld_ret_24;
   ArrayResize(lda_12, ai_4);
   for (int l_index_16 = 0; l_index_16 < ai_4; l_index_16++) lda_12[l_index_16] = ada_0[ai_8 - l_index_16];
   ArraySort(lda_12);
   int li_20 = MathRound((ai_4 - 1) / 2);
   if (MathMod(ai_4, 2) > 0.0) ld_ret_24 = lda_12[li_20];
   else ld_ret_24 = (lda_12[li_20] + (lda_12[li_20 + 1])) / 2.0;
   return (ld_ret_24);
}

double GeoMean(double ada_0[], int ai_4, int ai_8) {
   double ld_ret_12 = MathPow(ada_0[ai_8], 1.0 / ai_4);
   for (int li_20 = 1; li_20 < ai_4; li_20++) ld_ret_12 *= MathPow(ada_0[ai_8 - li_20], 1.0 / ai_4);
   return (ld_ret_12);
}

double REMA(double ad_0, double ada_8[], int ai_12, double ad_16, int ai_24) {
   double ld_ret_36;
   double ld_28 = 2.0 / (ai_12 + 1);
   if (ai_24 <= 3) ld_ret_36 = ad_0;
   else
      if (ai_24 > 3) ld_ret_36 = ((ada_8[ai_24 - 1]) * (2.0 * ad_16 + 1.0) + ld_28 * (ad_0 - (ada_8[ai_24 - 1])) - ad_16 * (ada_8[ai_24 - 2])) / (ad_16 + 1.0);
   return (ld_ret_36);
}

double ILRS(double ada_0[], int ai_4, int ai_8) {
   double ld_64;
   double ld_12 = ai_4 * (ai_4 - 1) / 2.0;
   double ld_20 = (ai_4 - 1) * ai_4 * (ai_4 * 2 - 1) / 6.0;
   double ld_28 = 0;
   double ld_36 = 0;
   for (int l_count_44 = 0; l_count_44 < ai_4; l_count_44++) {
      ld_28 += l_count_44 * (ada_0[ai_8 - l_count_44]);
      ld_36 += ada_0[ai_8 - l_count_44];
   }
   double ld_48 = ai_4 * ld_28 - ld_12 * ld_36;
   double ld_56 = ld_12 * ld_12 - ai_4 * ld_20;
   if (ld_56 != 0.0) ld_64 = ld_48 / ld_56;
   else ld_64 = 0;
   double ld_ret_72 = ld_64 + SMA(ada_0, ai_4, ai_8);
   return (ld_ret_72);
}

double IE2(double ada_0[], int ai_4, int ai_8) {
   double ld_ret_12 = (ILRS(ada_0, ai_4, ai_8) + LSMA(ada_0, ai_4, ai_8)) / 2.0;
   return (ld_ret_12);
}

double TriMA_gen(double ada_0[], int ai_4, int ai_8) {
   int li_12 = MathFloor((ai_4 + 1) / 2.0);
   int li_16 = MathCeil((ai_4 + 1) / 2.0);
   double ld_20 = 0;
   for (int l_count_28 = 0; l_count_28 < li_16; l_count_28++) ld_20 += SMA(ada_0, li_12, ai_8 - l_count_28);
   double ld_ret_32 = ld_20 / li_16;
   return (ld_ret_32);
}

double VWMA(double ada_0[], int ai_4, int ai_8) {
   double ld_ret_32;
   double ld_12 = 0;
   double ld_20 = 0;
   for (int l_count_28 = 0; l_count_28 < ai_4; l_count_28++) {
      ld_20 += Volume[gi_200 - ai_8 - 1 + l_count_28];
      ld_12 += (ada_0[ai_8 - l_count_28]) * (Volume[gi_200 - ai_8 - 1 + l_count_28]);
   }
   if (ld_20 > 0.0) ld_ret_32 = ld_12 / ld_20;
   else ld_ret_32 = 0;
   return (ld_ret_32);
}

double JSmooth(int ai_0, double ad_4, int ai_12, double ad_16, int ai_24) {
   double ld_28 = (ai_12 - 1) / 2.0 / ((ai_12 - 1) / 2.0 + 2.0);
   double ld_36 = MathPow(ld_28, ad_16);
   if (ai_24 == 2) {
      gda_176[ai_24][ai_0 + 4] = ad_4;
      gda_176[ai_24][ai_0 + 0] = ad_4;
      gda_176[ai_24][ai_0 + 2] = ad_4;
   } else {
      if (ai_24 > 2) {
         gda_176[ai_24][ai_0 + 0] = (1 - ld_36) * ad_4 + ld_36 * (gda_176[ai_24 - 1][ai_0 + 0]);
         gda_176[ai_24][ai_0 + 1] = (ad_4 - (gda_176[ai_24][ai_0 + 0])) * (1 - ld_28) + ld_28 * (gda_176[ai_24 - 1][ai_0 + 1]);
         gda_176[ai_24][ai_0 + 2] = gda_176[ai_24][ai_0 + 0] + (gda_176[ai_24][ai_0 + 1]);
         gda_176[ai_24][ai_0 + 3] = (gda_176[ai_24][ai_0 + 2] - (gda_176[ai_24 - 1][ai_0 + 4])) * MathPow(1 - ld_36, 2) + MathPow(ld_36, 2) * (gda_176[ai_24 - 1][ai_0 + 3]);
         gda_176[ai_24][ai_0 + 4] = gda_176[ai_24 - 1][ai_0 + 4] + (gda_176[ai_24][ai_0 + 3]);
      }
   }
   return (gda_176[ai_24][ai_0 + 4]);
}

double HeikenAshi(int ai_0, int a_timeframe_4, int ai_8, int ai_12) {
   if (ai_12 == iBars(NULL, TimeFrame) - 1) {
      gda_180[ai_12][ai_0] = iClose(NULL, a_timeframe_4, ai_12);
      gda_184[ai_12][ai_0] = iOpen(NULL, a_timeframe_4, ai_12);
      gda_188[ai_12][ai_0] = iHigh(NULL, a_timeframe_4, ai_12);
      gda_192[ai_12][ai_0] = iLow(NULL, a_timeframe_4, ai_12);
   } else {
      gda_180[ai_12][ai_0] = (iOpen(NULL, a_timeframe_4, ai_12) + iHigh(NULL, a_timeframe_4, ai_12) + iLow(NULL, a_timeframe_4, ai_12) + iClose(NULL, a_timeframe_4, ai_12)) / 4.0;
      gda_184[ai_12][ai_0] = (gda_184[ai_12 + 1][ai_0] + (gda_180[ai_12 + 1][ai_0])) / 2.0;
      gda_188[ai_12][ai_0] = MathMax(iHigh(NULL, a_timeframe_4, ai_12), MathMax(gda_184[ai_12][ai_0], gda_180[ai_12][ai_0]));
      gda_192[ai_12][ai_0] = MathMin(iLow(NULL, a_timeframe_4, ai_12), MathMin(gda_184[ai_12][ai_0], gda_180[ai_12][ai_0]));
   }
   switch (ai_8) {
   case 0:
      return (gda_180[ai_12][ai_0]);
   case 1:
      return (gda_184[ai_12][ai_0]);
   case 2:
      return (gda_188[ai_12][ai_0]);
   case 3:
      return (gda_192[ai_12][ai_0]);
   }
   return (0.0);
}

bool isNewBar() {
   bool li_ret_0 = FALSE;
   if (iTime(NULL, TimeFrame, 0) != g_datetime_228) {
      li_ret_0 = TRUE;
      g_datetime_228 = iTime(NULL, TimeFrame, 0);
   }
   return (li_ret_0);
}
// ------------------------------------------------------------------------------------------ //
//                                     E N D   P R O G R A M                                  //
// ------------------------------------------------------------------------------------------ //
/*                                                         
                                        ud$$$**BILLION$bc.                          
                                    u@**"        PROJECT$$Nu                       
                                  J                ""#$$$$$$r                     
                                 @                       $$$$b                    
                               .F                        ^*3$$$                   
                              :% 4                         J$$$N                  
                              $  :F                       :$$$$$                  
                             4F  9                       J$$$$$$$                 
                             4$   k             4$$$$bed$$$$$$$$$                 
                             $$r  'F            $$$$$$$$$$$$$$$$$r                
                             $$$   b.           $$$$$$$$$$$$$$$$$N                
                             $$$$$k 3eeed$$b    XARD777."$$$$$$$$$                
              .@$**N.        $$$$$" $$$$$$F'L $$$$$$$$$$$  $$$$$$$                
              :$$L  'L       $$$$$ 4$$$$$$  * $$$$$$$$$$F  $$$$$$F         edNc   
             @$$$$N  ^k      $$$$$  3$$$$*%   $F4$$$$$$$   $$$$$"        d"  z$N  
             $$$$$$   ^k     '$$$"   #$$$F   .$  $$$$$c.u@$$$          J"  @$$$$r 
             $$$$$$$b   *u    ^$L            $$  $$$$$$$$$$$$u@       $$  d$$$$$$ 
              ^$$$$$$.    "NL   "N. z@*     $$$  $$$$$$$$$$$$$P      $P  d$$$$$$$ 
                 ^"*$$$$b   '*L   9$E      4$$$  d$$$$$$$$$$$"     d*   J$$$$$r   
                      ^$$$$u  '$.  $$$L     "#" d$$$$$$".@$$    .@$"  z$$$$*"     
                        ^$$$$. ^$N.3$$$       4u$$$$$$$ 4$$$  u$*" z$$$"          
                          '*$$$$$$$$ *$b      J$$$$$$$b u$$P $"  d$$P             
                             #$$$$$$ 4$ 3*$"$*$ $"$'c@@$$$$ .u@$$$P               
                               "$$$$  ""F~$ $uNr$$$^&J$$$$F $$$$#                 
                                 "$$    "$$$bd$.$W$$$$$$$$F $$"                   
                                   ?k         ?$$$$$$$$$$$F'*                     
                                    9$$bL     z$$$$$$$$$$$F                       
                                     $$$$    $$$$$$$$$$$$$                        
                                      '#$$c  '$$$$$$$$$"                          
                                       .@"#$$$$$$$$$$$$b                          
                                     z*      $$$$$$$$$$$$N.                       
                                   e"      z$$"  #$$$k  '*$$.                     
                                .u*      u@$P"      '#$$c   "$$c                   
                        u@$*"""       d$$"            "$$$u  ^*$$b.               
                      :$F           J$P"                ^$$$c   '"$$$$$$bL        
                     d$$  ..      @$#                      #$$b         '#$       
                     9$$$$$$b   4$$                          ^$$k         '$      
                      "$$6""$b u$$                             '$    d$$$$$P      
                        '$F $$$$$"                              ^b  ^$$$$b$       
                         '$W$$$$"                                'b@$$$$"         
                                                                  ^$$$*/

Комментарии к исходному коду форекс индикатора !XPS v7 PRICE CHANNEL THREE.mq4
В целях безопасности и борьбы со спамом в тексте комментариев запрещено размещать html-теги и ссылки. Благодарим за понимание.

  • X
  • 0% загружено
« индикатор !XPS v7 PANEL.mq4
индикатор !XPS v7 PRICE CHANNEL TWO.mq4 »