just testing hhv but not getting expected results, can anyone advise?
Announcement
Collapse
No announcement yet.
hhv
Collapse
X
-
try:
PHP Code:function main(){
if(getBarState() == BARSTATE_NEWBAR){
var nh = high(0);
for(var i=0; i<20; ++i){
if(high(-i) > nh) nh = high(-i);
}
var sh = hhv(20,high());
var ah = highest(20,high());
return new Array(nh,sh.getValue(0),ah.getValue(0));
}
}
WayneLast edited by waynecd; 01-29-2012, 06:08 AM.
-
Wayne, that code you posted is okay so long as you realize that all those variables are not declared and initialized at the points in the code where you typed them in. They are all hoisted to the very top of the function and initialized to whatever the default is.
This won't bite you until much later when your function(s) get longer / more complex and you use a variable declared like that *above* where you specifically assigned them. Then you'll wonder why the variable is null when you least expect it.
This is the crazy world of Javascript, not a block-scoped variable declaration C/C++ one.
Comment
Comment