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

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 PaleGreen

int g_period_76 = 50;
int g_period_80 = 144;
int g_period_84 = 233;
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double gd_100;
double gd_108;
double g_icci_116;

int init() {
   IndicatorBuffers(3);
   SetIndexBuffer(0, g_ibuf_88);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(1, g_ibuf_92);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(2, g_ibuf_96);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   IndicatorShortName("MARKET SENTIMENT");
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   int l_ind_counted_0 = IndicatorCounted();
   if (l_ind_counted_0 < 0) return (-1);
   int li_4 = Bars - l_ind_counted_0;
   if (li_4 > Bars) li_4 = Bars;
   for (int li_8 = li_4; li_8 >= 0; li_8--) {
      g_icci_116 = iCCI(NULL, 0, g_period_76, PRICE_TYPICAL, li_8);
      gd_100 = iMA(NULL, 0, g_period_80, 0, MODE_EMA, PRICE_CLOSE, li_8) - iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_8);
      gd_108 = iMA(NULL, 0, g_period_80, 0, MODE_EMA, PRICE_CLOSE, li_8 + 1) - iMA(NULL, 0, g_period_84, 0, MODE_EMA, PRICE_CLOSE, li_8 + 1);
      g_ibuf_88[li_8] = 0.0;
      g_ibuf_92[li_8] = 0.0;
      g_ibuf_96[li_8] = 0.0;
      if (g_icci_116 > 0.0 && gd_100 > gd_108) g_ibuf_88[li_8] = 1.0;
      else {
         if (g_icci_116 < 0.0 && gd_100 < gd_108) g_ibuf_92[li_8] = 1.0;
         else g_ibuf_96[li_8] = 1.0;
      }
   }
   return (0);
}