has someone created an .efs for calculating average daily count in the form of daily high - daily low and then averaged over 5 days and 10 days?
Announcement
Collapse
No announcement yet.
average daily count
Collapse
X
-
found this, but seems to have function error when loaded
var vCntr=0;
function preMain(){
setStudyTitle("Average Change");
setPlotType(PLOTTYPE_HISTOGRAM);
setDefaultBarThickness(6);
}
function main(vNumberOfDays){
//default number of days is 10 change it in the study params
if (vNumberOfDays==null)var vNumberOfDays = 10;
var vAverageChange=0;
var vChangeSum = 0;
if(getBarState()==BARSTATE_NEWBAR)vCntr++;
if (vCntr>vNumberOfDays){ //gotta have enough days
for(i = 0; i > -1*vNumberOfDays ; i--){ //go through the last 10 days
vChangeSum += (close(i)-open(i)); //add up the changes
}
vAverageChange = vChangeSum/vNumberOfDays; //calc the average
if (vAverageChange>0)setBarFgColor(Color.green);
if (vAverageChange<0)setBarFgColor(Color.red);
return vAverageChange; //draw the graph
}
}
-
Re: found this, but seems to have function error when loaded
pigfarmer
FWIW at my end the formula is not generating any errors and is returning the correct results
Alex
Originally posted by pigfarmer
var vCntr=0;
function preMain(){
setStudyTitle("Average Change");
setPlotType(PLOTTYPE_HISTOGRAM);
setDefaultBarThickness(6);
}
function main(vNumberOfDays){
//default number of days is 10 change it in the study params
if (vNumberOfDays==null)var vNumberOfDays = 10;
var vAverageChange=0;
var vChangeSum = 0;
if(getBarState()==BARSTATE_NEWBAR)vCntr++;
if (vCntr>vNumberOfDays){ //gotta have enough days
for(i = 0; i > -1*vNumberOfDays ; i--){ //go through the last 10 days
vChangeSum += (close(i)-open(i)); //add up the changes
}
vAverageChange = vChangeSum/vNumberOfDays; //calc the average
if (vAverageChange>0)setBarFgColor(Color.green);
if (vAverageChange<0)setBarFgColor(Color.red);
return vAverageChange; //draw the graph
}
}
Comment
Comment