Hi all,
I have a question about programming this indicator. It's my first ever go at an indicator and I'm not sure how to use the buffer and how to get it to show data on the screen. The bit where I try to use the buffer I just copy/pasted from another indicator but obviously it doesn't work for this one.
The whole idea of the indicator is to show the current volume compared to the average volume for that time of the week.
Any help would be appreciated!
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Lime
//---- input parameters
extern double ExtParam1;
extern double LookBackBars = 25;
//---- buffers
double ExtMapBuffer1[];
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
int start()
{
int counted_bars=IndicatorCounted(),
weekback, i, pointer, limit;
double total, average;
//----
weekback = 7200/Period(); //calculate number of bars in a week
//add volumes for averaging
for(i=0; i <= LookBackBars; i++)
{
pointer = i*weekback;
total = total + Volume[pointer];
}
//calculate average
average = total/LookBackBars;
i=Bars-counted_bars-1; // Index of the first uncounted
while(i>=0) // Loop for uncounted bars
{
ExtMapBuffer1[i] = ((Volume[0]/average) *100);
i--; // Calculating index of the next bar
}
//----
return(0);
}
I have a question about programming this indicator. It's my first ever go at an indicator and I'm not sure how to use the buffer and how to get it to show data on the screen. The bit where I try to use the buffer I just copy/pasted from another indicator but obviously it doesn't work for this one.
The whole idea of the indicator is to show the current volume compared to the average volume for that time of the week.
Any help would be appreciated!
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Lime
//---- input parameters
extern double ExtParam1;
extern double LookBackBars = 25;
//---- buffers
double ExtMapBuffer1[];
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
int start()
{
int counted_bars=IndicatorCounted(),
weekback, i, pointer, limit;
double total, average;
//----
weekback = 7200/Period(); //calculate number of bars in a week
//add volumes for averaging
for(i=0; i <= LookBackBars; i++)
{
pointer = i*weekback;
total = total + Volume[pointer];
}
//calculate average
average = total/LookBackBars;
i=Bars-counted_bars-1; // Index of the first uncounted
while(i>=0) // Loop for uncounted bars
{
ExtMapBuffer1[i] = ((Volume[0]/average) *100);
i--; // Calculating index of the next bar
}
//----
return(0);
}