background color of charts
This isn't exactly super-necessary, but is it possible to change to background color of charts partially, depending on what time it is..
so it's say.. black during night hours and white during day hours?
I guess that would be some sort of time indicator :p ?
like in...
"For every time time is from this to that, use this rectangle as background"?
I know nobody likes a freeloader, but
what am even to look for in the reference? rectangles?
(thank you)
okay, som I am seing here, that I should use the OBJ_RECTANGLE_LABEL...
no that's just a label...
but ehm.. lets call the object rect.
should there be some sort of loop involved perhaps?
I don't know where to even begin.
- www.mql5.com
Yes Rectangle Label (or Canvas if you get too artistic :) ) , and also you can alter this directly with
"ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrBlack);"
- Make Sure to set the rectangle as background "ObjectSetInteger(0,"",OBJPROP_BACK,true);"
- Then in OnInit() set "EventSetTimer(seconds);" add the interval you need in seconds if your ea/indicator does not utilize timer otherwise.
- (2) will fire every "seconds" you set and will execute the code found in "OnTimer()" function
- From there you check the Local time "TimeLocal();" and you extract the hours "int hour=TimeHour(TimeLocal());"
- now to avoid changing the color constantly you will need a "int prev_hour=-1;" declared before Init() ,and also set to -1 on init
- Inside OnTimer , every time you detect the current hour being different than the previous hour you will execute your coloring code
- for which you can have a handy 24 slot array with colors and use the relevant hour color "color colors[24];" ,
ChartSetInteger(0,CHART_COLOR_BACKGROUND,colors[hour]);
so it's say.. black during night hours and white during day hours?
I guess that would be some sort of time indicator :p ?