Merry Christmas, hope you all had a good year, and I wish all the best ( buys and sells ) for the next year.
Here's another snippet of code I've been stumbling over. I don't really understand how to pass a number variable out of a " if new bar " sequence.
I'm playing with average true range, and I know I can just use the E-Signal function but ...
I would like to calculate " A " once at the new bar, and have it available for each tick after that during the current bar.
The following code does work, but it calculates " A " every tick.
I have two lines of code " // " commented out. When I remove the two " // " I get an error message that specifies, " A is not defined ".
Many many thanks in advance to the fine efs Guru who, well, doesn't quite enlighten me, but, helps me along the way another little step.
function preMain() {
setPriceStudy(true);
setDefaultBarFgColor(Color.RGB(250,250, 0),0);
setDefaultBarFgColor(Color.RGB(250,250, 0),1);
}
var bInit = false;
function main() {
if ( bInit == false ) {
E10 = middleDonchian(6);
bInit = true;
}
//if(getBarState()==BARSTATE_NEWBAR){
A1 = high(-1) - low(-1);
A2 = high(-2) - low(-2);
A3 = high(-3) - low(-3);
A = (A1+A2+A3) / 3 ;
//}
E = E10.getValue(0);
Ep1 = E + A;
En1 = E - A;
return new Array(Ep1,En1);
}
Here's another snippet of code I've been stumbling over. I don't really understand how to pass a number variable out of a " if new bar " sequence.
I'm playing with average true range, and I know I can just use the E-Signal function but ...
I would like to calculate " A " once at the new bar, and have it available for each tick after that during the current bar.
The following code does work, but it calculates " A " every tick.
I have two lines of code " // " commented out. When I remove the two " // " I get an error message that specifies, " A is not defined ".
Many many thanks in advance to the fine efs Guru who, well, doesn't quite enlighten me, but, helps me along the way another little step.
function preMain() {
setPriceStudy(true);
setDefaultBarFgColor(Color.RGB(250,250, 0),0);
setDefaultBarFgColor(Color.RGB(250,250, 0),1);
}
var bInit = false;
function main() {
if ( bInit == false ) {
E10 = middleDonchian(6);
bInit = true;
}
//if(getBarState()==BARSTATE_NEWBAR){
A1 = high(-1) - low(-1);
A2 = high(-2) - low(-2);
A3 = high(-3) - low(-3);
A = (A1+A2+A3) / 3 ;
//}
E = E10.getValue(0);
Ep1 = E + A;
En1 = E - A;
return new Array(Ep1,En1);
}
Comment