Can anyone apply this to a chart and successfully edit the values? I can't. For some reason the changes I make won't take. It is a MApricebars efs with adjustable parameters.
function preMain() {
setPriceStudy(true);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
var fp1 = new FunctionParameter("sPriceSource", FunctionParameter.STRING);
fp1.setName("Price Source");
fp1.addOption("Open");
fp1.addOption("High");
fp1.addOption("Low");
fp1.addOption("Close");
fp1.addOption("HL/2");
fp1.addOption("HLC/3");
fp1.addOption("OHLC/4");
fp1.setDefault("Close");
var fp2 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
fp2.setName("Periods");
fp2.setLowerLimit(1);
fp2.setDefault(5);
}
var Price = null;
function main(sPriceSource, nPeriods) {
if (Price == null) Price = sPriceSource;
nPeriods = 20;
var vValue = call("/library/ma.efs", nPeriods);
var vClose = close();
if(vValue == null || vClose == null)
return;
if(vValue >= vClose) {
setPriceBarColor(Color.red);
} else if(vValue < vClose) {
setPriceBarColor(Color.green);
}
return (vValue);
}
function getPrice() {
if (Price != "HL/2" && Price != "HLC/3" && Price != "OHLC/4") {
return getValue(Price, 0);
} else {
var o = open();
var h = high();
var l = low();
var c = close();
if (Price == "HL/2") return ((h+l)/2);
if (Price == "HLC/3") return ((h+l+c)/3);
if (Price == "OHLC/4") return ((o+h+l+c)/4);
}
return null;
}
function preMain() {
setPriceStudy(true);
setColorPriceBars(true);
setDefaultPriceBarColor(Color.black);
var fp1 = new FunctionParameter("sPriceSource", FunctionParameter.STRING);
fp1.setName("Price Source");
fp1.addOption("Open");
fp1.addOption("High");
fp1.addOption("Low");
fp1.addOption("Close");
fp1.addOption("HL/2");
fp1.addOption("HLC/3");
fp1.addOption("OHLC/4");
fp1.setDefault("Close");
var fp2 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
fp2.setName("Periods");
fp2.setLowerLimit(1);
fp2.setDefault(5);
}
var Price = null;
function main(sPriceSource, nPeriods) {
if (Price == null) Price = sPriceSource;
nPeriods = 20;
var vValue = call("/library/ma.efs", nPeriods);
var vClose = close();
if(vValue == null || vClose == null)
return;
if(vValue >= vClose) {
setPriceBarColor(Color.red);
} else if(vValue < vClose) {
setPriceBarColor(Color.green);
}
return (vValue);
}
function getPrice() {
if (Price != "HL/2" && Price != "HLC/3" && Price != "OHLC/4") {
return getValue(Price, 0);
} else {
var o = open();
var h = high();
var l = low();
var c = close();
if (Price == "HL/2") return ((h+l)/2);
if (Price == "HLC/3") return ((h+l+c)/3);
if (Price == "OHLC/4") return ((o+h+l+c)/4);
}
return null;
}
Comment