How could I adapt this to get the Normalized Accumulation/Distribution or Momentum(12)?
I wrote my own version of THE NORMALIZER.
This looks interesting.
Thanking You in Advance.
I wrote my own version of THE NORMALIZER.
This looks interesting.
Thanking You in Advance.
PHP Code:
/*****************************
Provided By : eSignal (c) Copyright 2004
Description: Normalized Standard Deviation - Markos Katsanos
Version 1.0
Notes:
Formula Parameters: Defaults:
Length 30
Color aqua
Thickness 2
**********************************/
function preMain() {
setStudyTitle("Normalized Standard Deviation ");
setCursorLabelName("N-Stdev",0);
// Formula Parameters
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setName("Period");
fp1.setLowerLimit(1);
fp1.setDefault(30);
// Study Parameters
var sp1 = new FunctionParameter("cColor", FunctionParameter.COLOR);
sp1.setName("Color");
sp1.setDefault(Color.aqua);
var sp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);
sp2.setName("Thickness");
sp2.setDefault(2);
}
var bEdit = true;
var aValue = null;
var vStudy = null;
function main(Length, cColor, nThick) {
if (bEdit == true) {
setDefaultBarFgColor(cColor, 0);
setDefaultBarThickness(nThick, 0);
bEdit = false;
}
if (aValue == null) aValue = new Array(Length);
if (vStudy == null) vStudy = new MAStudy(Length, 0, "Close", MAStudy.SIMPLE);
var nMA = vStudy.getValue(MAStudy.MA);
if (nMA == null) return;
var nState = getBarState();
var nSum = 0;
var ySum = 0;
var Basis = 0;
var vStdDev = 0;
if (nState == BARSTATE_NEWBAR) {
aValue.pop();
aValue.unshift(close(0));
}
aValue[0] = close(0);
if (aValue[Length-1] == null) return;
for(i = 0; i < Length; i++){
nSum += (aValue[i]);
}
Basis=nSum/Length;
for(i = 0; i < Length; i++){
ySum += (aValue[i]-Basis)*(aValue[i]-Basis);
}
vStdDev=Math.sqrt(ySum/(Length));
return (vStdDev/nMA);
}
Comment