File Name: MAPercentChannel.efs
Description:
MA Percent Channel
Formula Parameters:
MA Method : SMA
MA Price Source : CLOSE
Length : 55
Shift : 0
Deviation : 1
Notes:
Download File:
MAPercentChannel.efs
EFS Code:
Description:
MA Percent Channel
Formula Parameters:
MA Method : SMA
MA Price Source : CLOSE
Length : 55
Shift : 0
Deviation : 1
Notes:
Download File:
MAPercentChannel.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2009. All rights reserved. This sample eSignal
Formula Script (EFS) is for educational purposes only and may be
modified and saved under a new file name. eSignal is not responsible
for the functionality once modified. eSignal reserves the right
to modify and overwrite this EFS file with each new release.
Description:
MA Percent Channel
Version: 1.0 06/25/2009
Formula Parameters: Default:
MA Method SMA
MA Price Source CLOSE
Length 55
Shift 0
Deviation 1
Notes:
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain(){
setPriceStudy(true);
setShowCursorLabel(true);
setShowTitleParameters(false);
setStudyTitle("MA Percent Channel");
setCursorLabelName("U1", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE, 0);
setDefaultBarThickness(1, 0);
setCursorLabelName("U2", 1);
setDefaultBarFgColor(Color.blue, 1);
setPlotType(PLOTTYPE_LINE, 1);
setDefaultBarThickness(1, 1);
setCursorLabelName("U3", 2);
setDefaultBarFgColor(Color.blue, 2);
setPlotType(PLOTTYPE_LINE, 2);
setDefaultBarThickness(2, 2);
setCursorLabelName("D1", 3);
setDefaultBarFgColor(Color.red, 3);
setPlotType(PLOTTYPE_LINE, 3);
setDefaultBarThickness(1, 3);
setCursorLabelName("D2", 4);
setDefaultBarFgColor(Color.red, 4);
setPlotType(PLOTTYPE_LINE, 4);
setDefaultBarThickness(1, 4);
setCursorLabelName("D3", 5);
setDefaultBarFgColor(Color.red, 5);
setPlotType(PLOTTYPE_LINE, 5);
setDefaultBarThickness(2, 5);
setCursorLabelName("LB", 6);
setDefaultBarFgColor(Color.green, 6);
setPlotType(PLOTTYPE_LINE, 6);
setDefaultBarThickness(2, 6);
var x = 0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(55);
}
fpArray[x] = new FunctionParameter("Shift", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(0);
setDefault(0);
}
fpArray[x] = new FunctionParameter("Deviation", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("sMAType", FunctionParameter.STRING);
with(fpArray[x++]) {
setName("MA Method");
addOption("sma");
addOption("ema");
addOption("wma");
addOption("vwma");
setDefault("sma");
}
fpArray[x] = new FunctionParameter("sMAPriceSource", FunctionParameter.STRING);
with(fpArray[x++]) {
setName("MA Price Source");
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
}
var xMA = null;
function main(sMAType, sMAPriceSource, Length, Shift, Deviation) {
var nBarState = getBarState();
var nMA1 = 0;
var nMA2 = 0;
var nMA3 = 0;
var nMA4 = 0;
var nMA5 = 0;
var nMA6 = 0;
var nMA7 = 0;
if (nBarState == BARSTATE_ALLBARS) {
if(Length == null) Length = 55;
if(Shift == null) Shift = 0;
if(Deviation == null) Deviation = 1;
if(sMAType == null) sMAType = "sma";
if(sMAPriceSource == null) sMAPriceSource = "close";
}
if (bInit == false) {
xMA = eval(sMAType)(Length, eval(sMAPriceSource)());
bInit = true;
}
nMA7 = xMA.getValue(-Shift);
if (nMA7 == null) return;
nMA1 = (1 + Deviation * 0.382 / 100) * nMA7;
nMA4 = (1 - Deviation * 0.382 / 100) * nMA7;
nMA2 = (1 + Deviation * 0.618 / 100) * nMA7;
nMA5 = (1 - Deviation * 0.618 / 100) * nMA7;
nMA3 = (1 + Deviation / 100) * nMA7;
nMA6 = (1 - Deviation / 100) * nMA7;
return new Array(nMA1, nMA2, nMA3, nMA4, nMA5, nMA6, nMA7);
}