NormalizedVolume_v1

Author: Vadim Shumilov (DrShumiloff)
Price Data Components
Series array that contains tick volumes of each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
NormalizedVolume_v1
//+------------------------------------------------------------------+
//|                                             NormalizedVolume.mq4 |
//|                         Copyright © Vadim Shumilov (DrShumiloff) |
//|                                                shumiloff@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Vadim Shumilov (DrShumiloff)"
#property link      "shumiloff@mail.ru"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 clrLightSeaGreen

extern int VolumePeriod=9;

double VolBuffer[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;

   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,VolBuffer);
   SetIndexDrawBegin(0,VolumePeriod);

   short_name="Normalized Volume("+(string)VolumePeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();

   if(counted_bars<1)
      for(int i=1; i<=VolumePeriod; i++)
         VolBuffer[Bars-i]=0.0;
   int limit=Bars-counted_bars;
   if(counted_bars>0)
      limit++;
   else
      limit-=VolumePeriod;

   for(i=0; i<limit; i++)
      VolBuffer[i]=NormalizedVolume(i);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double NormalizedVolume(int i)
  {
   double nv=0;

   for(int j=i; j<(i+VolumePeriod); j++)
      nv=nv+Volume[j];
   nv=nv/VolumePeriod;
   return(Volume[i]/nv);
  }
//+------------------------------------------------------------------+

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 ---