Navigation:Home > Content >

VQzz2~_(e).mq4

Time: 2012-11-07 | Download file:VQzz2~_(e).mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : [email protected]
*/
#property copyright "Copyright © 2011 zznbrm"
#property link      ""

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 1.0
#property indicator_buffers 5
#property indicator_color1 FireBrick
#property indicator_color2 Green
#property indicator_color3 Black
#property indicator_color4 Black
#property indicator_color5 Black


extern string pus1 = "";
extern string slug = "Дополнительные настройки";
extern bool use_alert = false;
extern string down_alert = "way down";
extern string up_alert = "way up";

extern int eintTF = 0;
extern int eintPeriod = 7;
extern int eintMethod = 3;
extern int eintSmoothing = 1;
extern int eintFilter = 5;
extern bool eblnTrueMode = FALSE;

double g_ibuf_100[];
double g_ibuf_104[];
double g_ibuf_108[];
double g_ibuf_112[];
double g_ibuf_116[];

static int prevtime = 0;



int init() {
prevtime = iTime(Symbol(),0,0);

   IndicatorBuffers(5);
   IndicatorDigits(Digits);
   string ls_0 = "VQzz2-";
   if (eintTF == 0) ls_0 = ls_0 + Period();
   else ls_0 = ls_0 + eintTF;
   IndicatorShortName(ls_0);
   SetIndexBuffer(0, g_ibuf_100);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexLabel(0, NULL);
   SetIndexBuffer(1, g_ibuf_104);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexLabel(1, NULL);
   SetIndexBuffer(2, g_ibuf_108);
   SetIndexStyle(2, DRAW_NONE);
   SetIndexLabel(2, ls_0);
   SetIndexBuffer(3, g_ibuf_112);
   SetIndexStyle(3, DRAW_NONE);
   SetIndexLabel(3, NULL);
   SetIndexBuffer(4, g_ibuf_116);
   SetIndexStyle(4, DRAW_NONE);
   SetIndexLabel(4, "VQ Real");
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int li_ret_0;
   if (eintTF == 0 || eintTF == Period()) li_ret_0 = processCurr();
   else {
      if (eblnTrueMode) li_ret_0 = processTrue();
      else li_ret_0 = processOther();
   }
   return (li_ret_0);
}

int processCurr() {
   double ld_8;
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   if (li_0 == 0) li_0 = eintPeriod + 2 + eintSmoothing;
   int li_4 = Bars - li_0;
   for (int li_16 = li_4; li_16 >= 0; li_16--) {
      ld_8 = calcUtfVQ(li_16);
      g_ibuf_116[li_16] = ld_8;
      if (ld_8 == 0.0) {
         if (g_ibuf_108[li_16 + 1] < 0.0) ld_8 = -1.0 * Point;
         else ld_8 = Point;
      }
      if (MathAbs(ld_8) < eintFilter * Point) g_ibuf_108[li_16] = g_ibuf_108[li_16 + 1];
      else g_ibuf_108[li_16] = ld_8;
      g_ibuf_100[li_16] = 0.0;
      g_ibuf_104[li_16] = 0.0;
      if (g_ibuf_108[li_16] > 0.0) g_ibuf_104[li_16] = 1.0;
      else
         if (g_ibuf_108[li_16] < 0.0) g_ibuf_100[li_16] = 1.0;
   }
   
   
   
   if (iTime(Symbol(), 0, 0) == prevtime) {Sleep(50);return(0);}
   prevtime = iTime(Symbol(),0,0);
   
   if(use_alert)
   {
   if(g_ibuf_100[1]==1) Alert(Symbol()," ",down_alert); //down
   if(g_ibuf_104[1]==1) Alert(Symbol()," ",up_alert);   //up
   }
   
   
   
   return (0);
}

/////////////////////////////////////////////////////////
int processOther() {
   double ld_4;
   int l_datetime_12;
   int l_shift_16;
   int li_20;
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   if (li_0 == 0) li_0 = eintPeriod + 2 + eintSmoothing;
   int li_24 = MathMax(Bars - li_0, eintTF / Period());
   for (int li_28 = li_24; li_28 >= 0; li_28--) {
      l_shift_16 = iBarShift(Symbol(), eintTF, Time[li_28]);
      l_datetime_12 = iTime(Symbol(), eintTF, l_shift_16);
      li_20 = calcUtfStart(l_datetime_12);
      g_ibuf_112[li_28] = g_ibuf_108[li_20 + 1];
      ld_4 = calcUtfVQ(l_shift_16);
      g_ibuf_116[li_28] = ld_4;
      if (ld_4 == 0.0) {
         if (g_ibuf_112[li_28] < 0.0) ld_4 = -1.0 * Point;
         else ld_4 = Point;
      }
      if (MathAbs(ld_4) < eintFilter * Point) g_ibuf_108[li_28] = g_ibuf_112[li_28];
      else g_ibuf_108[li_28] = ld_4;
      g_ibuf_100[li_28] = 0.0;
      g_ibuf_104[li_28] = 0.0;
      if (g_ibuf_108[li_28] > 0.0) g_ibuf_104[li_28] = 1.0;
      else
         if (g_ibuf_108[li_28] < 0.0) g_ibuf_100[li_28] = 1.0;
   }
   return (0);
}

