So I have this script that changes the background colour of the chart if the time falls within the RTH.
It works fine except that it colours the background only up to the current bar. I'd like the colouring to be done for the entire period, so the border should be where the red line is. What am I doing wrong?
Thanks.
PS. The times are London times.
Code:
START_T = 1430; END_T = 2100; function preMain() { setComputeOnClose(true); setPriceStudy(true); setStudyTitle("BGColourT"); setCursorLabelName("BGColourT"); setShowTitleParameters(false); var fp1 = new FunctionParameter("colour1", FunctionParameter.COLOR); fp1.setDefault(Color.RGB(225, 225, 225)); var fp2 = new FunctionParameter("colour2", FunctionParameter.COLOR); fp2.setDefault(Color.RGB(192, 192, 192)); } function main(colour1, colour2) { var vHour = getHour(0); var vMin = getMinute(0); vHour = vHour.toString(); vMin = vMin.toString(); if (vHour < 10) vHour = "0" + vHour; if (vMin < 10) vMin = "0" + vMin; var vTime = vHour + vMin; if (vTime >= START_T && vTime <= END_T) setBarBgColor(colour2); else setBarBgColor(colour1); return; }
It works fine except that it colours the background only up to the current bar. I'd like the colouring to be done for the entire period, so the border should be where the red line is. What am I doing wrong?
Thanks.
PS. The times are London times.
Comment