//+------------------------------------------------------------------+
//|                                                       Sample.mq4 |
//|                   Copyright 2009-2020, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2020, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

input ENUM_TIMEFRAMES TimeFrame = PERIOD_H4;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
       Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---input ENUM_TIMEFRAMES TimeFrame = PERIOD_H4;
 
  //Arrays for the EMA
  double slowMovingAverageArray[];
  double fastMovingAverageArray[];
  string Bias;
  
  //Definition of the EMA
  double slowEMA = iMA(_Symbol,TimeFrame,18,0,MODE_EMA,PRICE_CLOSE,1);
  double fastEMA = iMA(_Symbol,TimeFrame,8,0,MODE_EMA,PRICE_CLOSE,1);
  
  // Check Bias (0 is bearish, 1 is bullish and 2 is neutral)
  if(slowEMA > fastEMA){
   Bias = "SHORT";
  }else if( slowEMA < fastEMA){
   Bias = "LONG";
  }else{
   Bias = "NEUTRAL";
   }
   
     
  Comment("Verdict: ",Bias,"\n");
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
