/********************************************************* 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. **********************************************************/ var fpArray = new Array(); function preMain() { setPriceStudy(true); setStudyTitle("Pivot Points"); setCursorLabelName("PP-R2", 0); setCursorLabelName("PP-R1", 1); setCursorLabelName("PP", 2); setCursorLabelName("PP-S1", 3); setCursorLabelName("PP-S2", 4); // R2 setPlotType(PLOTTYPE_FLATLINES,0) setDefaultBarFgColor(Color.RGB(255,0,0), 0); setDefaultBarThickness(2, 0); // R1 setPlotType(PLOTTYPE_FLATLINES,1) setDefaultBarFgColor(Color.RGB(0,0,255), 1); setDefaultBarThickness(1, 1); // Pivot Point setPlotType(PLOTTYPE_FLATLINES,2) setDefaultBarFgColor(Color.RGB(0,0,0), 2); setDefaultBarThickness(1, 2); // S1 setPlotType(PLOTTYPE_FLATLINES,3) setDefaultBarFgColor(Color.RGB(0,0,255), 3); setDefaultBarThickness(1, 3); // S2 setPlotType(PLOTTYPE_FLATLINES,4) setDefaultBarFgColor(Color.RGB(255,0,0), 4); setDefaultBarThickness(2, 4); 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 bInit = false; var vSymbol = null; var vSymbol2 = null; function main(Symbol,Interval,Interval2,Lookback,Type,Params) { 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; 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 == "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