//+------------------------------------------------------------------+ //| 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; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if(counted_bars==0) limit--; 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) ExtBuffer[i] = NormalizeDouble(Buffer[i]/d,4); } return(0); }