I have written an indicator for coloring the price bars. It works fine until I type in a new symbol. When the new symbol's data displays, the indicator is not visible, instead the default red/green bars are shown.
If I reload the indicator, it does not show. But, I know it is reloading, because I have tried changing the screen name, and the screen name is revised when the indicator reloads, but not the price bar coloring.
If I go to Edit Studies and click Apply, the indicator shows.
If the session is active, sometimes the indicator shows after 30 secs.
How do I get the the indicator to continue to show when I change the symbol?
I have included the code, below.
Thanks for any help. Gnossos
**********************************
var hL=0;
var lH=0;
var upsw=0;
var SwLine=0;
function preMain() {
setStudyTitle("NoiseBar");
setCursorLabelName("NoiseBar",0);
setPriceStudy(true);
}
function main() {
if(hL==0) hL=low(); //set initial values for hL and lH
if(lH==0) lH=high();
if(upsw==1) {
if(low()>hL) hL=low();
if(high()<hL) { //swing turns to down
upsw=0;
lH=high();
}
}
if(upsw==0) {
if(high()<lH) lH=high();
if(low()>lH) { //swing turns to up
upsw=1;
hL=low();
}
}
if(upsw==1) {
setPriceBarColor(Color.lime);
if(low()<hL) setPriceBarColor(Color.grey);
}
if(upsw==0) {
setPriceBarColor(Color.red);
if(high()>lH) setPriceBarColor(Color.grey);
}
}
If I reload the indicator, it does not show. But, I know it is reloading, because I have tried changing the screen name, and the screen name is revised when the indicator reloads, but not the price bar coloring.
If I go to Edit Studies and click Apply, the indicator shows.
If the session is active, sometimes the indicator shows after 30 secs.
How do I get the the indicator to continue to show when I change the symbol?
I have included the code, below.
Thanks for any help. Gnossos
**********************************
var hL=0;
var lH=0;
var upsw=0;
var SwLine=0;
function preMain() {
setStudyTitle("NoiseBar");
setCursorLabelName("NoiseBar",0);
setPriceStudy(true);
}
function main() {
if(hL==0) hL=low(); //set initial values for hL and lH
if(lH==0) lH=high();
if(upsw==1) {
if(low()>hL) hL=low();
if(high()<hL) { //swing turns to down
upsw=0;
lH=high();
}
}
if(upsw==0) {
if(high()<lH) lH=high();
if(low()>lH) { //swing turns to up
upsw=1;
hL=low();
}
}
if(upsw==1) {
setPriceBarColor(Color.lime);
if(low()<hL) setPriceBarColor(Color.grey);
}
if(upsw==0) {
setPriceBarColor(Color.red);
if(high()>lH) setPriceBarColor(Color.grey);
}
}
Comment