int processTrue() {
   double ld_4;
   int l_datetime_12;
   int l_shift_16;
   int li_20;
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   int li_24 = Bars - li_0;
   if (li_24 > 1000) li_24 = 1000;
   for (int li_28 = li_24; li_28 >= 0; li_28--) {
      l_shift_16 = iBarShift(Symbol(), eintTF, Time[li_28]);
      l_datetime_12 = iTime(Symbol(), eintTF, l_shift_16);
      li_20 = calcUtfStart(l_datetime_12);
      g_ibuf_112[li_28] = g_ibuf_108[li_20 + 1];
      ld_4 = calcTrue(l_shift_16, li_28, li_20);
      g_ibuf_116[li_28] = ld_4;
      if (ld_4 == 0.0) {
         if (g_ibuf_112[li_28] < 0.0) ld_4 = -1.0 * Point;
         else ld_4 = Point;
      }
      if (MathAbs(ld_4) < eintFilter * Point) g_ibuf_108[li_28] = g_ibuf_112[li_28];
      else g_ibuf_108[li_28] = ld_4;
      g_ibuf_100[li_28] = 0.0;
      g_ibuf_104[li_28] = 0.0;
      if (g_ibuf_108[li_28] > 0.0) g_ibuf_104[li_28] = 1.0;
      else
         if (g_ibuf_108[li_28] < 0.0) g_ibuf_100[li_28] = 1.0;
   }
   return (0);
}

double calcUtfVQ(int ai_0) {
   double l_ima_4 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_HIGH, ai_0);
   double l_ima_12 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_LOW, ai_0);
   double l_ima_20 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_OPEN, ai_0);
   double l_ima_28 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_CLOSE, ai_0);
   double l_ima_36 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_CLOSE, ai_0 + eintSmoothing);
   if (l_ima_4 == 0.0 || l_ima_12 == 0.0 || l_ima_20 == 0.0 || l_ima_28 == 0.0 || l_ima_36 == 0.0) return (0.0);
   return (calcVQ(l_ima_4, l_ima_12, l_ima_20, l_ima_28, l_ima_36));
}

double calcTrue(int ai_0, int ai_4, int ai_8) {
   double l_ima_44;
   double l_ima_12 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_OPEN, ai_0);
   double ld_20 = calcMaAltLow(ai_0, ai_4, ai_8);
   double ld_28 = calcMaAltHigh(ai_0, ai_4, ai_8);
   double ld_36 = calcMaAltClose(ai_0, ai_4);
   if (eintSmoothing > 0) l_ima_44 = iMA(Symbol(), eintTF, eintPeriod, 0, eintMethod, PRICE_CLOSE, ai_0 + eintSmoothing);
   else l_ima_44 = ld_36;
   if (ld_28 == 0.0 || ld_20 == 0.0 || l_ima_12 == 0.0 || ld_36 == 0.0 || l_ima_44 == 0.0) return (0.0);
   return (calcVQ(ld_28, ld_20, l_ima_12, ld_36, l_ima_44));
}

double calcVQ(double ad_0, double ad_8, double ad_16, double ad_24, double ad_32) {
   double ld_40 = MathMax(ad_0 - ad_8, MathMax(ad_0 - ad_32, ad_32 - ad_8));
   double ld_ret_48 = MathAbs(((ad_24 - ad_32) / ld_40 + (ad_24 - ad_16) / (ad_0 - ad_8)) / 2.0) * ((ad_24 - ad_32 + (ad_24 - ad_16)) / 2.0);
   return (ld_ret_48);
}

double calcMaAltClose(int ai_0, int ai_4) {
   double lda_8[];
   double lda_12[];
   ArraySetAsSeries(lda_12, TRUE);
   ArrayCopySeries(lda_8, 3, Symbol(), eintTF);
   ArrayCopy(lda_12, lda_8);
   lda_12[ai_0] = Close[ai_4];
   return (iMAOnArray(lda_12, 0, eintPeriod, 0, eintMethod, ai_0));
}

double calcMaAltHigh(int ai_0, int ai_4, int ai_8) {
   double lda_12[];
   double lda_16[];
   int li_24;
   ArraySetAsSeries(lda_16, TRUE);
   ArrayCopySeries(lda_12, 2, Symbol(), eintTF);
   ArrayCopy(lda_16, lda_12);
   int li_20 = ai_8 - ai_4 + 1;
   if (li_20 <= 1) lda_16[ai_0] = High[ai_4];
   else {
      li_24 = ArrayMaximum(High, li_20, ai_4);
      lda_16[ai_0] = High[li_24];
   }
   return (iMAOnArray(lda_16, 0, eintPeriod, 0, eintMethod, ai_0));
}

double calcMaAltLow(int ai_0, int ai_4, int ai_8) {
   double lda_12[];
   double lda_16[];
   int li_24;
   ArraySetAsSeries(lda_16, TRUE);
   ArrayCopySeries(lda_12, 1, Symbol(), eintTF);
   ArrayCopy(lda_16, lda_12);
   int li_20 = ai_8 - ai_4 + 1;
   if (li_20 <= 1) lda_16[ai_0] = Low[ai_4];
   else {
      li_24 = ArrayMinimum(Low, li_20, ai_4);
      lda_16[ai_0] = Low[li_24];
   }
   return (iMAOnArray(lda_16, 0, eintPeriod, 0, eintMethod, ai_0));
}

int calcUtfStart(int ai_0) {
   int li_ret_4 = iBarShift(Symbol(), Period(), ai_0, TRUE);
   if (li_ret_4 < 0) li_ret_4 = iBarShift(Symbol(), Period(), ai_0, FALSE) - 1;
   return (li_ret_4);
}

Recommend