#property link "https://www.forexfactory.com/lghr"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 clrLime
#property indicator_color2 clrMagenta
#property indicator_level1 0

extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalEMA = 9;

double UP[];
double DN[];

int init() 
{
   IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1.0);
   
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(0, UP);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID);
   SetIndexBuffer(1, DN);
   IndicatorShortName("OsMA(" + FastEMA + "," + SlowEMA + "," + SignalEMA + ")");
   SetIndexLabel(0, "UP");
   SetIndexLabel(1, "DOWN");
   return (0);
}

int start() 
{
   int counted_bars = IndicatorCounted();
   if (counted_bars < 0) return (-1);
   if (counted_bars > 0) counted_bars--;   
   int limit = Bars - counted_bars;
   
   for(int i = 0; i < limit; i++) 
      {
       double
       M1 = iOsMA(Symbol(),0,FastEMA,SlowEMA,SignalEMA,0,i),
       M2 = iOsMA(Symbol(),0,FastEMA,SlowEMA,SignalEMA,0,i+1);       
       
       UP[i] = 0;
       DN[i] = 0;
       if (M1 > M2) UP[i] = M1;
       else DN[i] = M1;
      }
   return (0);
}
