hello friends
here an oscillator that i try to add on metastock v 10 but i don' t know where is the problem.who can detect small error de help add it.
belkhayate Oscillateur
function preMain() {
setStudyTitle("Belkhayate Indicator");
setPriceStudy(false);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.blue, 0);
}
var cg_1 = 0;
function main(Length) {
if(Length == null)
Length = 10;
var count = 0;
var num = 0;
var cg;
var temp;
var denom = 0;
var vHigh = getValue("high", 0, -Length);
var vLow = getValue("low", 0, -Length);
if(vHigh == null || vLow == null) {
return;
}
for(count = 0; count < Length - 1; count++) {
num += (1 + count) * ((vHigh[count] + vLow[count])/2);
denom += (vHigh[count] + vLow[count])/2;
}
if(denom != 0)
cg = - num/denom;
temp = cg_1;
if (getBarState() == BARSTATE_NEWBAR)
cg_1 = cg;
return new Array(cg,temp);
}
/*
Inputs: Price((H+L)/2),
Length(10);
Vars: count(0),
Num(0),
Denom(0),
CG(0);
Num=0;
Denom=0;
For count=0 to Length-1 begin
Num=Num+(1+count)*(Price[count]);
Denom=Denom+(Price[count]);
End;
If Denom<>0 then CG=-Num/Denom;
Plot1(CG,"CG");
Plot2(CG[1],"CG1");
*/
here an oscillator that i try to add on metastock v 10 but i don' t know where is the problem.who can detect small error de help add it.
belkhayate Oscillateur
function preMain() {
setStudyTitle("Belkhayate Indicator");
setPriceStudy(false);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.blue, 0);
}
var cg_1 = 0;
function main(Length) {
if(Length == null)
Length = 10;
var count = 0;
var num = 0;
var cg;
var temp;
var denom = 0;
var vHigh = getValue("high", 0, -Length);
var vLow = getValue("low", 0, -Length);
if(vHigh == null || vLow == null) {
return;
}
for(count = 0; count < Length - 1; count++) {
num += (1 + count) * ((vHigh[count] + vLow[count])/2);
denom += (vHigh[count] + vLow[count])/2;
}
if(denom != 0)
cg = - num/denom;
temp = cg_1;
if (getBarState() == BARSTATE_NEWBAR)
cg_1 = cg;
return new Array(cg,temp);
}
/*
Inputs: Price((H+L)/2),
Length(10);
Vars: count(0),
Num(0),
Denom(0),
CG(0);
Num=0;
Denom=0;
For count=0 to Length-1 begin
Num=Num+(1+count)*(Price[count]);
Denom=Denom+(Price[count]);
End;
If Denom<>0 then CG=-Num/Denom;
Plot1(CG,"CG");
Plot2(CG[1],"CG1");
*/