I built this simple study below that is supposed to accept three input paramaters (nAvg1, nAvg2, nAvg3) when I edit the study. The three paramaters don't show up in the edit studies window. I know this has to be simple but so far I can't make it work.
//{High Jump Description
// This formula returns a plot of the percent intraday high prices are above three user selectable moving average periods.
// This formula was generated by Mike Scott
//
//
function preMain() {
setPriceStudy(false);
setStudyTitle("Hi Jump Daily (High)");
setCursorLabelName("Hi Jump 3", 0);
setCursorLabelName("Hi Jump 2", 1);
setCursorLabelName("Hi Jump 1", 2);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.green, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(2, 2);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
var fp1 = new FunctionParameter("nAvg1", FunctionParameter.NUMBER);
fp1.setName("First Moving Average");
fp1.setLowerLimit(1);
fp1.setDefault(200);
var fp2 = new FunctionParameter("nAvg2", FunctionParameter.NUMBER);
fp2.setName("Second Moving Average");
fp2.setLowerLimit(1);
fp2.setDefault(50);
var fp3 = new FunctionParameter("nAvg3", FunctionParameter.NUMBER);
fp3.setName("Third Moving Average");
fp3.setLowerLimit(1);
fp3.setDefault(10);
}
function main(nAvg1, nAvg2, nAvg3) {
var vHigh = high();
if(vHigh == null)
return;
var n_Avg3_Percent = 100 * (vHigh/sma(nAvg3) - 1);
var n_Avg2_Percent = 100 * (vHigh/sma(nAvg2) - 1);
var n_Avg1_Percent = 100 * (vHigh/sma(nAvg1) - 1);
if(n_Avg3_Percent >= 85) setBarBgColor(Color.olive);
addLineTool( LineTool.HORZ, 100, 1, Color.blue, "null");
return new Array(n_Avg1_Percent, n_Avg2_Percent, n_Avg3_Percent);
}
//{High Jump Description
// This formula returns a plot of the percent intraday high prices are above three user selectable moving average periods.
// This formula was generated by Mike Scott
//
//
function preMain() {
setPriceStudy(false);
setStudyTitle("Hi Jump Daily (High)");
setCursorLabelName("Hi Jump 3", 0);
setCursorLabelName("Hi Jump 2", 1);
setCursorLabelName("Hi Jump 1", 2);
setDefaultBarStyle(PS_SOLID, 0);
setDefaultBarStyle(PS_SOLID, 1);
setDefaultBarStyle(PS_SOLID, 2);
setDefaultBarFgColor(Color.black, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.green, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(2, 2);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
var fp1 = new FunctionParameter("nAvg1", FunctionParameter.NUMBER);
fp1.setName("First Moving Average");
fp1.setLowerLimit(1);
fp1.setDefault(200);
var fp2 = new FunctionParameter("nAvg2", FunctionParameter.NUMBER);
fp2.setName("Second Moving Average");
fp2.setLowerLimit(1);
fp2.setDefault(50);
var fp3 = new FunctionParameter("nAvg3", FunctionParameter.NUMBER);
fp3.setName("Third Moving Average");
fp3.setLowerLimit(1);
fp3.setDefault(10);
}
function main(nAvg1, nAvg2, nAvg3) {
var vHigh = high();
if(vHigh == null)
return;
var n_Avg3_Percent = 100 * (vHigh/sma(nAvg3) - 1);
var n_Avg2_Percent = 100 * (vHigh/sma(nAvg2) - 1);
var n_Avg1_Percent = 100 * (vHigh/sma(nAvg1) - 1);
if(n_Avg3_Percent >= 85) setBarBgColor(Color.olive);
addLineTool( LineTool.HORZ, 100, 1, Color.blue, "null");
return new Array(n_Avg1_Percent, n_Avg2_Percent, n_Avg3_Percent);
}
Comment