For the life of me I cannot understand why the two different results are occuring in the following routine when trying to calculate
sma(close(0)"minus"close(-len)) or sma(close(0)"divide"close(-len)). Minus works but divide does not.
Yet without the sma() part, xDiv.getValue(0) returns a value when subtraction or division is applied in closeDiv().
I understand that sma() requires a series object to work on which is what it gets, so there must be a difference between 'subtract' and 'divide'...
So the question is, what is it I don't understand??
Regards
Nigel
sma(close(0)"minus"close(-len)) or sma(close(0)"divide"close(-len)). Minus works but divide does not.
Yet without the sma() part, xDiv.getValue(0) returns a value when subtraction or division is applied in closeDiv().
I understand that sma() requires a series object to work on which is what it gets, so there must be a difference between 'subtract' and 'divide'...
So the question is, what is it I don't understand??
Regards
Nigel
PHP Code:
var len = 20;
var xDiv = null;
function main(){
if(xDiv == null) xDiv = efsInternal("closeDiv", len, close());
var efsClose = sma(10, getSeries(xDiv), 0);
return (efsClose);
}
function closeDiv( len, source ) {
var ret = source.getValue(0) - source.getValue(-len); //subtract WORKS
//var ret = source.getValue(0) / source.getValue(-len); //divide DOES NOT WORK??
return( ret );
}
Comment