Is there a way to edit the enclosed EFS so as when the VPO goes below 0 is changes the background color of the chart and when above 0 it changes the background color to a different color?
Here is the efs:
/************************************************** *******************************************/
/* Volume Price Momentum Oscillator */
/* ver 2.0.0 - Apr 01, 2004 by R.L. Brecko (aka Gavishti) */
/* */
/* NO GUARANTEES. USE AT YOUR OWN RISK. */
/* */
/* Based on the Volume * Price Momentum Oscillator (V*PMO) found on page 774 of The */
/* Encyclopedia of Technical Market Indicators. The original used crossing of zero of the */
/* three day exponential moving average of volume times the current close less the previous */
/* close as a reversal signal. */
/************************************************** *******************************************/
/* REVISIONS: */
/* 2.1.0 - Apr 02, 2004 by R.L. Brecko */
/* - Added price source option. */
/************************************************** *******************************************/
var aVP, aVPMO;
var pctMA;
var i, iType;
var tmp;
function preMain()
{
setShowTitleParameters(false);
setShowCursorLabel(true);
var fp01 = new FunctionParameter("pPeriod", FunctionParameter.NUMBER);
fp01.setLowerLimit(1);
fp01.setUpperLimit(100);
fp01.setDefault(3);
var fp02 = new FunctionParameter("pLookBack", FunctionParameter.NUMBER);
fp02.setLowerLimit(1);
fp02.setUpperLimit(100);
fp02.setDefault(1);
var fp03 = new FunctionParameter("pType", FunctionParameter.STRING);
fp03.addOption("EXPONENTIAL");
fp03.addOption("SIMPLE");
fp03.addOption("WEIGHTED");
fp03.setDefault("EXPONENTIAL");
var fp04 = new FunctionParameter("pSrc", FunctionParameter.STRING);
fp04.addOption("O");
fp04.addOption("H");
fp04.addOption("L");
fp04.addOption("C");
fp04.addOption("HL/2");
fp04.addOption("HLC/3");
fp04.addOption("OHLC/4");
fp04.setDefault("C");
var fp80 = new FunctionParameter("pThkHist", FunctionParameter.NUMBER);
fp80.setLowerLimit(1);
fp80.setUpperLimit(15);
fp80.setDefault(5);
var fp90 = new FunctionParameter("pClrBull", FunctionParameter.COLOR);
fp90.setDefault(Color.RGB(0,144,0)); // green
var fp91 = new FunctionParameter("pClrBear", FunctionParameter.COLOR);
fp91.setDefault(Color.RGB(233,0,0)); // red
var fp92 = new FunctionParameter("pClrNeut", FunctionParameter.COLOR);
fp92.setDefault(Color.RGB(153,204,255)); // pale blue
}
function main(pPeriod, pLookBack, pType, pSrc, pThkHist, pClrBull, pClrBear, pClrNeut)
{
if(getBarState() == 2)
{
setStudyTitle("VPMO(" + pPeriod + "," + pLookBack + "," + pType.substr(0,1) +
"," + pSrc + ") v2.1.0");
setCursorLabelName("VPO", 0);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setDefaultBarThickness(pThkHist, 0);
aVP = new Array(pPeriod+pLookBack);
aVPMO = new Array(pPeriod+pLookBack);
iType = pType == "EXPONENTIAL" ? 1 : pType = "SIMPLE" ? 2 : 3;
tmp = volume();
for (i = 0; i < (pPeriod+pLookBack); i++)
{
aVP[i] = tmp;
aVPMO[i] = tmp;
}
pctMA = (2.0 / (pPeriod + 1.0));
return;
}
if(getBarState() == 0)
{
aVP.pop();
aVP.unshift(0.0);
aVPMO.pop();
aVPMO.unshift(0.0);
}
switch (pSrc)
{
case "O":
aVP[0] = volume() * (open() - open(-pLookBack));
break;
case "H":
aVP[0] = volume() * (high() - high(-pLookBack));
break;
case "L":
aVP[0] = volume() * (low() - low(-pLookBack));
break;
case "C":
aVP[0] = volume() * (close() - close(-pLookBack));
break;
case "HL/2":
aVP[0] = volume() * ((high() - high(-pLookBack) + low() - low(-pLookBack)) / 2);
break;
case "HLC/3":
aVP[0] = volume() * ((high() - high(-pLookBack) + low() - low(-pLookBack) +
close() - close(-pLookBack) ) / 3);
break;
case "OHLC/4":
aVP[0] = volume() *
(( open() - open(-pLookBack) + high() - high(-pLookBack) +
low() - low(-pLookBack) + close() - close(-pLookBack) ) / 4);
}
switch (iType)
{
case 1:
aVPMO[0] = (aVP[0] - aVPMO[1]) * pctMA + aVPMO[1];
break;
case 2:
tmp = 0;
for (i = 0; i < pPeriod; i++) tmp += aVP[i];
aVPMO[0] = tmp / pPeriod;
break;
case 3:
tmp = 0;
for (i = 0; i < pPeriod; i++) tmp += (pPeriod - i) * aVP[i];
aVPMO[0] = tmp / pPeriod;
}
if(aVPMO[0] > 0) setBarFgColor(pClrBull, 0);
else if(aVPMO[0] < 0) setBarFgColor(pClrBear, 0);
else setBarFgColor(pClrNeut, 0);
return aVPMO[0];
}
Thanks for your time...Greg
Here is the efs:
/************************************************** *******************************************/
/* Volume Price Momentum Oscillator */
/* ver 2.0.0 - Apr 01, 2004 by R.L. Brecko (aka Gavishti) */
/* */
/* NO GUARANTEES. USE AT YOUR OWN RISK. */
/* */
/* Based on the Volume * Price Momentum Oscillator (V*PMO) found on page 774 of The */
/* Encyclopedia of Technical Market Indicators. The original used crossing of zero of the */
/* three day exponential moving average of volume times the current close less the previous */
/* close as a reversal signal. */
/************************************************** *******************************************/
/* REVISIONS: */
/* 2.1.0 - Apr 02, 2004 by R.L. Brecko */
/* - Added price source option. */
/************************************************** *******************************************/
var aVP, aVPMO;
var pctMA;
var i, iType;
var tmp;
function preMain()
{
setShowTitleParameters(false);
setShowCursorLabel(true);
var fp01 = new FunctionParameter("pPeriod", FunctionParameter.NUMBER);
fp01.setLowerLimit(1);
fp01.setUpperLimit(100);
fp01.setDefault(3);
var fp02 = new FunctionParameter("pLookBack", FunctionParameter.NUMBER);
fp02.setLowerLimit(1);
fp02.setUpperLimit(100);
fp02.setDefault(1);
var fp03 = new FunctionParameter("pType", FunctionParameter.STRING);
fp03.addOption("EXPONENTIAL");
fp03.addOption("SIMPLE");
fp03.addOption("WEIGHTED");
fp03.setDefault("EXPONENTIAL");
var fp04 = new FunctionParameter("pSrc", FunctionParameter.STRING);
fp04.addOption("O");
fp04.addOption("H");
fp04.addOption("L");
fp04.addOption("C");
fp04.addOption("HL/2");
fp04.addOption("HLC/3");
fp04.addOption("OHLC/4");
fp04.setDefault("C");
var fp80 = new FunctionParameter("pThkHist", FunctionParameter.NUMBER);
fp80.setLowerLimit(1);
fp80.setUpperLimit(15);
fp80.setDefault(5);
var fp90 = new FunctionParameter("pClrBull", FunctionParameter.COLOR);
fp90.setDefault(Color.RGB(0,144,0)); // green
var fp91 = new FunctionParameter("pClrBear", FunctionParameter.COLOR);
fp91.setDefault(Color.RGB(233,0,0)); // red
var fp92 = new FunctionParameter("pClrNeut", FunctionParameter.COLOR);
fp92.setDefault(Color.RGB(153,204,255)); // pale blue
}
function main(pPeriod, pLookBack, pType, pSrc, pThkHist, pClrBull, pClrBear, pClrNeut)
{
if(getBarState() == 2)
{
setStudyTitle("VPMO(" + pPeriod + "," + pLookBack + "," + pType.substr(0,1) +
"," + pSrc + ") v2.1.0");
setCursorLabelName("VPO", 0);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setDefaultBarThickness(pThkHist, 0);
aVP = new Array(pPeriod+pLookBack);
aVPMO = new Array(pPeriod+pLookBack);
iType = pType == "EXPONENTIAL" ? 1 : pType = "SIMPLE" ? 2 : 3;
tmp = volume();
for (i = 0; i < (pPeriod+pLookBack); i++)
{
aVP[i] = tmp;
aVPMO[i] = tmp;
}
pctMA = (2.0 / (pPeriod + 1.0));
return;
}
if(getBarState() == 0)
{
aVP.pop();
aVP.unshift(0.0);
aVPMO.pop();
aVPMO.unshift(0.0);
}
switch (pSrc)
{
case "O":
aVP[0] = volume() * (open() - open(-pLookBack));
break;
case "H":
aVP[0] = volume() * (high() - high(-pLookBack));
break;
case "L":
aVP[0] = volume() * (low() - low(-pLookBack));
break;
case "C":
aVP[0] = volume() * (close() - close(-pLookBack));
break;
case "HL/2":
aVP[0] = volume() * ((high() - high(-pLookBack) + low() - low(-pLookBack)) / 2);
break;
case "HLC/3":
aVP[0] = volume() * ((high() - high(-pLookBack) + low() - low(-pLookBack) +
close() - close(-pLookBack) ) / 3);
break;
case "OHLC/4":
aVP[0] = volume() *
(( open() - open(-pLookBack) + high() - high(-pLookBack) +
low() - low(-pLookBack) + close() - close(-pLookBack) ) / 4);
}
switch (iType)
{
case 1:
aVPMO[0] = (aVP[0] - aVPMO[1]) * pctMA + aVPMO[1];
break;
case 2:
tmp = 0;
for (i = 0; i < pPeriod; i++) tmp += aVP[i];
aVPMO[0] = tmp / pPeriod;
break;
case 3:
tmp = 0;
for (i = 0; i < pPeriod; i++) tmp += (pPeriod - i) * aVP[i];
aVPMO[0] = tmp / pPeriod;
}
if(aVPMO[0] > 0) setBarFgColor(pClrBull, 0);
else if(aVPMO[0] < 0) setBarFgColor(pClrBear, 0);
else setBarFgColor(pClrNeut, 0);
return aVPMO[0];
}
Thanks for your time...Greg
Comment