I have copy and pasted a sample strategy found in eSignals help guide. The code is below. When I add the study to my chart, I do not see any buy/sell signals giving any indication that it is trading. However, when I run a backtest I do see trades generated. Am I doing something wrong?
Code:
var fpArray = new Array(); var bInit = false; function preMain() { setPriceStudy(false); setStudyTitle("roCombined"); setCursorLabelName("CCI MA Slow",0); setDefaultBarFgColor(Color.red,0); setCursorLabelName("CCI MA FAST",1); setDefaultBarFgColor(Color.blue,1); setColorPriceBars(true); setDefaultPriceBarColor(Color.grey); askForInput(); var x = 0; fpArray[x] = new FunctionParameter("FastMA", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(10); } fpArray[x] = new FunctionParameter("SlowMA", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(20); } } var xSMA = null; var xFMA = null; function main(FastMA,SlowMA) { var nBarState = getBarState(); if(nBarState == BARSTATE_ALLBARS) { if (FastMA == null) FastMA = 10; if (SlowMA == null) SlowMA = 20; } if (bInit == false) { var xCCI = cci(10); if (xCCI == null) return; xSMA = sma(SlowMA, xCCI); xFMA = sma(FastMA, xCCI); bInit = true; } if(getCurrentBarIndex()==0) return; var nSMA = xSMA.getValue(0); var nFMA = xFMA.getValue(0); if(nSMA < nFMA && !Strategy.isLong()) Strategy.doLong("Long", Strategy.CLOSE, Strategy.THISBAR); if(nSMA > nFMA && !Strategy.isShort()) Strategy.doShort("Short", Strategy.CLOSE, Strategy.THISBAR); if(Strategy.isLong()) setPriceBarColor(Color.lime); if(Strategy.isShort()) setPriceBarColor(Color.red); return new Array(nSMA, nFMA); }
Comment