https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/vama.
I am getting a bit stuck trying to make sense of the numbers it's coming up with on the data window. The indicator is not complete. Right now I am trying to make sure the numbers generated make sense. I believe the issue is in how I am calculating the volume increment. However, I'm not sure.
Any help would be appreciated, and I hope I am posting this in the correct section.
- Code: Select all
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow
extern int Length=200;
double Vol[];
double VolumeRatio[];
double PriceVolumeRatio[];
double VAMA[];
int init()
{
IndicatorShortName("VAMA Modfied Fidelity Formula ");
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,Vol);
SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(1,VolumeRatio);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(2,PriceVolumeRatio);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,VAMA);
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int limit = Bars-1;
int pos = limit;
//Create Volume Array
while(limit>=0)
{
Vol[limit]=iVolume(NULL,NULL,limit);
limit--;
}
//Average Volume of all bars in the chart.
double VolArraySum;
int limitarray = ArraySize(Vol);
while(limitarray>=0)
{
VolArraySum +=Vol[limitarray];
limitarray--;
}
//Take average of Volume Array
double VolumeIncrement = (VolArraySum/ArraySize(Vol))*.67;
//Alert(VolumeIncrement);//Use to test AverageVolume
while(pos>=0)
{
VolumeRatio[pos]=Vol[pos]/VolumeIncrement;
PriceVolumeRatio[pos]=VolumeRatio[pos]*iClose(NULL,NULL,pos);
VAMA[pos]=iMAOnArray(PriceVolumeRatio,0,Length,0,MODE_SMA,pos);
pos--;
}
return(0);
}