Navigation:Home > Content >

MomPinboll.mq4

Time: 2016-11-09 | Download file:MomPinboll.mq4

//+------------------------------------------------------------------+
//|                                             Momentum Pinboll.mq4 |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2007, Karakurt"

#property  indicator_separate_window
#property  indicator_buffers 1

#property  indicator_color1 Blue

#property  indicator_level1 70
#property  indicator_level2 30

#property  indicator_minimum   0
#property  indicator_maximum 100

//---- indicator parameters
extern int ExtPeriodRSI = 3;
extern int ExtPeriodROC = 1;

//---- indicator buffers
double BufferRSI[];
double BufferROC[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
  IndicatorBuffers( 2 );
  
  SetIndexStyle( 0, DRAW_LINE );
  SetIndexDrawBegin( 0, ExtPeriodRSI );
  IndicatorDigits( Digits + 1 );
  
  SetIndexBuffer( 0, BufferRSI );
  SetIndexBuffer( 1, BufferROC );
  
  IndicatorShortName( "Momentum Pinboll(" + ExtPeriodRSI + "," + ExtPeriodROC + ")" );
  
  return ( 0 );
}

int start()
{
  int counted_bars = IndicatorCounted();
  int iCount;
  int i;
  
  if ( counted_bars < 0 ) 
    return ( -1 );
  if ( counted_bars > 0 )
    counted_bars--;
    
  iCount = Bars - counted_bars - ExtPeriodROC;
  
  //---- Заполнение вспом.буфера ROC
  for ( i = 0; i < iCount; i++ ) {
    BufferROC[i] = Close[ i ] - Close[ i + ExtPeriodROC ];
  } // for
  
  //---- Расчёт RSI от ROC
  for ( i = 0; i < iCount; i++ ) {
    BufferRSI[i] = iRSIOnArray( BufferROC, 0, ExtPeriodRSI, i );
  } // for
 
  return ( 0 );
}

Recommend