Hi
Somebody could help me with this formula, witch is trader pivot lines, but I would like to see only those pivots from the current day, not all pivot for previous days, take to many place on the chart.
Thank you
Alexis C. Montenegro © 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 April 2008
by Scott Cranmer to include additional pivots e.g. R3, S3
and mid-point pivot levels.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("Pivot Points");
setCursorLabelName("PP-R3", 0);
setCursorLabelName("PP-MidR3", 1);
setCursorLabelName("PP-R2", 2);
setCursorLabelName("PP-MidR2", 3);
setCursorLabelName("PP-R1", 4);
setCursorLabelName("PP-MidR1", 5);
setCursorLabelName("PP", 6);
setCursorLabelName("PP-MidS1", 7);
setCursorLabelName("PP-S1", 8);
setCursorLabelName("PP-MidS2", 9);
setCursorLabelName("PP-S2", 10);
setCursorLabelName("PP-MidS3", 11);
setCursorLabelName("PP-S3", 12);
// R3
setPlotType(PLOTTYPE_FLATLINES,0)
setDefaultBarFgColor(Color.RGB(255,0,0), 0);
setDefaultBarThickness(1, 0);
// Mid R3
setPlotType(PS_DASH,1)
setDefaultBarFgColor(Color.RGB(255,0,0), 1);
setDefaultBarThickness(1, 1);
// R2
setPlotType(PLOTTYPE_FLATLINES,2)
setDefaultBarFgColor(Color.RGB(255,0,0), 2);
setDefaultBarThickness(1, 2);
// Mid R2
setPlotType(PS_DASH,3)
setDefaultBarFgColor(Color.RGB(255,0,0), 3);
setDefaultBarThickness(1, 3);
// R1
setPlotType(PLOTTYPE_FLATLINES,4)
setDefaultBarFgColor(Color.RGB(255,0,0), 4);
setDefaultBarThickness(1, 4);
// Mid R1
setPlotType(PS_DASH,5)
setDefaultBarFgColor(Color.RGB(255,0,0), 5);
setDefaultBarThickness(1, 5);
// Pivot Point
setPlotType(PLOTTYPE_FLATLINES,6)
setDefaultBarFgColor(Color.RGB(30,183,215), 6);
setDefaultBarThickness(1, 6);
// Mid S1
setPlotType(PS_DASH,7)
setDefaultBarFgColor(Color.RGB(0,151,0), 7);
setDefaultBarThickness(1, 7);
// S1
setPlotType(PLOTTYPE_FLATLINES,8)
setDefaultBarFgColor(Color.RGB(0,151,0), 8);
setDefaultBarThickness(1, 8);
// Mid S2
setPlotType(PS_DASH,9)
setDefaultBarFgColor(Color.RGB(0,151,0), 9);
setDefaultBarThickness(1, 9);
// S2
setPlotType(PLOTTYPE_FLATLINES,10)
setDefaultBarFgColor(Color.RGB(0,151,0), 10);
setDefaultBarThickness(1, 10);
// Mid S3
setPlotType(PS_DASH,11)
setDefaultBarFgColor(Color.RGB(0,151,0), 11);
setDefaultBarThickness(1, 11);
// S3
setPlotType(PLOTTYPE_FLATLINES,12)
setDefaultBarFgColor(Color.RGB(0,151,0), 12);
setDefaultBarThickness(1, 12);
var x=0;
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval2", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Optional Close Interval");
setDefault();
}
fpArray[x] = new FunctionParameter("Lookback", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("Type", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Pivot type");
addOption("Standard");
addOption("DeMark");
addOption("Woodie");
setDefault("Standard");
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var xHigh = null;
var xLow = null;
var xClose = null;
var xOpen = null;
var vPP = null;
var vR1 = null;
var vS1 = null;
var vR2 = null;
var vS2 = null;
var vR3 = null;
var vS3 = null;
var bInit = false;
var vSymbol = null;
var vSymbol2 = null;
function main(Symbol,Interval,Interval2,Lookback,Type,Param s) {
if(getBarState()==BARSTATE_ALLBARS) bCurrentDay = false;
if(bInit == false){
if(isIntraday() && Interval == null) Interval = "D";
else if(isDaily() && Interval == null) Interval = "W";
else if(isWeekly() && Interval == null) Interval = "M";
else if(Interval == null) Interval = getInterval();
if(Symbol==null) Symbol = getSymbol();
vSymbol = Symbol+","+Interval;
if(Interval2==null) vSymbol2 = vSymbol;
else vSymbol2 = Symbol+","+Interval2;
xHigh = high(sym(vSymbol));
xLow = low(sym(vSymbol));
xClose = close(sym(vSymbol2));
if (Type=="Woodie"||Type=="DeMark") xOpen = open(sym(vSymbol));
if (Type=="DeMark"){
setCursorLabelName("PP-R1",0);
setCursorLabelName("PP",1);
setCursorLabelName("PP-S1",2);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.red, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(1, 2);
}
setShowTitleParameters(eval(Params));
bInit = true;
}
var vHigh = xHigh.getValue(-Lookback);
var vLow = xLow.getValue(-Lookback);
var vClose = xClose.getValue(-Lookback);
if(Type == "Standard"){
vPP = (vHigh+vLow+vClose)/3;
vMidR1 = (vR1 - vPP)/2 + vPP;
vR1 = 2*vPP-vLow;
vMidS1 = (vS1 - vPP)/2 + vPP;
vS1 = 2*vPP-vHigh;
vMidR2 = (vR2 - vR1)/2 + vR1;
vR2 = (vPP-vS1)+vR1;
vMidS2 = (vS2 - vS1)/2 + vS1
vS2 = vPP-(vR1-vS1);
vMidR3 = (vR3 - vR2)/2 + vR2;
vR3 = (vPP - vS1) + vR2;
vMidS3 = (vS3 - vS2)/2 + vS2
vS3 = vPP - (vR2 - vS1);
var retArray = new Array(vR3, vMidR3, vR2, vMidR2, vR1, vMidR1, vPP, vMidS1, vS1, vMidS2, vS2, vMidS3, vS3);
}else if(Type == "Woodie"){
vOpen = xOpen.getValue(-Lookback+1);
vPP = (vHigh+vLow+(2*vOpen))/4;
vR1 = 2*vPP-vLow;
vS1 = 2*vPP-vHigh;
vR2 = (vPP-vS1)+vR1;
vS2 = vPP-(vR1-vS1);
var retArray = new Array(vR2, vR1, vPP, vS1, vS2);
}else if(Type == "DeMark"){
var vOpen = xOpen.getValue(-Lookback);
if(vClose>vOpen){
x = vClose+vHigh+vHigh+vLow;
}
else if(vClose<vOpen){
x = vClose+vHigh+vLow+vLow;
}
else if(vClose==vOpen){
x = vClose+vClose+vHigh+vLow;
}
vR1 = x/2-vLow;
vS1 = x/2-vHigh;
vPP = (vR1+vS1)/2;
var retArray = new Array (vR1,vPP,vS1);
}
return (retArray);
}
Somebody could help me with this formula, witch is trader pivot lines, but I would like to see only those pivots from the current day, not all pivot for previous days, take to many place on the chart.
Thank you
Alexis C. Montenegro © 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 April 2008
by Scott Cranmer to include additional pivots e.g. R3, S3
and mid-point pivot levels.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(true);
setStudyTitle("Pivot Points");
setCursorLabelName("PP-R3", 0);
setCursorLabelName("PP-MidR3", 1);
setCursorLabelName("PP-R2", 2);
setCursorLabelName("PP-MidR2", 3);
setCursorLabelName("PP-R1", 4);
setCursorLabelName("PP-MidR1", 5);
setCursorLabelName("PP", 6);
setCursorLabelName("PP-MidS1", 7);
setCursorLabelName("PP-S1", 8);
setCursorLabelName("PP-MidS2", 9);
setCursorLabelName("PP-S2", 10);
setCursorLabelName("PP-MidS3", 11);
setCursorLabelName("PP-S3", 12);
// R3
setPlotType(PLOTTYPE_FLATLINES,0)
setDefaultBarFgColor(Color.RGB(255,0,0), 0);
setDefaultBarThickness(1, 0);
// Mid R3
setPlotType(PS_DASH,1)
setDefaultBarFgColor(Color.RGB(255,0,0), 1);
setDefaultBarThickness(1, 1);
// R2
setPlotType(PLOTTYPE_FLATLINES,2)
setDefaultBarFgColor(Color.RGB(255,0,0), 2);
setDefaultBarThickness(1, 2);
// Mid R2
setPlotType(PS_DASH,3)
setDefaultBarFgColor(Color.RGB(255,0,0), 3);
setDefaultBarThickness(1, 3);
// R1
setPlotType(PLOTTYPE_FLATLINES,4)
setDefaultBarFgColor(Color.RGB(255,0,0), 4);
setDefaultBarThickness(1, 4);
// Mid R1
setPlotType(PS_DASH,5)
setDefaultBarFgColor(Color.RGB(255,0,0), 5);
setDefaultBarThickness(1, 5);
// Pivot Point
setPlotType(PLOTTYPE_FLATLINES,6)
setDefaultBarFgColor(Color.RGB(30,183,215), 6);
setDefaultBarThickness(1, 6);
// Mid S1
setPlotType(PS_DASH,7)
setDefaultBarFgColor(Color.RGB(0,151,0), 7);
setDefaultBarThickness(1, 7);
// S1
setPlotType(PLOTTYPE_FLATLINES,8)
setDefaultBarFgColor(Color.RGB(0,151,0), 8);
setDefaultBarThickness(1, 8);
// Mid S2
setPlotType(PS_DASH,9)
setDefaultBarFgColor(Color.RGB(0,151,0), 9);
setDefaultBarThickness(1, 9);
// S2
setPlotType(PLOTTYPE_FLATLINES,10)
setDefaultBarFgColor(Color.RGB(0,151,0), 10);
setDefaultBarThickness(1, 10);
// Mid S3
setPlotType(PS_DASH,11)
setDefaultBarFgColor(Color.RGB(0,151,0), 11);
setDefaultBarThickness(1, 11);
// S3
setPlotType(PLOTTYPE_FLATLINES,12)
setDefaultBarFgColor(Color.RGB(0,151,0), 12);
setDefaultBarThickness(1, 12);
var x=0;
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval2", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Optional Close Interval");
setDefault();
}
fpArray[x] = new FunctionParameter("Lookback", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("Type", FunctionParameter.STRING);
with(fpArray[x++]){
setName("Pivot type");
addOption("Standard");
addOption("DeMark");
addOption("Woodie");
setDefault("Standard");
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var xHigh = null;
var xLow = null;
var xClose = null;
var xOpen = null;
var vPP = null;
var vR1 = null;
var vS1 = null;
var vR2 = null;
var vS2 = null;
var vR3 = null;
var vS3 = null;
var bInit = false;
var vSymbol = null;
var vSymbol2 = null;
function main(Symbol,Interval,Interval2,Lookback,Type,Param s) {
if(getBarState()==BARSTATE_ALLBARS) bCurrentDay = false;
if(bInit == false){
if(isIntraday() && Interval == null) Interval = "D";
else if(isDaily() && Interval == null) Interval = "W";
else if(isWeekly() && Interval == null) Interval = "M";
else if(Interval == null) Interval = getInterval();
if(Symbol==null) Symbol = getSymbol();
vSymbol = Symbol+","+Interval;
if(Interval2==null) vSymbol2 = vSymbol;
else vSymbol2 = Symbol+","+Interval2;
xHigh = high(sym(vSymbol));
xLow = low(sym(vSymbol));
xClose = close(sym(vSymbol2));
if (Type=="Woodie"||Type=="DeMark") xOpen = open(sym(vSymbol));
if (Type=="DeMark"){
setCursorLabelName("PP-R1",0);
setCursorLabelName("PP",1);
setCursorLabelName("PP-S1",2);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.black, 1);
setDefaultBarFgColor(Color.red, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(1, 2);
}
setShowTitleParameters(eval(Params));
bInit = true;
}
var vHigh = xHigh.getValue(-Lookback);
var vLow = xLow.getValue(-Lookback);
var vClose = xClose.getValue(-Lookback);
if(Type == "Standard"){
vPP = (vHigh+vLow+vClose)/3;
vMidR1 = (vR1 - vPP)/2 + vPP;
vR1 = 2*vPP-vLow;
vMidS1 = (vS1 - vPP)/2 + vPP;
vS1 = 2*vPP-vHigh;
vMidR2 = (vR2 - vR1)/2 + vR1;
vR2 = (vPP-vS1)+vR1;
vMidS2 = (vS2 - vS1)/2 + vS1
vS2 = vPP-(vR1-vS1);
vMidR3 = (vR3 - vR2)/2 + vR2;
vR3 = (vPP - vS1) + vR2;
vMidS3 = (vS3 - vS2)/2 + vS2
vS3 = vPP - (vR2 - vS1);
var retArray = new Array(vR3, vMidR3, vR2, vMidR2, vR1, vMidR1, vPP, vMidS1, vS1, vMidS2, vS2, vMidS3, vS3);
}else if(Type == "Woodie"){
vOpen = xOpen.getValue(-Lookback+1);
vPP = (vHigh+vLow+(2*vOpen))/4;
vR1 = 2*vPP-vLow;
vS1 = 2*vPP-vHigh;
vR2 = (vPP-vS1)+vR1;
vS2 = vPP-(vR1-vS1);
var retArray = new Array(vR2, vR1, vPP, vS1, vS2);
}else if(Type == "DeMark"){
var vOpen = xOpen.getValue(-Lookback);
if(vClose>vOpen){
x = vClose+vHigh+vHigh+vLow;
}
else if(vClose<vOpen){
x = vClose+vHigh+vLow+vLow;
}
else if(vClose==vOpen){
x = vClose+vClose+vHigh+vLow;
}
vR1 = x/2-vLow;
vS1 = x/2-vHigh;
vPP = (vR1+vS1)/2;
var retArray = new Array (vR1,vPP,vS1);
}
return (retArray);
}
Comment