I am new to writing code in JavaScript. On my first efs studies, the lines plot correctly, except for the current bar. They are essentially exp. moving averages. As the ticks accumulate on the current bar the line moves up into the current bar's value.
How can I prevent this? Thanks, Ron
Here is the calculation portion of the code:
function main() {
//Check for initial null values
if (nn == null) {
nn = 1;
Osc1_1=(high(0)+low(0))/2
Osc2_1=(high(0)+low(0))/2
Osc3_1=(high(0)+low(0))/2
Osc3_2=(high(0)+low(0))/2
Osc3_3=(high(0)+low(0))/2
Osc3_4=(high(0)+low(0))/2
Osc4_1=(high(0)+low(0))/2
Osc4_2=(high(0)+low(0))/2
Osc4_3=(high(0)+low(0))/2
Osc4_4=(high(0)+low(0))/2
}
// If we are past the first bar, store away current osc values as prev values, calc new osc values
if (nn>=1){
Osc1=(0.53*Osc1_1)+(0.47*close(0));
Osc2=(0.53*Osc2_1)+(0.47*Osc1);
Osc1_1=Osc1;
Osc2_1=Osc2;
}
nn++
return (Osc2);
}
How can I prevent this? Thanks, Ron
Here is the calculation portion of the code:
function main() {
//Check for initial null values
if (nn == null) {
nn = 1;
Osc1_1=(high(0)+low(0))/2
Osc2_1=(high(0)+low(0))/2
Osc3_1=(high(0)+low(0))/2
Osc3_2=(high(0)+low(0))/2
Osc3_3=(high(0)+low(0))/2
Osc3_4=(high(0)+low(0))/2
Osc4_1=(high(0)+low(0))/2
Osc4_2=(high(0)+low(0))/2
Osc4_3=(high(0)+low(0))/2
Osc4_4=(high(0)+low(0))/2
}
// If we are past the first bar, store away current osc values as prev values, calc new osc values
if (nn>=1){
Osc1=(0.53*Osc1_1)+(0.47*close(0));
Osc2=(0.53*Osc2_1)+(0.47*Osc1);
Osc1_1=Osc1;
Osc2_1=Osc2;
}
nn++
return (Osc2);
}
Comment