//+------------------------------------------------------------------+
//|                                                         AOAC.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_minimum 30.0
#property indicator_maximum 60.0
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Gray
#property indicator_color2 Green
#property indicator_color3 Red
 
double aNon[];
double aUp[];
double aDown[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);
   SetIndexBuffer(0, aNon);
   SetIndexStyle(0, DRAW_ARROW,EMPTY,2);
   SetIndexArrow(0, 167);
   SetIndexBuffer(1, aUp);
   SetIndexStyle(1, DRAW_ARROW,EMPTY,2);
   SetIndexArrow(1, 167);
   SetIndexBuffer(2, aDown);
   SetIndexStyle(2, DRAW_ARROW,EMPTY,2);
   SetIndexArrow(2, 167);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i, limit;
   double dcAC, dpAC, dcAO, dpAO;
   bool bACDir, bAODir;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit = MathMin(Bars-counted_bars,Bars-1);
//----
   for(i=limit; i>=0; i--) {
      dcAC = iAC(NULL,0,i+1);
      dpAC = iAC(NULL,0,i+2);
      dcAO = iAO(NULL,0,i+1);
      dpAO = iAO(NULL,0,i+2);
      
      if (dcAC >= dpAC) bACDir = true; else bACDir = false;
      if (dcAO >= dpAO) bAODir = true; else bAODir = false;
      
      if (bAODir && bACDir) aUp[i+1] = 45;
      else if (!bAODir && !bACDir) aDown[i+1] = 45;
      else aNon[i+1] = 45;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+