I have a question about the “Colour Scheme” property. At the moment there are the following “Time Intervals” possible: Sessions, Daily, Weeks, Months, Years, 5 Years.
That one is a little trickier. This is one way you could do it that is not timeframe-specific to the chart you are applying it to.
// Get the current bar index
brIndex = BARINDEX();
// Calculate the value of barIndex modulo 120 to create a cycle
modValue = MOD(brIndex, VALUE=120);
// Determine if the modValue is less than 60 for the first half of the cycle, making it true
isTrue = modValue < 60;
isTrue
In this instance, i want every 60 bars one colour, and the other 60 bars a different colour.
You can modify this script to use whichever Bar interval you want, you just need to modify the bar values (in this example, 60 and 120). The mod value should always be double the bar interval you are looking for, so 50 would be 100, 70 would be 140, etc.
I can’t think of a way to get the cycle going from a specific date. The only way would be to adjust the charts Date Range to use that specific start date.
For quarterly colours you could use MONTHNUM() in the script so it’s based on date rather than number of bars. This will show Q1 and Q3 one colour, and Q2 and Q4 another:
Thank you very much for your help. For the quarter colors I use Matthew’s script with “Show Plot”. It is perfect.
For decade and quarter coloring I have hard coded the time periods. It was easy but a little bit cumbersome. But on the other hand it was a one time job.
Here is the script for the decades:
D1 = BARDATE()>STRDATE(DATE=1849-12-31) and BARDATE()<STRDATE(DATE=1859-12-31) ;
D2 = BARDATE()>STRDATE(DATE=1869-12-31) and BARDATE()<STRDATE(DATE=1879-12-31) ;
D3 = BARDATE()>STRDATE(DATE=1889-12-31) and BARDATE()<STRDATE(DATE=1899-12-31) ;
D4 = BARDATE()>STRDATE(DATE=1909-12-31) and BARDATE()<STRDATE(DATE=1919-12-31) ;
D5 = BARDATE()>STRDATE(DATE=1929-12-31) and BARDATE()<STRDATE(DATE=1939-12-31) ;
D6 = BARDATE()>STRDATE(DATE=1949-12-31) and BARDATE()<STRDATE(DATE=1959-12-31) ;
D7 = BARDATE()>STRDATE(DATE=1969-12-31) and BARDATE()<STRDATE(DATE=1979-12-31) ;
D8 = BARDATE()>STRDATE(DATE=1989-12-31) and BARDATE()<STRDATE(DATE=1999-12-31) ;
D9 = BARDATE()>STRDATE(DATE=2009-12-31) and BARDATE()<STRDATE(DATE=2019-12-31) ;
D10 = BARDATE()>STRDATE(DATE=2029-12-31) and BARDATE()<STRDATE(DATE=2039-12-31) ;
D11 = BARDATE()>STRDATE(DATE=2049-12-31) and BARDATE()<STRDATE(DATE=2059-12-31) ;
D12 = BARDATE()>STRDATE(DATE=2069-12-31) and BARDATE()<STRDATE(DATE=2079-12-31) ;
D13 = BARDATE()>STRDATE(DATE=2089-12-31) and BARDATE()<STRDATE(DATE=2099-12-31) ;
EOD = D1 or D2 or D3 or D4 or D5 or D6 or D7 or D8 or D9 or D10 or D11 or D12 or D13 ;
EOD
For the quarters it is the same procedure but a lot more work! For the step line in decade chart I have created a csv file in Excel and update it via a VBA macro. So there is no daily time consuming work.