I would like to create a new efs formula that is a variation on the existing formula "PreviousDayDailyBars" to plot the OHLC of the day before yesterday (instead of yesterday).
I would be grateful if someone could tell me what I need to change to get this to work. Thanks in advance.
The exisiting code is:
/************************************************** **************************************************
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("PreviousDayDailyBars");
setCursorLabelName("PD-O", 0); // Open
setCursorLabelName("PD-H", 1); // High
setCursorLabelName("PD-L", 2); // Low
setCursorLabelName("PD-C", 3); // Close
/*
* Set the properties of the default bar. These will be the
* properties of any bar for which style, color, thickness is
* not specificed.
*/
setDefaultBarStyle(PS_SOLID, 0); // Open
setDefaultBarStyle(PS_SOLID, 1); // High
setDefaultBarStyle(PS_SOLID, 2); // Low
setDefaultBarStyle(PS_SOLID, 3); // Close
setDefaultBarFgColor(Color.red, 0); // Open
setDefaultBarFgColor(Color.black, 1); // High
setDefaultBarFgColor(Color.black, 2); // Low
setDefaultBarFgColor(Color.blue, 3); // Close
setDefaultBarThickness(2, 0); // Open
setDefaultBarThickness(4, 1); // High
setDefaultBarThickness(4, 2); // Low
setDefaultBarThickness(2, 3); // Close
setPlotType(PLOTTYPE_FLATLINES, 0); // Open
setPlotType(PLOTTYPE_FLATLINES, 1); // High
setPlotType(PLOTTYPE_FLATLINES, 2); // Low
setPlotType(PLOTTYPE_FLATLINES, 3); // Close
}
var vSymbol = null;
var vInterval = null;
var vLastRawTime = null;
var vLastO = null;
var vLastH = null;
var vLastL = null;
var vLastC = null;
/*
* This is a neat formula because it is working on multiple intervals
* sBarItem will be "Open", "High", "Close", or "Low"
*
*/
function main(bShowOpen, bShowHigh, bShowLow, bShowClose) {
if(bShowOpen == null)
bShowOpen = true;
if(bShowHigh == null)
bShowHigh = true;
if(bShowLow == null)
bShowLow = true;
if(bShowClose == null)
bShowClose = true;
var vBarTime;
var vAbsTime;
var vIndex;
var nState = getBarState();
if(nState == BARSTATE_ALLBARS) {
vLastRawTime = null;
vLastO = null;
vLastH = null;
vLastL = null;
vLastC = null;
vSymbol = getSymbol();
vInterval = getInterval();
vSymbol += ",D";
}
if(vInterval == null)
return;
/*
* No need to show the OHL or C on a daily chart.
* only interested in seeing OHLorC on intraday.
*/
if(vInterval == "D" || vInterval == "W" || vInterval == "M")
return;
vRawTime = getValue("rawtime");
if(vRawTime == null)
return;
vRawTime = Math.floor(vRawTime / RawTime.DAY);
// Start of Performance addition
if(vLastRawTime != null) {
if(vRawTime == vLastRawTime) {
return new Array(vLastO, vLastH, vLastL, vLastC);
}
}
/*
* What time is the current bar?
*/
vBarTime = getValue("time");
if(vBarTime != null) {
/*
* vTime is currently the time for the current intraday bar.
* Ask for the time of the previous trading day for "Symbol,D"
* Note: See that we are asking for a different time frame
* than the default by passing a symbol,interval
*/
vAbsTime = getPreviousTradingDay(vBarTime, vSymbol);
if(vAbsTime == null)
return;
/*
* Get index to first bar of day. In this case the daily bar.
*/
vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol);
if(vIndex != null) {
vO = getValueAbsolute("Open", vIndex, vSymbol);
vH = getValueAbsolute("High", vIndex, vSymbol);
vL = getValueAbsolute("Low", vIndex, vSymbol);
vC = getValueAbsolute("Close", vIndex, vSymbol);
vLastRawTime = vRawTime;
vLastO = vO;
vLastH = vH;
vLastL = vL;
vLastC = vC;
return new Array(vO, vH, vL, vC);
}
}
return null;
}
I would be grateful if someone could tell me what I need to change to get this to work. Thanks in advance.
The exisiting code is:
/************************************************** **************************************************
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("PreviousDayDailyBars");
setCursorLabelName("PD-O", 0); // Open
setCursorLabelName("PD-H", 1); // High
setCursorLabelName("PD-L", 2); // Low
setCursorLabelName("PD-C", 3); // Close
/*
* Set the properties of the default bar. These will be the
* properties of any bar for which style, color, thickness is
* not specificed.
*/
setDefaultBarStyle(PS_SOLID, 0); // Open
setDefaultBarStyle(PS_SOLID, 1); // High
setDefaultBarStyle(PS_SOLID, 2); // Low
setDefaultBarStyle(PS_SOLID, 3); // Close
setDefaultBarFgColor(Color.red, 0); // Open
setDefaultBarFgColor(Color.black, 1); // High
setDefaultBarFgColor(Color.black, 2); // Low
setDefaultBarFgColor(Color.blue, 3); // Close
setDefaultBarThickness(2, 0); // Open
setDefaultBarThickness(4, 1); // High
setDefaultBarThickness(4, 2); // Low
setDefaultBarThickness(2, 3); // Close
setPlotType(PLOTTYPE_FLATLINES, 0); // Open
setPlotType(PLOTTYPE_FLATLINES, 1); // High
setPlotType(PLOTTYPE_FLATLINES, 2); // Low
setPlotType(PLOTTYPE_FLATLINES, 3); // Close
}
var vSymbol = null;
var vInterval = null;
var vLastRawTime = null;
var vLastO = null;
var vLastH = null;
var vLastL = null;
var vLastC = null;
/*
* This is a neat formula because it is working on multiple intervals
* sBarItem will be "Open", "High", "Close", or "Low"
*
*/
function main(bShowOpen, bShowHigh, bShowLow, bShowClose) {
if(bShowOpen == null)
bShowOpen = true;
if(bShowHigh == null)
bShowHigh = true;
if(bShowLow == null)
bShowLow = true;
if(bShowClose == null)
bShowClose = true;
var vBarTime;
var vAbsTime;
var vIndex;
var nState = getBarState();
if(nState == BARSTATE_ALLBARS) {
vLastRawTime = null;
vLastO = null;
vLastH = null;
vLastL = null;
vLastC = null;
vSymbol = getSymbol();
vInterval = getInterval();
vSymbol += ",D";
}
if(vInterval == null)
return;
/*
* No need to show the OHL or C on a daily chart.
* only interested in seeing OHLorC on intraday.
*/
if(vInterval == "D" || vInterval == "W" || vInterval == "M")
return;
vRawTime = getValue("rawtime");
if(vRawTime == null)
return;
vRawTime = Math.floor(vRawTime / RawTime.DAY);
// Start of Performance addition
if(vLastRawTime != null) {
if(vRawTime == vLastRawTime) {
return new Array(vLastO, vLastH, vLastL, vLastC);
}
}
/*
* What time is the current bar?
*/
vBarTime = getValue("time");
if(vBarTime != null) {
/*
* vTime is currently the time for the current intraday bar.
* Ask for the time of the previous trading day for "Symbol,D"
* Note: See that we are asking for a different time frame
* than the default by passing a symbol,interval
*/
vAbsTime = getPreviousTradingDay(vBarTime, vSymbol);
if(vAbsTime == null)
return;
/*
* Get index to first bar of day. In this case the daily bar.
*/
vIndex = getFirstBarIndexOfDay(vAbsTime, vSymbol);
if(vIndex != null) {
vO = getValueAbsolute("Open", vIndex, vSymbol);
vH = getValueAbsolute("High", vIndex, vSymbol);
vL = getValueAbsolute("Low", vIndex, vSymbol);
vC = getValueAbsolute("Close", vIndex, vSymbol);
vLastRawTime = vRawTime;
vLastO = vO;
vLastH = vH;
vLastL = vL;
vLastC = vC;
return new Array(vO, vH, vL, vC);
}
}
return null;
}
Comment