Not sure why I can't do a MAstudy on a rd_ma. I get an error. Could someone help this newbie? I am sure it is how I am handling the array.
Thanks
var vCCI = null;
var vMA = null;
var vMA1 = null;
var vMA2 = null;
var vMA3 = null;
var rd_ma = null;
function preMain() {
setStudyTitle("CCI_T3");
setCursorLabelName("CCI", 0);
setDefaultBarFgColor(Color.red, 0);
setCursorLabelName("TMA", 1);
setDefaultBarFgColor(Color.blue, 1);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(14); //Edit this value to set a new default
var fp2 = new FunctionParameter("Source", FunctionParameter.STRING);
fp2.setName("CCISource");
fp2.addOption("Close");
fp2.addOption("High");
fp2.addOption("Low");
fp2.addOption("Open");
fp2.addOption("HL/2");
fp2.addOption("HLC/3");
fp2.addOption("OHLC/4");
fp2.setDefault("HLC/3"); //Edit this value to set a new default
var fp3 = new FunctionParameter("Upper", FunctionParameter.NUMBER);
fp3.setDefault(100); //Edit this value to set a new default
var fp4 = new FunctionParameter("Lower", FunctionParameter.NUMBER);
fp4.setDefault(-100); //Edit this value to set a new default
var fp5 = new FunctionParameter("Smooth", FunctionParameter.NUMBER);
fp5.setLowerLimit(1);
fp5.setDefault(7); //Edit this value to set a new default
}
function Get_T3(ma1, ma2, ma3) {
var dsum = 0.0;
dsum = (3 * vMA1) - (3 * vMA2) + vMA3;
return (dsum);
}
function main(Length, Source, Upper, Lower, Smooth) {
if (vCCI == null) vCCI = new CCIStudy(Length, Source);
addBand( Upper, PS_SOLID, 1, Color.black,1);
addBand( Lower, PS_SOLID, 1, Color.black,2);
if (vMA1 == null) vMA1= new MAStudy(Smooth, 0, vCCI,MAStudy.MA, MAStudy.EXPONENTIAL);
if (vMA2 == null) vMA2 = new MAStudy(Smooth, 0, vMA1,MAStudy.MA, MAStudy.EXPONENTIAL);
if (vMA3 == null) vMA3 = new MAStudy(Smooth, 0, vMA2,MAStudy.MA, MAStudy.EXPONENTIAL);
if (rd_ma == null) rd_ma = new Get_T3(vMA1,vMA2,vMA3);
if (vMA == null) vMA = new MAStudy(3, 0, rd_ma,MAStudy.MA, MAStudy.SIMPLE);
return new Array(vCCI.getValue(CCIStudy.CCI), vMA.getValue(MAStudy.MA));
}
Thanks
var vCCI = null;
var vMA = null;
var vMA1 = null;
var vMA2 = null;
var vMA3 = null;
var rd_ma = null;
function preMain() {
setStudyTitle("CCI_T3");
setCursorLabelName("CCI", 0);
setDefaultBarFgColor(Color.red, 0);
setCursorLabelName("TMA", 1);
setDefaultBarFgColor(Color.blue, 1);
var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
fp1.setLowerLimit(1);
fp1.setDefault(14); //Edit this value to set a new default
var fp2 = new FunctionParameter("Source", FunctionParameter.STRING);
fp2.setName("CCISource");
fp2.addOption("Close");
fp2.addOption("High");
fp2.addOption("Low");
fp2.addOption("Open");
fp2.addOption("HL/2");
fp2.addOption("HLC/3");
fp2.addOption("OHLC/4");
fp2.setDefault("HLC/3"); //Edit this value to set a new default
var fp3 = new FunctionParameter("Upper", FunctionParameter.NUMBER);
fp3.setDefault(100); //Edit this value to set a new default
var fp4 = new FunctionParameter("Lower", FunctionParameter.NUMBER);
fp4.setDefault(-100); //Edit this value to set a new default
var fp5 = new FunctionParameter("Smooth", FunctionParameter.NUMBER);
fp5.setLowerLimit(1);
fp5.setDefault(7); //Edit this value to set a new default
}
function Get_T3(ma1, ma2, ma3) {
var dsum = 0.0;
dsum = (3 * vMA1) - (3 * vMA2) + vMA3;
return (dsum);
}
function main(Length, Source, Upper, Lower, Smooth) {
if (vCCI == null) vCCI = new CCIStudy(Length, Source);
addBand( Upper, PS_SOLID, 1, Color.black,1);
addBand( Lower, PS_SOLID, 1, Color.black,2);
if (vMA1 == null) vMA1= new MAStudy(Smooth, 0, vCCI,MAStudy.MA, MAStudy.EXPONENTIAL);
if (vMA2 == null) vMA2 = new MAStudy(Smooth, 0, vMA1,MAStudy.MA, MAStudy.EXPONENTIAL);
if (vMA3 == null) vMA3 = new MAStudy(Smooth, 0, vMA2,MAStudy.MA, MAStudy.EXPONENTIAL);
if (rd_ma == null) rd_ma = new Get_T3(vMA1,vMA2,vMA3);
if (vMA == null) vMA = new MAStudy(3, 0, rd_ma,MAStudy.MA, MAStudy.SIMPLE);
return new Array(vCCI.getValue(CCIStudy.CCI), vMA.getValue(MAStudy.MA));
}
Comment