NormalizedVolumeOscillator_v2_v1

Author: Vadim Shumiloff
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
NormalizedVolumeOscillator_v2_v1
//+------------------------------------------------------------------+
//|                              Normalized Volume Oscillator v2.mq4 |
//|                                                  Vadim Shumiloff |
//|                                                shumiloff@mail.ru |
//|                                                     ICQ 84796634 |
//+------------------------------------------------------------------+
#property copyright "Vadim Shumiloff"
#property link      "shumiloff@mail.ru"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Blue        // Çàêðàñêà îòðèöàòåëüíûõ áàðîâ
#property indicator_color2 Green       // Çàêðàñêà áàðîâ 0 - 38.2
#property indicator_color3 Lime        // Çàêðàñêà áàðîâ 38.2 - 61.8
#property indicator_color4 Yellow      // Çàêðàñêà áàðîâ 61.8 - 100
#property indicator_color5 Red         // Çàêðàñêà áàðîâ ñâûøå 100

#property indicator_width1 2  
#property indicator_width2 2  
#property indicator_width3 2  
#property indicator_width4 2  
#property indicator_width5 2  

/*
Method: 
0 - MODE_SMA
1 - MODE_EMA 
2 - MODE_SMMA
3 - MODE_LWMA
4 - MODE_LRMA
*/
extern int Method=0;
extern int VolumePeriod=21;
extern int Shift=1;

double VolBufferH1[];
double VolBufferH2[];
double VolBufferH3[];
double VolBufferH4[];
double VolBufferH5[];
double Buffer[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;

   IndicatorBuffers(5);

   SetIndexBuffer(0,VolBufferH1);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,VolBufferH1);
   SetIndexDrawBegin(0, VolumePeriod);

   SetIndexBuffer(1,VolBufferH2);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,VolBufferH2);
   SetIndexDrawBegin(1, VolumePeriod);

   SetIndexBuffer(2,VolBufferH3);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,VolBufferH3);
   SetIndexDrawBegin(2, VolumePeriod);

   SetIndexBuffer(3,VolBufferH4);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,VolBufferH4);
   SetIndexDrawBegin(3, VolumePeriod);

   SetIndexBuffer(4,VolBufferH5);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexBuffer(4,VolBufferH5);
   SetIndexDrawBegin(4, VolumePeriod);

   short_name="NVO ("+VolumePeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

   ArrayResize(Buffer,Bars);
   ArrayInitialize(Buffer,0);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,limit;
   double nvo;

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   if(counted_bars==0) limit--;

   ArrayResize(Buffer,Bars);
   ArraySetAsSeries(Buffer,true);

   for(i=0; i<limit; i++) Buffer[i]=Volume[i];

   for(i=0; i<limit; i++)
     {

      double d=0;

      if(Method<4)
         d=iMAOnArray(Buffer,0,VolumePeriod,0,Method,i+Shift);
      else
         d=(3*iMAOnArray(Buffer,0,VolumePeriod,0,MODE_LWMA,i+Shift)-2*iMAOnArray(Buffer,0,VolumePeriod,0,MODE_SMA,i+Shift));

      if(d!=0) nvo=NormalizeDouble((Buffer[i]/d)*100-100,4);

      if(nvo<0)
         VolBufferH1[i]=nvo;
      else
        {
         if(nvo<38.2)
            VolBufferH2[i]=nvo;
         else
           {
            if(nvo<61.8)
               VolBufferH3[i]=nvo;
            else
              {
               if(nvo<100)
                 {
                  VolBufferH4[i]=nvo;
                 }
               else VolBufferH5[i]=nvo;
              }
           }
        }
     }

   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---