Navigation:Home > Content >

RaitisHeikenAshi.mq4

Time: 2017-12-02 | Download file:RaitisHeikenAshi.mq4

//+------------------------------------------------------------------+
//|                                                                  |
//|                                             RaitisHeikenAshi.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+

#property copyright "Raitis"
#property link      "esterkin2313@inbox.lv"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 LimeGreen
#property indicator_color2 DarkOrange
#property indicator_color3 LimeGreen
#property indicator_color4 DarkOrange

extern int HmaPeriod = 30;
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
double g_ibuf_92[];
double gda_96[][8];
int g_period_100;
int gi_104;

int init() {
   SetIndexBuffer(0, g_ibuf_88);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(1, g_ibuf_92);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(2, g_ibuf_80);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(3, g_ibuf_84);
   SetIndexStyle(3, DRAW_HISTOGRAM);
   HmaPeriod = MathMax(2, HmaPeriod);
   g_period_100 = MathFloor(HmaPeriod / 2.0);
   gi_104 = MathFloor(MathSqrt(HmaPeriod));
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double ld_16;
   double ld_24;
   double ld_32;
   double ld_40;
   int li_0 = IndicatorCounted();
   if (li_0 < 0) return (-1);
   if (li_0 > 0) li_0--;
   int li_12 = Bars - li_0;
   if (ArrayRange(gda_96, 0) != Bars) ArrayResize(gda_96, Bars);
   int li_4 = li_12;
   for (int li_8 = Bars - li_4 - 1; li_4 >= 0; li_8++) {
      gda_96[li_8][0] = 2.0 * iMA(NULL, 0, g_period_100, 0, MODE_LWMA, PRICE_OPEN, li_4) - iMA(NULL, 0, HmaPeriod, 0, MODE_LWMA, PRICE_OPEN, li_4);
      gda_96[li_8][1] = iLwma(0, gi_104, li_8);
      gda_96[li_8][2] = 2.0 * iMA(NULL, 0, g_period_100, 0, MODE_LWMA, PRICE_CLOSE, li_4) - iMA(NULL, 0, HmaPeriod, 0, MODE_LWMA, PRICE_CLOSE, li_4);
      gda_96[li_8][3] = iLwma(2, gi_104, li_8);
      gda_96[li_8][4] = 2.0 * iMA(NULL, 0, g_period_100, 0, MODE_LWMA, PRICE_HIGH, li_4) - iMA(NULL, 0, HmaPeriod, 0, MODE_LWMA, PRICE_HIGH, li_4);
      gda_96[li_8][5] = iLwma(4, gi_104, li_8);
      gda_96[li_8][6] = 2.0 * iMA(NULL, 0, g_period_100, 0, MODE_LWMA, PRICE_LOW, li_4) - iMA(NULL, 0, HmaPeriod, 0, MODE_LWMA, PRICE_LOW, li_4);
      gda_96[li_8][7] = iLwma(6, gi_104, li_8);
      ld_16 = (g_ibuf_84[li_4 + 1] + (g_ibuf_80[li_4 + 1])) / 2.0;
      ld_24 = (gda_96[li_8][1] + gda_96[li_8][3] + gda_96[li_8][5] + gda_96[li_8][7]) / 4.0;
      ld_32 = MathMax(gda_96[li_8][5], MathMax(ld_16, ld_24));
      ld_40 = MathMin(gda_96[li_8][7], MathMin(ld_16, ld_24));
      if (ld_16 < ld_24) {
         g_ibuf_92[li_4] = ld_40;
         g_ibuf_88[li_4] = ld_32;
      } else {
         g_ibuf_88[li_4] = ld_40;
         g_ibuf_92[li_4] = ld_32;
      }
      g_ibuf_84[li_4] = ld_16;
      g_ibuf_80[li_4] = ld_24;
      li_4--;
   }
   return (0);
}

double iLwma(int ai_0, int ai_4, int ai_8) {
   int l_count_28;
   double ld_12 = 0;
   double ld_20 = 0;
   if (ai_8 >= ai_4) {
      l_count_28 = 0;
      for (int li_32 = ai_4; l_count_28 < ai_4; li_32--) {
         ld_12 += li_32;
         ld_20 += (gda_96[ai_8 - l_count_28][ai_0]) * li_32;
         l_count_28++;
      }
      if (ld_12 != 0.0) return (ld_20 / ld_12);
      return (0.0);
   }
   return (gda_96[ai_8][ai_0]);
}

Recommend