The following script stops working when I add .toFixed(2) (the error message states: TypeError: myVar0 has no properties). The same happens when I reassing myVar0 to vOpenTxt even when I declare the variables as global (both before and just after the "function main()" statement:
var bInit = false;
var aFPArray = new Array();
function preMain() {
setPriceStudy(true);
var x=0;
aFPArray[x] = new FunctionParameter( "vInterval", FunctionParameter.String);
with( aFPArray[x++] ) {
setName( "Interval" );
setDefault( );
}
}
var vOpenTxt =null;
var myVar0;
function main(vInterval){
if ( bInit == false ) {
if (vInterval == null) vInterval = getInterval();
if(isNaN( vInterval )) vInterval = "\""+vInterval+"\"";
myStudy0 = sma( 9, inv(eval(vInterval)) );
// debugPrintln(vInterval);
vInt = vInterval.toUpperCase()
bInit = true;
}
myVar0 = myStudy0.getValue(0);
vOpenTxt = myVar0.toFixed(2);
drawTextRelative(3, myVar0, vOpenTxt , Color.black, Color.RGB(192,192,192), Text.BOLD|Text.LEFT|Text.VCENTER|Text.FRAME , "Eras Demi LTC", 10, "text1");
return new Array( getSeries(myStudy0));
}
/*it also fails with this alternative last 2 lines of code:*/
myVar0 = myStudy0.getValue(0);
drawTextRelative(3, myVar0, myVar0.toFixed(2)+ " (9sma)" + "-" + vInt, Color.black, Color.RGB(192,192,192), Text.BOLD|Text.LEFT|Text.VCENTER|Text.FRAME , "Eras Demi LTC", 10, "text1");
return new Array( getSeries(myStudy0));
If anyone knows why I would appreciate your thoughts.
Thanks
var bInit = false;
var aFPArray = new Array();
function preMain() {
setPriceStudy(true);
var x=0;
aFPArray[x] = new FunctionParameter( "vInterval", FunctionParameter.String);
with( aFPArray[x++] ) {
setName( "Interval" );
setDefault( );
}
}
var vOpenTxt =null;
var myVar0;
function main(vInterval){
if ( bInit == false ) {
if (vInterval == null) vInterval = getInterval();
if(isNaN( vInterval )) vInterval = "\""+vInterval+"\"";
myStudy0 = sma( 9, inv(eval(vInterval)) );
// debugPrintln(vInterval);
vInt = vInterval.toUpperCase()
bInit = true;
}
myVar0 = myStudy0.getValue(0);
vOpenTxt = myVar0.toFixed(2);
drawTextRelative(3, myVar0, vOpenTxt , Color.black, Color.RGB(192,192,192), Text.BOLD|Text.LEFT|Text.VCENTER|Text.FRAME , "Eras Demi LTC", 10, "text1");
return new Array( getSeries(myStudy0));
}
/*it also fails with this alternative last 2 lines of code:*/
myVar0 = myStudy0.getValue(0);
drawTextRelative(3, myVar0, myVar0.toFixed(2)+ " (9sma)" + "-" + vInt, Color.black, Color.RGB(192,192,192), Text.BOLD|Text.LEFT|Text.VCENTER|Text.FRAME , "Eras Demi LTC", 10, "text1");
return new Array( getSeries(myStudy0));
If anyone knows why I would appreciate your thoughts.
Thanks
Comment