Hi there.
I`m having some trouble with this formula. Don`t know why but it plots nothing...
It's an EMA based Keltner Channel. The formula is
ema +/- ConstantCoeficient * sma( 2 * emaPeriod, high - low);
The code has 2 pairs of channels, each one relative to a constant.
Hope someone can.
Here is the code:
-------------------------------------------------------
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("MA Long Keltner Channel");
setCursorLabelName("OUTSIDE UP Keltner Channel",0);
setPlotType(PLOTTYPE_DOT,0);
setDefaultBarFgColor(Color.RGB(255,255,0),0);
setCursorLabelName("INSIDE UP Keltner Channel",1);
setPlotType(PLOTTYPE_DOT,1);
setDefaultBarFgColor(Color.RGB(255,255,0),1);
setCursorLabelName("MEDIA Keltner Channel",2);
setPlotType(PLOTTYPE_DOT,2);
setDefaultBarFgColor(Color.RGB(255,255,0),2);
setCursorLabelName("INSIDE DOWN UP Keltner Channel",3);
setPlotType(PLOTTYPE_DOT,3);
setDefaultBarFgColor(Color.RGB(255,255,0),3);
setCursorLabelName("OUTSIDE DOWN DOWN Keltner Channel",4);
setPlotType(PLOTTYPE_DOT,4);
setDefaultBarFgColor(Color.RGB(255,255,0),4);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(120);
}
fpArray[x] = new FunctionParameter("Coef_Out", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(5);
}
fpArray[x] = new FunctionParameter("Coef_In", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(1.5);
}
}
var AMP = null;
var MAL = null;
var bInit = false;
var CHOH = 0;
var CHOL = 0;
var CHIH = 0;
var CHIL = 0;
var valorMediaAMP = 0;
var valorMediaMAL = 0;
function main(Length, Coef_Out, Coef_In) {
if(bInit==false){
MAL = ema(Length);
intervalo = 2*Length;
seriesma = getSeries(high() - high());
AMP = sma(intervalo, seriesma);
bInit=true;
}
valorMediaMAL = MAL.getValue(0);
valorMediaAMP = AMP.getValue(0);
CHOH = valorMediaMAL + (Coef_Out*valorMediaAMP);
CHOL = valorMediaMAL - (Coef_Out*valorMediaAMP);
CHTH = valorMediaMAL + (Coef_In*valorMediaAMP);
CHTL = valorMediaMAL - (Coef_In*valorMediaAMP);
return new Array(CHOH,CHOL,valorMediaMAL,CHTH,CHTL);
}
---------------------------------------------------
I`m having some trouble with this formula. Don`t know why but it plots nothing...
It's an EMA based Keltner Channel. The formula is
ema +/- ConstantCoeficient * sma( 2 * emaPeriod, high - low);
The code has 2 pairs of channels, each one relative to a constant.
Hope someone can.
Here is the code:
-------------------------------------------------------
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("MA Long Keltner Channel");
setCursorLabelName("OUTSIDE UP Keltner Channel",0);
setPlotType(PLOTTYPE_DOT,0);
setDefaultBarFgColor(Color.RGB(255,255,0),0);
setCursorLabelName("INSIDE UP Keltner Channel",1);
setPlotType(PLOTTYPE_DOT,1);
setDefaultBarFgColor(Color.RGB(255,255,0),1);
setCursorLabelName("MEDIA Keltner Channel",2);
setPlotType(PLOTTYPE_DOT,2);
setDefaultBarFgColor(Color.RGB(255,255,0),2);
setCursorLabelName("INSIDE DOWN UP Keltner Channel",3);
setPlotType(PLOTTYPE_DOT,3);
setDefaultBarFgColor(Color.RGB(255,255,0),3);
setCursorLabelName("OUTSIDE DOWN DOWN Keltner Channel",4);
setPlotType(PLOTTYPE_DOT,4);
setDefaultBarFgColor(Color.RGB(255,255,0),4);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(120);
}
fpArray[x] = new FunctionParameter("Coef_Out", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(5);
}
fpArray[x] = new FunctionParameter("Coef_In", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(1.5);
}
}
var AMP = null;
var MAL = null;
var bInit = false;
var CHOH = 0;
var CHOL = 0;
var CHIH = 0;
var CHIL = 0;
var valorMediaAMP = 0;
var valorMediaMAL = 0;
function main(Length, Coef_Out, Coef_In) {
if(bInit==false){
MAL = ema(Length);
intervalo = 2*Length;
seriesma = getSeries(high() - high());
AMP = sma(intervalo, seriesma);
bInit=true;
}
valorMediaMAL = MAL.getValue(0);
valorMediaAMP = AMP.getValue(0);
CHOH = valorMediaMAL + (Coef_Out*valorMediaAMP);
CHOL = valorMediaMAL - (Coef_Out*valorMediaAMP);
CHTH = valorMediaMAL + (Coef_In*valorMediaAMP);
CHTL = valorMediaMAL - (Coef_In*valorMediaAMP);
return new Array(CHOH,CHOL,valorMediaMAL,CHTH,CHTL);
}
---------------------------------------------------
Comment