Any help is appreciated.
When I run the following code the chart stays on "Loading Data..." forever. It does not affect any other operation and I can even delete the study from the chart when it is in this state.
I would like to use the close(0) of a 1 min chart (symbol $ADD) when it is above or below a 21 ema for 1 min chart of $ADD to color the background of a 55T chart of the "ES #F".
Attached is a picture of the chart and the code sample follows:
When I run the following code the chart stays on "Loading Data..." forever. It does not affect any other operation and I can even delete the study from the chart when it is in this state.
I would like to use the close(0) of a 1 min chart (symbol $ADD) when it is above or below a 21 ema for 1 min chart of $ADD to color the background of a 55T chart of the "ES #F".
Attached is a picture of the chart and the code sample follows:
PHP Code:
var bInit = false;
function preMain() {
setPriceStudy(true);
}
var vLastAlert = -1;
var myStudy0 = null;
var Type0 = "ema";
var Length0 = 21;
var Source0 = "close";
var Offset = 0;
var vSymbol = "$ADD";
var Interval0 = 1;
function main(){
if ( bInit == false ) {
if(vSymbol == null) vSymbol = getSymbol();
if(Interval0 == null) Interval0 = getInterval();
var xSymbol = vSymbol+","+Interval0;
if(myStudy0 == null) myStudy0 = offsetSeries(eval(Type0)(Length0,eval(Source0)(sym(xSymbol))),Offset);
bInit = true;
}
var CloseVal = close(0,sym(xSymbol));
if (CloseVal > myStudy0.getValue(0)){
setBarBgColor(Color.RGB(255,255,192));
} else if (CloseVal < myStudy0.getValue(0)){
setBarBgColor(Color.RGB(255,234,255));
}
return getSeries(myStudy0).toFixed(2);
}
Comment