change background color

 
Is there a way to change the chart background color depending on a variable in MQL4?
 

AFAIK it's can be done only through WINAPI

 
SanMiguel:
Is there a way to change the chart background color depending on a variable in MQL4?

hi


you can draw rectangle object, bigger than background, effect will be the same.


regards

oromek

 
oromek:

hi


you can draw rectangle object, bigger than background, effect will be the same.


regards

oromek


How do I get the size of the window to draw a rectangle across it and continually readjust the rectangle to the new candle?
 

I think I saw somthing about this in the libraries. The trouble for me is that the comments are in russian https://www.mql5.com/en/code/8412

 
 

I tried this code but it doesn't colour in the right hand side of the chart on ichiomoku charts sue to the 26 period shift.

Any ideas on what to change?

I tired adding +26 to the WindowBarsPerChart but it doesnt change anything.


   //background
   datetime left=Time[WindowFirstVisibleBar()];
   int      right_bound=WindowFirstVisibleBar()-WindowBarsPerChart();
   if(right_bound<0) right_bound=0;
   datetime right=Time[right_bound]+Period()*60;

   if (
          Bid > iIchimoku(Symbol(), PERIOD_D1, 9, 26, 52, MODE_SENKOUSPANA, 0) && 
          Bid > iIchimoku(Symbol(), PERIOD_D1, 9, 26, 52, MODE_SENKOUSPANB, 0) &&
          Bid > iIchimoku(Symbol(), PERIOD_H4, 9, 26, 52, MODE_SENKOUSPANA, 0) && 
          Bid > iIchimoku(Symbol(), PERIOD_H4, 9, 26, 52, MODE_SENKOUSPANB, 0) &&
          Bid > iIchimoku(Symbol(), PERIOD_H1, 9, 26, 52, MODE_SENKOUSPANA, 0) && 
          Bid > iIchimoku(Symbol(), PERIOD_H1, 9, 26, 52, MODE_SENKOUSPANB, 0)
      )
   {
      ObjectSet("Bkgrnd", OBJPROP_COLOR, LimeGreen);
      ObjectSet("Bkgrnd", OBJPROP_PRICE1, WindowPriceMax(0));
      ObjectSet("Bkgrnd", OBJPROP_PRICE2, WindowPriceMin(0));
      ObjectSet("Bkgrnd", OBJPROP_TIME1, left);
      ObjectSet("Bkgrnd", OBJPROP_TIME2, right);
   }
 

It seems that if I do this, the Time function cannot pick up a correct time:


datetime left=Time[WindowFirstVisibleBar()];
   int      right_bound=WindowFirstVisibleBar()-WindowBarsPerChart()-26;
   //if(right_bound<0) right_bound=0;
   datetime right=Time[right_bound]+Period()*60;
 
? bump
 
int iShiftBars = 26 ;
datetime right=Time[right_bound]+Period()*60*iShiftBars;
Reason: