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 ?
 
or maybe changing the colors of the candles?
 
Dmitri Mikhalev:
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 ?
add a recttangle.object as background and set its colour accordingly
 

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.

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
When a graphical object is created using the ObjectCreate() function, it's necessary to specify the type of object being created, which can be one of the values of the ENUM_OBJECT enumeration. Further specifications of object properties are possible using functions for working with graphical objects.
 

Yes Rectangle Label (or Canvas if you get too artistic :) ) , and also you can alter this directly with 
"ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrBlack);"

  1. Make Sure to set the rectangle as background "ObjectSetInteger(0,"",OBJPROP_BACK,true);"
  2. Then in OnInit() set "EventSetTimer(seconds);" add the interval you need in seconds if your ea/indicator does not utilize timer otherwise.
  3. (2) will fire every "seconds" you set and will execute the code found in "OnTimer()" function
  4. From there you check the Local time "TimeLocal();" and you extract the hours "int hour=TimeHour(TimeLocal());"
  5. 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
  6. Inside OnTimer , every time you detect the current hour being different than the previous hour you will execute your coloring code
  7. 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]);