I tried copying the formula for the Linear Regression Reversal Indicator from the current issue of Stocks and Commodities Magazine (December 2003) but get the message there is an error. Can someone tell me what the problem is. Thanks
function preMain()
{
setStudyTitle("Lin Reg Reverse");
setCursorLabelName("LRR",0);
setDefaultBarFgColor(Color.green,0);
setDefaultBarThickness(2,0);
}
function main(Length) {
if(Length == null) Length = 5;
var sum = 0;
var i = 0;
var mt = 0;
varWT = 0;
var vWT2 = getGlobalValue("WT2");
if(vWT2 == null) {
setGlobalValue("WT2", 0);
}
for(i = Length; i > 0; i--)
sum += (i - (Length + 1) / 3 * close(i - Length);
WT = 6/ Length * (Length + 1)) * sum
if (WT >= vWT2)
{
setGlobalValue("WT2", WT);
return 1;
}
else
{
setGlobalValue("WT2", WT);
return -1;
}
return;
}
function preMain()
{
setStudyTitle("Lin Reg Reverse");
setCursorLabelName("LRR",0);
setDefaultBarFgColor(Color.green,0);
setDefaultBarThickness(2,0);
}
function main(Length) {
if(Length == null) Length = 5;
var sum = 0;
var i = 0;
var mt = 0;
varWT = 0;
var vWT2 = getGlobalValue("WT2");
if(vWT2 == null) {
setGlobalValue("WT2", 0);
}
for(i = Length; i > 0; i--)
sum += (i - (Length + 1) / 3 * close(i - Length);
WT = 6/ Length * (Length + 1)) * sum
if (WT >= vWT2)
{
setGlobalValue("WT2", WT);
return 1;
}
else
{
setGlobalValue("WT2", WT);
return -1;
}
return;
}
Comment