/**************************************************************************************************** Copyright © eSignal, a division of Interactive Data Corporation. 2002. All rights reserved. This sample eSignal Formula Script (EFS) may be modified and saved under a new filename; however, eSignal is no longer responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. ******************************************************************************************************/ function preMain() { setPriceStudy(true); setStudyTitle("Pivot Points"); setCursorLabelName("R3", 0); setCursorLabelName("R2", 1); setCursorLabelName("R1", 2); setCursorLabelName("PIVOT", 3); setCursorLabelName("S1", 4); setCursorLabelName("S2", 5); setCursorLabelName("S3", 6); setCursorLabelName("TR(D-1)", 7); // R3 setDefaultBarStyle(PS_SOLID, 0); setDefaultBarFgColor(Color.fushcia, 0); setDefaultBarThickness(4, 0); // R2 setDefaultBarStyle(PS_DASHDOT, 1); setDefaultBarFgColor(Color.fushcia, 1); setDefaultBarThickness(3, 1); // R1 setDefaultBarStyle(PS_DOT, 2); setDefaultBarFgColor(Color.fushcia, 2); setDefaultBarThickness(3, 2); // PIVOT setDefaultBarStyle(PS_SOLID, 3); setDefaultBarFgColor(Color.fushcia, 3); setDefaultBarThickness(5, 3); // S1 setDefaultBarStyle(PS_DOT, 4); setDefaultBarFgColor(Color.fushcia, 4); setDefaultBarThickness(3, 4); // S2 setDefaultBarStyle(PS_DASHDOT, 5); setDefaultBarFgColor(Color.fushcia, 5); setDefaultBarThickness(3, 5); // S3 setDefaultBarStyle(PS_SOLID, 6); setDefaultBarFgColor(Color.fushcia, 6); setDefaultBarThickness(4, 6); // setComputeOnClose(); // to speed up things further, can be removed } // Start of Performance addition var vLastRawTime = null; var vLastPPR3 = null; var vLastPPR2 = null; var vLastPPR1 = null; var vLastPP = null; var vLastPPS1 = null; var vLastPPS2 = null; var vLastPPS3 = null; var vLastTR = null; var vLastArray = null; var vSymbol = null; var vInterval = null; function main() { var vH; var vL; var vC; var vRawTime; var vBarTime; var vAbsTime; var vIndex; var nState = getBarState(); if(nState == BARSTATE_ALLBARS) { vLastRawTime = null; vLastArray = null; vLastPPR3 = null; vLastPPR2 = null; vLastPPR1 = null; vLastPP = null; vLastPPS1 = null; vLastPPS2 = null; vLastPPS3 = null; vLastTR = null; vInterval = getInterval(); vSymbol = getSymbol(); vSymbol += ",D"; } vRawTime = getValue("rawtime"); if(vRawTime == null) return; vRawTime = Math.floor(vRawTime / RawTime.DAY); // Start of Performance addition if(vRawTime != null && vLastRawTime != null) { if(vRawTime == vLastRawTime) { return vLastArray; // return new Array(vLastPPR3, vLastPPR2, vLastPPR1, vLastPP, vLastPPS1, vLastPPS2, VLastPPS3, vLastTR); } } if(vInterval == null) return null; if(vInterval == "D") return null; vBarTime = getValue("time"); if(vBarTime != null) { vAbsTime = getPreviousTradingDay(vBarTime, vSymbol); if(vAbsTime == null) return; vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol); if(vIndex != null) { vH = getValueAbsolute("High", vIndex, vSymbol); vL = getValueAbsolute("Low", vIndex, vSymbol); vC = getValueAbsolute("Close", vIndex, vSymbol); if(vH != null && vL != null && vC != null) { vLastPP = (vH + vL + vC) / 3; vLastPPR1 = 2 * vLastPP - vL; vLastPPS1 = 2 * vLastPP - vH; vLastPPR2 = (vLastPP - vLastPPS1) + vLastPPR1; vLastPPS2 = vLastPP - (vLastPPR1 - vLastPPS1); vLastPPR3 = vLastPPR2 + (vH-vL); vLastPPS3 = vLastPPS2 - (vH-vL); vLastTR = (vH-vL); vLastRawTime = vRawTime; vLastArray = new Array(vLastPPR3, vLastPPR2, vLastPPR1, vLastPP, vLastPPS1, vLastPPS2, vLastPPS3, vLastTR); return vLastArray; } } } return null; }