Hi,
I am trying to add some moving averages to the B% formula from the Bollinger Study package, but for some reason I am getting an error message on the second use of 'MAStudy' in the following code:
My Formulas\Percent B Custom.efs, line 41: Error: Failed to call 'MAStudy': parameter # 5 is invalid.
Strangely enough the first use of 'MAStudy' with almost the same paramter set works perfectly fine:
var vSMA10_of_vBollinger20_1 = new MAStudy(10, 0, vBollinger20, BollingerStudy.UPPER, MAStudy.SIMPLE);
Only on the second use I get the error message:
var vSMA10_of_vBollinger20_2 = new MAStudy(10, 0, vBollinger20, BollingerStudy.LOWER, MAStudy.SIMPLE);
Here is the complete efs code:
function preMain() {
setPriceStudy(false);
setStudyTitle("MA of B%");
setCursorLabelName("vB%", 0);
setCursorLabelName("vGD10", 1);
setCursorLabelName("vEMA8", 2);
setDefaultBarFgColor(Color.RGB(0xFE,0x00,0x6D), 0);
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 1);
setDefaultBarFgColor(Color.RGB(0xFE,0x69,0x00), 2);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
setDefaultBarThickness(1,2);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setPlotType(PLOTTYPE_LINE,2);
}
var vBollinger20 = new BollingerStudy(20, "Close", 20);
var vSMA10 = new MAStudy(10, 0, "Close", MAStudy.SIMPLE);
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vSMA10_of_vBollinger20_1 = new MAStudy(10, 0, vBollinger20, BollingerStudy.UPPER, MAStudy.SIMPLE);
var vSMA10_of_vBollinger20_2 = new MAStudy(10, 0, vBollinger20, BollingerStudy.LOWER, MAStudy.SIMPLE);
var vEMA8_of_vBollinger20_1 = new MAStudy(8, 0, vBollinger20, BollingerStudy.UPPER, MAStudy.EXPONENTIAL);
var vEMA8_of_vBollinger20_2 = new MAStudy(8, 0, vBollinger20, BollingerStudy.LOWER, MAStudy.EXPONENTIAL);
var vLastAlert = -1;
function main() {
var vUpper = vBollinger20.getValue(BollingerStudy.UPPER);
var vLower = vBollinger20.getValue(BollingerStudy.LOWER);
var vLast = close();
var vSMA_Upper = vSMA10_of_vBollinger20_1.getValue(MAStudy.MA);
var vSMA_Lower = vSMA10_of_vBollinger20_2.getValue(MAStudy.MA);
var vSMA = vSMA10.getValue(MAStudy.MA);
var vEMA_Upper = vEMA8_of_vBollinger20_1.getValue(MAStudy.MA);
var vEMA_Lower = vEMA8_of_vBollinger20_2.getValue(MAStudy.MA);
var vEMA = vEMA8.getValue(MAStudy.MA);
if(vUpper == null || vLower == null || vLast == null || vSMA_Upper == null || vSMA_Lower == null || vSMA == null || vEMA_Upper == null || vEMA_Lower == null || vEMA == null)
return;
return new Array( (vLast - vLower) / (vUpper - vLower), (vSMA - vSMA_Lower) / (vSMA_Upper - vSMA_Lower), (vEMA - vEMA_Lower) / (vEMA_Upper - vEMA_Lower) );
}
This doesn't seem to be overly complicated and I am an absolute beginner with programming efs, so maybe I am overlooking something really simple? I would appreciate any help.
panta-rhei
I am trying to add some moving averages to the B% formula from the Bollinger Study package, but for some reason I am getting an error message on the second use of 'MAStudy' in the following code:
My Formulas\Percent B Custom.efs, line 41: Error: Failed to call 'MAStudy': parameter # 5 is invalid.
Strangely enough the first use of 'MAStudy' with almost the same paramter set works perfectly fine:
var vSMA10_of_vBollinger20_1 = new MAStudy(10, 0, vBollinger20, BollingerStudy.UPPER, MAStudy.SIMPLE);
Only on the second use I get the error message:
var vSMA10_of_vBollinger20_2 = new MAStudy(10, 0, vBollinger20, BollingerStudy.LOWER, MAStudy.SIMPLE);
Here is the complete efs code:
function preMain() {
setPriceStudy(false);
setStudyTitle("MA of B%");
setCursorLabelName("vB%", 0);
setCursorLabelName("vGD10", 1);
setCursorLabelName("vEMA8", 2);
setDefaultBarFgColor(Color.RGB(0xFE,0x00,0x6D), 0);
setDefaultBarFgColor(Color.RGB(0x00,0x94,0xFF), 1);
setDefaultBarFgColor(Color.RGB(0xFE,0x69,0x00), 2);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
setDefaultBarThickness(1,2);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setPlotType(PLOTTYPE_LINE,2);
}
var vBollinger20 = new BollingerStudy(20, "Close", 20);
var vSMA10 = new MAStudy(10, 0, "Close", MAStudy.SIMPLE);
var vEMA8 = new MAStudy(8, 0, "Close", MAStudy.EXPONENTIAL);
var vSMA10_of_vBollinger20_1 = new MAStudy(10, 0, vBollinger20, BollingerStudy.UPPER, MAStudy.SIMPLE);
var vSMA10_of_vBollinger20_2 = new MAStudy(10, 0, vBollinger20, BollingerStudy.LOWER, MAStudy.SIMPLE);
var vEMA8_of_vBollinger20_1 = new MAStudy(8, 0, vBollinger20, BollingerStudy.UPPER, MAStudy.EXPONENTIAL);
var vEMA8_of_vBollinger20_2 = new MAStudy(8, 0, vBollinger20, BollingerStudy.LOWER, MAStudy.EXPONENTIAL);
var vLastAlert = -1;
function main() {
var vUpper = vBollinger20.getValue(BollingerStudy.UPPER);
var vLower = vBollinger20.getValue(BollingerStudy.LOWER);
var vLast = close();
var vSMA_Upper = vSMA10_of_vBollinger20_1.getValue(MAStudy.MA);
var vSMA_Lower = vSMA10_of_vBollinger20_2.getValue(MAStudy.MA);
var vSMA = vSMA10.getValue(MAStudy.MA);
var vEMA_Upper = vEMA8_of_vBollinger20_1.getValue(MAStudy.MA);
var vEMA_Lower = vEMA8_of_vBollinger20_2.getValue(MAStudy.MA);
var vEMA = vEMA8.getValue(MAStudy.MA);
if(vUpper == null || vLower == null || vLast == null || vSMA_Upper == null || vSMA_Lower == null || vSMA == null || vEMA_Upper == null || vEMA_Lower == null || vEMA == null)
return;
return new Array( (vLast - vLower) / (vUpper - vLower), (vSMA - vSMA_Lower) / (vSMA_Upper - vSMA_Lower), (vEMA - vEMA_Lower) / (vEMA_Upper - vEMA_Lower) );
}
This doesn't seem to be overly complicated and I am an absolute beginner with programming efs, so maybe I am overlooking something really simple? I would appreciate any help.
panta-rhei
Comment