Hi Alexis C. Montenegro ,
Thanks for your previous posts on external function.
I am trying to plot a moving average of the absolute value of the difference between 2 moving averages.
in other words a moving average of abs( (sma(100,close(0))-sma(50,close(0))) )
The following program works, but I can not seem to get the absolute function working when it is added.
Thanks
function preMain() {
setStudyTitle("SMA Test");
setCursorLabelName("Zero", 0);
setCursorLabelName("SMA", 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(50);
}
function main(Length) {
var vZero = 0;
var nMove = efsInternal("range");
var vSmooth = ema(Length,nMove);
return new Array (vSmooth, vZero);
}
function range () {
return (sma(100,close(0))-sma(50,close(0))); // Actually want abs( (sma(60,close(0))-sma(30,close(0))) );
}
Thanks for your previous posts on external function.
I am trying to plot a moving average of the absolute value of the difference between 2 moving averages.
in other words a moving average of abs( (sma(100,close(0))-sma(50,close(0))) )
The following program works, but I can not seem to get the absolute function working when it is added.
Thanks
function preMain() {
setStudyTitle("SMA Test");
setCursorLabelName("Zero", 0);
setCursorLabelName("SMA", 1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(50);
}
function main(Length) {
var vZero = 0;
var nMove = efsInternal("range");
var vSmooth = ema(Length,nMove);
return new Array (vSmooth, vZero);
}
function range () {
return (sma(100,close(0))-sma(50,close(0))); // Actually want abs( (sma(60,close(0))-sma(30,close(0))) );
}
Comment