#property copyright "Levix95"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Orange

extern int MAPeriod = 200 ;
extern int MAType = 1 ;           // 0: SMA, 1: EMA, 2: SMMA, 3: LWMA

//---- buffers
double OBVBuffer[];
double MABuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

    SetIndexStyle(0, DRAW_LINE);
    SetIndexBuffer(0, OBVBuffer);

    SetIndexStyle(1, DRAW_LINE,STYLE_DOT,1);
    SetIndexBuffer(1, MABuffer);
    
    IndicatorShortName("OBV");
    SetIndexLabel(0, " OBV ");
    SetIndexLabel(1, " OBV-MA ");    
//---
    return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  for(int i = 0 ; i < Bars ; i++ ){ 
      OBVBuffer[i]= iOBV(NULL, 0, PRICE_CLOSE, i);
  }
  for(i = 0 ; i < Bars ; i++ ){ 
      MABuffer[i]= iMAOnArray(OBVBuffer, 0 , MAPeriod , 0, MAType , i) ;
  }
  
  return(0); 
 }