NormalizedVolume_v2

Author: Vadim Shumilov (DrShumiloff)
NormalizedVolume_v2
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
NormalizedVolume_v2
//+------------------------------------------------------------------+
//|                                          NormalizedVolume_v2.mq4 |
//|                         Copyright © Vadim Shumilov (DrShumiloff) |
//|                                                shumiloff@mail.ru |
//|                                                     ICQ 84796634 |
//+------------------------------------------------------------------+
#property copyright "Vadim Shumilov (DrShumiloff)"
#property link      "shumiloff@mail.ru"
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 LightSeaGreen
#property indicator_width1 2
#property indicator_level1 1.0
#property indicator_level2 2.0
#property indicator_minimum 0

/*
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 Buffer[];
double ExtBuffer[];

int init()
{
   IndicatorBuffers(1);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, ExtBuffer);
   SetIndexDrawBegin(0, VolumePeriod);
  
   string short_name = "NV (" + VolumePeriod + ")";
   IndicatorShortName(short_name);
   SetIndexLabel(0, short_name);

   ArrayResize(Buffer, Bars);      ArrayInitialize(Buffer, 0);
   ArrayResize(ExtBuffer, Bars);   ArrayInitialize(ExtBuffer, 0);

   return(0);
}

int start()
{
   int i, limit;
   int counted_bars = IndicatorCounted();
   if (counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
   
   ArraySetAsSeries(Buffer, true);
   for(i = 0; i < limit; i++) Buffer[i] = Volume[i];
   
   for(i = 0; i < limit; i++)
   {
      if (Method < 4)
        ExtBuffer[i] = NormalizeDouble(Buffer[i] / iMAOnArray(Buffer, 0, VolumePeriod, 0, Method, i+Shift), 4);
      else
        ExtBuffer[i] = NormalizeDouble(Buffer[i] / (3*iMAOnArray(Buffer, 0, VolumePeriod, 0, MODE_LWMA, i+Shift) - 2*iMAOnArray(Buffer, 0, VolumePeriod, 0, MODE_SMA, i+Shift)), 4);
   }
   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 ---