I need some help. Anyone know how to create a moving average within an RSI study?
Any assistance is greatly appreciated.
Any assistance is greatly appreciated.
/*********************************************************
By Alexis C. Montenegro for eSignal © December 2004
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
**********************************************************/
function preMain() {
setPriceStudy(false);
setStudyTitle("RSI");
setCursorLabelName("RSI", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(1,0);
setStudyMin(0);
setStudyMax(100);
addBand(70,PS_SOLID,1,Color.black,"Upper");
addBand(30,PS_SOLID,1,Color.black,"Lower");
}
function main() {
return rsi(14);
}
/*********************************************************
By Alexis C. Montenegro for eSignal © December 2004
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
**********************************************************/
// modified to take a 6 period SMA of a 12 period RSI 11/29/2006
function preMain() {
setPriceStudy(false);
setStudyTitle("SMA of RSI");
setCursorLabelName("RSI", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(1,0);
setCursorLabelName("SMA of RSI", 1);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,1);
setStudyMin(0);
setStudyMax(100);
addBand(70,PS_SOLID,1,Color.black,"Upper");
addBand(30,PS_SOLID,1,Color.black,"Lower");
}
function main() {
return new Array(rsi(12),sma(6, rsi(12)));
}
function preMain() {
setPriceStudy(false);
setStudyTitle("RSI w. Signal");
setCursorLabelName("RSI", 0);
setDefaultBarFgColor(Color.navy, 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(1,0);
setCursorLabelName("Signal", 1);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,1);
//setStudyMin(0);
//setStudyMax(100);
setComputeOnClose();
addBand(70,PS_SOLID,1,Color.grey,"Upper");
addBand(30,PS_SOLID,1,Color.grey,"Lower");
var fp1 = new FunctionParameter("nRSI", FunctionParameter.NUMBER);
fp1.setName("RSI length");
fp1.setLowerLimit(1);
fp1.setDefault(13);
var fp2 = new FunctionParameter("Source", FunctionParameter.STRING);
fp2.setName("RSISource");
fp2.addOption("Close");
fp2.addOption("High");
fp2.addOption("Low");
fp2.addOption("Open");
fp2.addOption("HL/2");
fp2.addOption("HLC/3");
fp2.addOption("OHLC/4");
fp2.setDefault("HLC/3");
var fp3 = new FunctionParameter("nMA", FunctionParameter.NUMBER);
fp3.setName("Signal length");
fp3.setLowerLimit(1);
fp3.setDefault(8);
}
function main(nRSI, Source, nMA) {
return new Array(rsi(nRSI, Source), sma((nMA), rsi(nRSI, Source)));
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("RSI with Signal");
setCursorLabelName("RSI", 0);
setDefaultBarFgColor(Color.navy, 0);
setPlotType(PLOTTYPE_LINE,0);
setDefaultBarThickness(1,0);
setCursorLabelName("Signal", 1);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,1);
//setStudyMin(0);
//setStudyMax(100);
setComputeOnClose();
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("nLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("RSI")
setLowerLimit(1);
setDefault(13);
}
fpArray[x] = new FunctionParameter("nSignal", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Signal")
setLowerLimit(1);
setDefault(8);
}
fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Source")
addOption("open");
addOption("high");
addOption("low");
addOption("close");
addOption("hl2");
addOption("hlc3");
addOption("ohlc4");
setDefault("close");
}
/**fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Symbol");
setDefault();
}**/
/**fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Interval");
setDefault();
}**/
fpArray[x] = new FunctionParameter("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Upper")
setDefault(70);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Lower")
setDefault(30);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xRSI = null;
function main(nLength, Source, nSignal, Upper, Lower, Params) {
if(bInit == false){
//if(Symbol == null) Symbol = getSymbol();
//if(Interval == null) Interval = getInterval();
//var vSymbol = Symbol+","+Interval;
xRSI = rsi(nLength);
addBand(Upper,PS_SOLID,1,Color.grey,"Upper");
addBand(Lower,PS_SOLID,1,Color.grey,"Lower");
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array(getSeries(xRSI), sma(nSignal, getSeries(xRSI)));
}
Comment