I would like a volume sub chart that has 1) a dashed blue line showing 5 minute (200 period) average volume and 2) a dashed Green line showing 30 minute (200 period) average volume. I would like both lines to automatically appear on every chart, regardless of the chart time frame. i.e. regardless of whether I look at a 1 minute chart or a 60 minute chart, I would see both the blue and green lines that show what average 5 and 30 minute volume is for that stock.
Someone tried to help me with this previously, but I think they created the 2 lines showing 5 period and 30 period 200 minute volume. I know absolutely nothing about writing code. If anyone could take a look at this I would greatly appreciate it!
Thanks,
Tom
Here is the code:
var fpArray = new Array();
function preMain(){
setStudyTitle("Duel Volume MA");
askForInput("Duel Volume MA");
setCursorLabelName("200p MA Volume", 0);
setCursorLabelName("MA1 - 5p MA of 200", 1);
setCursorLabelName("MA2 - 30p MA of 200", 2);
setStudyMin(0);
var x=0;
fpArray[x] = new FunctionParameter("nLength1", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("sStudy");
setDefault(200);
setPlotType(PLOTTYPE_LINE);
setDefaultBarFgColor(Color.white,0);
}
fpArray[x] = new FunctionParameter("nLength2", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("MA 1")
setDefault(5);
setDefaultBarFgColor(Color.green,1);
setDefaultBarThickness(4,1);
setPlotType(PLOTTYPE_CIRCLE, 1)
}
fpArray[x] = new FunctionParameter("nLength3", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("MA 2")
setDefault(30);
setDefaultBarFgColor(Color.blue,2);
setDefaultBarThickness(2,2);
setPlotType(PLOTTYPE_FLATLINES,2);
}
}
function main(nLength1,nLength2,nLength3){
var vVol = volume();
var nMA1 = null;
var nMA2 = null;
var nStudy = null;
var bInit = false;
if(bInit == false){
//vVol = volume();
nStudy = sma(nLength1,(vVol));
nMA1 = sma(nLength2,(nStudy));
nMA2 = sma(nLength3,(nStudy));
bInit = true;
}
var nVol1 = vVol.getValue(-1);
/* if(vVol > nVol1){
setBarFgColor(Color.green)
setPlotType(PLOTTYPE_HISTOGRAM);
}
else{
setBarFgColor(Color.red);
setPlotType(PLOTTYPE_HISTOGRAM);
}*/
return Array(nStudy,nMA1, nMA2);
}
Someone tried to help me with this previously, but I think they created the 2 lines showing 5 period and 30 period 200 minute volume. I know absolutely nothing about writing code. If anyone could take a look at this I would greatly appreciate it!
Thanks,
Tom
Here is the code:
var fpArray = new Array();
function preMain(){
setStudyTitle("Duel Volume MA");
askForInput("Duel Volume MA");
setCursorLabelName("200p MA Volume", 0);
setCursorLabelName("MA1 - 5p MA of 200", 1);
setCursorLabelName("MA2 - 30p MA of 200", 2);
setStudyMin(0);
var x=0;
fpArray[x] = new FunctionParameter("nLength1", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("sStudy");
setDefault(200);
setPlotType(PLOTTYPE_LINE);
setDefaultBarFgColor(Color.white,0);
}
fpArray[x] = new FunctionParameter("nLength2", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("MA 1")
setDefault(5);
setDefaultBarFgColor(Color.green,1);
setDefaultBarThickness(4,1);
setPlotType(PLOTTYPE_CIRCLE, 1)
}
fpArray[x] = new FunctionParameter("nLength3", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("MA 2")
setDefault(30);
setDefaultBarFgColor(Color.blue,2);
setDefaultBarThickness(2,2);
setPlotType(PLOTTYPE_FLATLINES,2);
}
}
function main(nLength1,nLength2,nLength3){
var vVol = volume();
var nMA1 = null;
var nMA2 = null;
var nStudy = null;
var bInit = false;
if(bInit == false){
//vVol = volume();
nStudy = sma(nLength1,(vVol));
nMA1 = sma(nLength2,(nStudy));
nMA2 = sma(nLength3,(nStudy));
bInit = true;
}
var nVol1 = vVol.getValue(-1);
/* if(vVol > nVol1){
setBarFgColor(Color.green)
setPlotType(PLOTTYPE_HISTOGRAM);
}
else{
setBarFgColor(Color.red);
setPlotType(PLOTTYPE_HISTOGRAM);
}*/
return Array(nStudy,nMA1, nMA2);
}