/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "ForexScannerQuantumTrendElite"
#property link      "http://www.forexscanners.com"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Gray

string gs_unused_76 = "Last Modified: 2009.06.26 18:45";
int g_period_84 = 50;
double gd_unused_88 = 0.15;
int gi_96 = 2;
int gi_100 = 0;
int gi_104 = 15;
int gi_108 = 5000;
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
//int gi_124 = D'25.08.2039 13:00';
//string gs_128 = "Your trail/subscription period is over!";

int init() {
   IndicatorBuffers(3);
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2);
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 2.0);
   if (!SetIndexBuffer(0, g_ibuf_112) && !SetIndexBuffer(1, g_ibuf_116) && !SetIndexBuffer(2, g_ibuf_120)) Print("cannot set indicator buffers!");
   IndicatorShortName("ForexScannerQuantumTrendElite");
   return (0);
}

int start() {
/*
   if (TimeCurrent() >= gi_124) {
      Alert(gs_128);
      return (0);
   }
   */
   int li_4 = IndicatorCounted();
   if (li_4 > 0) li_4--;
   int li_0 = Bars - li_4;
   if (li_0 > gi_108) li_0 = gi_108;
   int li_8 = 0;
   double ld_12 = 0;
   for (int l_index_20 = 0; l_index_20 <= li_0; l_index_20++) {
      li_8 = GetSignal(l_index_20, ld_12);
      if (li_8 == 1) {
         g_ibuf_112[l_index_20] = ld_12;
         g_ibuf_116[l_index_20] = EMPTY_VALUE;
         g_ibuf_120[l_index_20] = EMPTY_VALUE;
      }
      if (li_8 == 2) {
         g_ibuf_112[l_index_20] = EMPTY_VALUE;
         g_ibuf_116[l_index_20] = ld_12;
         g_ibuf_120[l_index_20] = EMPTY_VALUE;
      }
      if (li_8 == 3) {
         g_ibuf_112[l_index_20] = EMPTY_VALUE;
         g_ibuf_116[l_index_20] = EMPTY_VALUE;
         g_ibuf_120[l_index_20] = ld_12;
      }
   }
   return (0);
}

int GetSignal(int ai_0, double &ad_4) {
   bool li_12 = TRUE;
   bool li_16 = TRUE;
   for (int li_20 = ai_0; li_20 <= gi_104 + ai_0; li_20++) {
      if (GetSMAAngle(li_20) >= 0.0) li_16 = FALSE;
      if (GetSMAAngle(li_20) <= 0.0) li_12 = FALSE;
   }
   ad_4 = GetSMAAngle(ai_0);
   if (li_12 == TRUE && li_16 == FALSE) return (1);
   if (li_12 == FALSE && li_16 == TRUE) return (2);
   return (3);
}

double GetSMAAngle(int ai_0) {
   if (gi_100 >= gi_96) {
      Print("Error: EndEMAShift >= StartEMAShift");
      gi_96 = 6;
      gi_100 = 0;
   }
   int li_28 = IndicatorCounted();
   if (li_28 < 0) return (-1);
   if (li_28 > 0) li_28--;
   int li_32 = Bars - li_28;
   double ld_unused_36 = 0.0349065556;
   double ld_44 = 10000.0;
   string ls_52 = StringSubstr(Symbol(), 3, 3);
   if (ls_52 == "JPY") ld_44 = 100.0;
   int li_60 = gi_96 - gi_100;
   ld_44 /= li_60;
   double l_ima_4 = iMA(NULL, 0, g_period_84, 0, MODE_SMA, PRICE_MEDIAN, ai_0 + gi_100);
   double l_ima_12 = iMA(NULL, 0, g_period_84, 0, MODE_SMA, PRICE_MEDIAN, ai_0 + gi_96);
   double ld_ret_20 = ld_44 * (l_ima_4 - l_ima_12) / 2.0;
   return (ld_ret_20);
}