/*
   Generated by EX4-TO-MQ4 decompiler ONE FILE V4.0.218.3
   EX4 ID : 04E20A41724C2645BAEB3FDF008C44EC
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright © 2006, Winning-Solution.Net "
#property link      "http://www.winning-solution.net/"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_width1 3
#property indicator_color2 SpringGreen
#property indicator_width2 3
#property indicator_color3 DarkOrange
#property indicator_width3 3

int g_applied_price_76 = PRICE_CLOSE;
int gi_80 = 9;
int gi_84 = 0;
int gi_88 = 1;
int gi_92 = 1;
int gi_96 = 1;
double gd_100 = 0.0;
double gd_108 = 4.0;
double g_ibuf_116[];
double g_ibuf_120[];
double g_ibuf_124[];
double g_ibuf_128[];
double g_ibuf_132[];

int init() {
   int li_unused_0 = 0;
   IndicatorBuffers(5);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 3);
   SetIndexBuffer(0, g_ibuf_116);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 3);
   SetIndexBuffer(1, g_ibuf_120);
   SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 3);
   SetIndexBuffer(2, g_ibuf_124);
   SetIndexBuffer(3, g_ibuf_128);
   SetIndexBuffer(4, g_ibuf_132);
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS));
   string ls_4 = "NonLagMA(" + gi_80 + ")";
   IndicatorShortName(ls_4);
   SetIndexLabel(0, "NLMA");
   SetIndexLabel(1, "Up");
   SetIndexLabel(2, "Dn");
   SetIndexShift(0, gi_84);
   SetIndexShift(1, gi_84);
   SetIndexShift(2, gi_84);
   SetIndexDrawBegin(0, gi_80 * gd_108 + gi_80);
   SetIndexDrawBegin(1, gi_80 * gd_108 + gi_80);
   SetIndexDrawBegin(2, gi_80 * gd_108 + gi_80);
   return (0);
}

int start() {
   int li_12;
   double ld_16;
   double ld_24;
   double ld_32;
   double ld_40;
   double ld_48;
   double ld_64;
   int l_ind_counted_8 = IndicatorCounted();
   
   double ld_72 =   3.141592653589793238462643383279;
   //double ld_72 = 3.1415926535;
   double ld_80 = 3.0 * ld_72;
   int li_88 = gi_80 - 1;
   double ld_92 = gi_80 * gd_108 + li_88;
   if (l_ind_counted_8 > 0) li_12 = Bars - l_ind_counted_8;
   if (l_ind_counted_8 < 0) return (0);
   if (l_ind_counted_8 == 0) li_12 = Bars - ld_92 - 1.0;
   if (l_ind_counted_8 < 1) {
      for (int l_index_0 = 1; l_index_0 < gi_80 * gd_108 + gi_80; l_index_0++) {
         g_ibuf_116[Bars - l_index_0] = 0;
         g_ibuf_120[Bars - l_index_0] = 0;
         g_ibuf_124[Bars - l_index_0] = 0;
      }
   }
   for (int li_4 = li_12; li_4 >= 0; li_4--) {
      ld_48 = 0;
      ld_40 = 0;
      ld_32 = 0;
      for (l_index_0 = 0; l_index_0 <= ld_92 - 1.0; l_index_0++) {
         ld_64 = 1.0 / (ld_80 * ld_32 + 1.0);
         if (ld_32 <= 0.5) ld_64 = 1;
         ld_24 = MathCos(ld_72 * ld_32);
         ld_16 = ld_64 * ld_24;
         g_ibuf_128[l_index_0] = iMA(NULL, 0, 1, 0, MODE_SMA, g_applied_price_76, li_4 + l_index_0);
         ld_40 += ld_16 * g_ibuf_128[l_index_0];
         ld_48 += ld_16;
         if (ld_32 < 1.0) ld_32 += 1.0 / (li_88 - 1);
         else
            if (ld_32 < ld_92 - 1.0) ld_32 += (2.0 * gd_108 - 1.0) / (gd_108 * gi_80 - 1.0);
      }
      if (ld_48 > 0.0) g_ibuf_116[li_4] = (gd_100 / 100.0 + 1.0) * ld_40 / ld_48;
      if (gi_88 > 0)
         if (MathAbs(g_ibuf_116[li_4] - (g_ibuf_116[li_4 + 1])) < gi_88 * Point) g_ibuf_116[li_4] = g_ibuf_116[li_4 + 1];
      if (gi_92 > 0) {
         g_ibuf_132[li_4] = g_ibuf_132[li_4 + 1];
         if (g_ibuf_116[li_4] - (g_ibuf_116[li_4 + 1]) > gi_88 * Point) g_ibuf_132[li_4] = 1;
         if (g_ibuf_116[li_4 + 1] - g_ibuf_116[li_4] > gi_88 * Point) g_ibuf_132[li_4] = -1;
         if (g_ibuf_132[li_4] > 0.0) {
            g_ibuf_120[li_4] = g_ibuf_116[li_4];
            if (g_ibuf_132[li_4 + gi_96] < 0.0) g_ibuf_120[li_4 + gi_96] = g_ibuf_116[li_4 + gi_96];
            g_ibuf_124[li_4] = EMPTY_VALUE;
         }
         if (g_ibuf_132[li_4] < 0.0) {
            g_ibuf_124[li_4] = g_ibuf_116[li_4];
            if (g_ibuf_132[li_4 + gi_96] > 0.0) g_ibuf_124[li_4 + gi_96] = g_ibuf_116[li_4 + gi_96];
            g_ibuf_120[li_4] = EMPTY_VALUE;
         }
      }
   }
   if (g_ibuf_120[0] != EMPTY_VALUE && g_ibuf_120[1] == EMPTY_VALUE) Alert("[" + Symbol() + "] TREND MA AKAN NAIK... PERIODE = " + Period());
   else
      if (g_ibuf_124[0] != EMPTY_VALUE && g_ibuf_124[1] == EMPTY_VALUE) Alert("[" + Symbol() + "] TREND MA AKAN NAIK... PERIODE = " + Period());
   return (0);
}