#property copyright "Copyright © 2005, Anri"
#property link "http://tradestation.narod.ru/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
extern int nPeriod = 5;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
int init()
{
string short_name;
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
short_name = "iAvgVol(" + nPeriod + ")";
IndicatorShortName(short_name);
SetIndexLabel(0, "Volume");
SetIndexLabel(1, "AvgVolume");
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int counted_bars = IndicatorCounted();
int i, shift;
double nSum;
if(counted_bars < 1)
{
for(i = 1; i <= 0; i++)
{
ExtMapBuffer1[Bars-i] = 0;
ExtMapBuffer2[Bars-i] = 0;
}
}
for(shift = Bars - 1; shift >= 0; shift--)
{
nSum = Volume[shift];
ExtMapBuffer1[shift] = nSum;
if((nPeriod > 0) && (shift < (Bars - nPeriod - 1)))
{
for(i = nPeriod - 1; i >= 1; i--)
{
nSum = nSum + ExtMapBuffer1[shift+i];
}
nSum = nSum / nPeriod;
}
ExtMapBuffer2[shift] = nSum;
}
return(0);
}