I got the code from Stock and Commodities Magazine and I need help getting it to work. Here is the code as they have it:
}
var EMA_1 = 0.0;
function main(Length)
{
if(Length == null)
Length = 22
var K = 2 / (Length + 1);
var TO = 0;
var EMA = 0;
if( getValue("close","$adv") * getValue("volume","$ADV") +
getValue("close","$DECL") * getValue("volume","$DECL")!=0)
TO = (getValue("close","$ADV") *
getValue("volume","$ADV") - getValue("close","$DECL") *
getValue("volume","DECL")) / (getValue("close","$ADV") *
getValue("volume","$ADV") + getValue("close","DECL") *
getValue("volume","$DECL"));
EMA = K * TO +(1-K) * EMA_1;
if (getBarState() ==BARSTATE_NEWBAR)
EMA_1 = EMA;
return new Array(TO,EMA);
}
I have no prgramming experience so I don't know where to start. If someone could get this thing to work that would be great. Many thanks in advance.
Dave
}
var EMA_1 = 0.0;
function main(Length)
{
if(Length == null)
Length = 22
var K = 2 / (Length + 1);
var TO = 0;
var EMA = 0;
if( getValue("close","$adv") * getValue("volume","$ADV") +
getValue("close","$DECL") * getValue("volume","$DECL")!=0)
TO = (getValue("close","$ADV") *
getValue("volume","$ADV") - getValue("close","$DECL") *
getValue("volume","DECL")) / (getValue("close","$ADV") *
getValue("volume","$ADV") + getValue("close","DECL") *
getValue("volume","$DECL"));
EMA = K * TO +(1-K) * EMA_1;
if (getBarState() ==BARSTATE_NEWBAR)
EMA_1 = EMA;
return new Array(TO,EMA);
}
I have no prgramming experience so I don't know where to start. If someone could get this thing to work that would be great. Many thanks in advance.
Dave
Comment