Could anyone be so kind and suggest a workaround on the realtime update issue inherent in this script with intraday timeframes (in other words, "setComputeOnClose(false)"). The script can be evaluated with just an SMA if needed... Many thanks!
/*---FVE Indicator smoothed with JurikJMA---*/
var vJC = null;
var vJH = null;
var vJL = null;
function preMain(){
setPriceStudy(false);
setStudyTitle("Finite Volume Elements JMA");
setCursorLabelName("FVI",0);
setDefaultBarThickness(2,0);
setPlotType(PLOTTYPE_HISTOGRAM,0);
addBand(0, PS_SOLID, 1, Color.grey, "Zero");
setShowTitleParameters( false );
setComputeOnClose(true);
var fp1 = new FunctionParameter("Period", FunctionParameter.NUMBER);
fp1.setName("Period");
fp1.setLowerLimit(2);
fp1.setDefault(20);
var fp2 = new FunctionParameter("J1L", FunctionParameter.NUMBER);
fp2.setName("JMA Length");
fp2.setLowerLimit(2);
fp2.setDefault(8);
var fp3 = new FunctionParameter("J1P", FunctionParameter.NUMBER);
fp3.setName("JMA Phase");
fp3.setLowerLimit(-100);
fp3.setUpperLimit(100);
fp3.setDefault(50);
var fp4 = new FunctionParameter("Factor", FunctionParameter.NUMBER);
fp4.setName("% Value");
fp4.setLowerLimit(-10);
fp4.setUpperLimit(10);
fp4.setDefault(0.1);
}
VolumePlusMinusArray = new Array();
function main(Period, J1L, J1P, Factor){
var MF = 0, FveFactor = 0, VolSum = 0, VolumePlusMinus = 0, FVE = 0, Fvesum=0;
if (vJC == null) vJC = new JurikJMAStudy(J1L, J1P, 0, "Close");
if (vJH == null) vJH = new JurikJMAStudy(J1L, J1P, 0, "High");
if (vJL == null) vJL = new JurikJMAStudy(J1L, J1P, 0, "Low");
MF = (vJC.getValue(JurikJMAStudy.JMA,0) - (vJH.getValue(JurikJMAStudy.JMA,0) + vJL.getValue(JurikJMAStudy.JMA,0)) / 2 + ((vJH.getValue(JurikJMAStudy.JMA,0) + vJL.getValue(JurikJMAStudy.JMA,0) + vJC.getValue(JurikJMAStudy.JMA,0)) / 3) - ((vJH.getValue(JurikJMAStudy.JMA,-1) + vJL.getValue(JurikJMAStudy.JMA,-1) + vJC.getValue(JurikJMAStudy.JMA,-1)) / 3));
if(MF > Factor * vJC.getValue(JurikJMAStudy.JMA, 0)/10000){
FveFactor = 1;
setDefaultBarFgColor(Color.green,0);
setDefaultBarFgColor(Color.green,1);
setPriceBarColor(Color.green);
}
else if(MF < -Factor * vJC.getValue(JurikJMAStudy.JMA, 0)/10000){
FveFactor = - 1;
setDefaultBarFgColor(Color.red,0);
setDefaultBarFgColor(Color.red,1);
setPriceBarColor(Color.red);
}
else {
FveFactor = 0;
setDefaultBarFgColor(Color.yellow,0);
setPriceBarColor(Color.yellow);
}
VolumePlusMinus = (volume() * FveFactor);
for(i = Period - 1; i > 0; i--)
VolumePlusMinusArray[i] = (VolumePlusMinusArray[i - 1]);
VolumePlusMinusArray[0] = (VolumePlusMinus);
for(i = 0; i < Period; i++){
Fvesum += (VolumePlusMinusArray[i]);
VolSum += (volume(-i));
}
if(VolumePlusMinusArray[Period - 1] != null){
FVE = ((Fvesum / VolSum) * 100);
}
return new Array (FVE, FVE);
}
/*---FVE Indicator smoothed with JurikJMA---*/
var vJC = null;
var vJH = null;
var vJL = null;
function preMain(){
setPriceStudy(false);
setStudyTitle("Finite Volume Elements JMA");
setCursorLabelName("FVI",0);
setDefaultBarThickness(2,0);
setPlotType(PLOTTYPE_HISTOGRAM,0);
addBand(0, PS_SOLID, 1, Color.grey, "Zero");
setShowTitleParameters( false );
setComputeOnClose(true);
var fp1 = new FunctionParameter("Period", FunctionParameter.NUMBER);
fp1.setName("Period");
fp1.setLowerLimit(2);
fp1.setDefault(20);
var fp2 = new FunctionParameter("J1L", FunctionParameter.NUMBER);
fp2.setName("JMA Length");
fp2.setLowerLimit(2);
fp2.setDefault(8);
var fp3 = new FunctionParameter("J1P", FunctionParameter.NUMBER);
fp3.setName("JMA Phase");
fp3.setLowerLimit(-100);
fp3.setUpperLimit(100);
fp3.setDefault(50);
var fp4 = new FunctionParameter("Factor", FunctionParameter.NUMBER);
fp4.setName("% Value");
fp4.setLowerLimit(-10);
fp4.setUpperLimit(10);
fp4.setDefault(0.1);
}
VolumePlusMinusArray = new Array();
function main(Period, J1L, J1P, Factor){
var MF = 0, FveFactor = 0, VolSum = 0, VolumePlusMinus = 0, FVE = 0, Fvesum=0;
if (vJC == null) vJC = new JurikJMAStudy(J1L, J1P, 0, "Close");
if (vJH == null) vJH = new JurikJMAStudy(J1L, J1P, 0, "High");
if (vJL == null) vJL = new JurikJMAStudy(J1L, J1P, 0, "Low");
MF = (vJC.getValue(JurikJMAStudy.JMA,0) - (vJH.getValue(JurikJMAStudy.JMA,0) + vJL.getValue(JurikJMAStudy.JMA,0)) / 2 + ((vJH.getValue(JurikJMAStudy.JMA,0) + vJL.getValue(JurikJMAStudy.JMA,0) + vJC.getValue(JurikJMAStudy.JMA,0)) / 3) - ((vJH.getValue(JurikJMAStudy.JMA,-1) + vJL.getValue(JurikJMAStudy.JMA,-1) + vJC.getValue(JurikJMAStudy.JMA,-1)) / 3));
if(MF > Factor * vJC.getValue(JurikJMAStudy.JMA, 0)/10000){
FveFactor = 1;
setDefaultBarFgColor(Color.green,0);
setDefaultBarFgColor(Color.green,1);
setPriceBarColor(Color.green);
}
else if(MF < -Factor * vJC.getValue(JurikJMAStudy.JMA, 0)/10000){
FveFactor = - 1;
setDefaultBarFgColor(Color.red,0);
setDefaultBarFgColor(Color.red,1);
setPriceBarColor(Color.red);
}
else {
FveFactor = 0;
setDefaultBarFgColor(Color.yellow,0);
setPriceBarColor(Color.yellow);
}
VolumePlusMinus = (volume() * FveFactor);
for(i = Period - 1; i > 0; i--)
VolumePlusMinusArray[i] = (VolumePlusMinusArray[i - 1]);
VolumePlusMinusArray[0] = (VolumePlusMinus);
for(i = 0; i < Period; i++){
Fvesum += (VolumePlusMinusArray[i]);
VolSum += (volume(-i));
}
if(VolumePlusMinusArray[Period - 1] != null){
FVE = ((Fvesum / VolSum) * 100);
}
return new Array (FVE, FVE);
}