I am having trouble changing the background bar color when the current bar is the first bar of a new day. It works fine for all previous days, but the background color of the current day doesn't change until the second bar. Is there some kind of DrawBarBgColor function that I am missing?
Dale Sullivan
Dale Sullivan
PHP Code:
/**************************************************
Created by Dale Sullivan October 2003
This program shows where a day starts and ends. I find
that this is especially useful on 60 minute charts.
***************************************************/
var vTempColor;
var vBgColor1;
var vBgColor2;
function preMain() {
setComputeOnClose(true);
setPriceStudy(true);
setStudyTitle("NewDay");
setCursorLabelName("NewDay");
var fp1 = new FunctionParameter("v1stBgColor", FunctionParameter.COLOR);
fp1.setDefault(Color.white); // First color = white
var fp2 = new FunctionParameter("v2ndBgColor", FunctionParameter.COLOR);
fp2.setDefault(Color.RGB(0xE8, 0xE8, 0xE8)); //Second color = very light grey
}
function main(v1stBgColor, v2ndBgColor) {
if(vBgColor1 == null)
vBgColor1 = v1stBgColor;
if(vBgColor2 == null)
vBgColor2 = v2ndBgColor;
var vThisBarDate = getDay();
var vPreviousBarDate = getDay(-1);
if(vThisBarDate != vPreviousBarDate){
//Swap colors
vTempColor = vBgColor1;
vBgColor1 = vBgColor2;
vBgColor2 = vTempColor;
}
setBarBgColor(vBgColor1);
}
Comment