Rectangle object not showing when end point isn't last bar

 

Hi,

public:
   string              DrawRectangle(string Name, ENUM_TIMEFRAMES Timeframe, int StartBar, double StartPrice, int EndBar, double EndPrice, int Color)
     {
      datetime StartBarTime = iTime(Symbol(), Timeframe, StartBar);
      datetime EndBarTime = iTime(Symbol(), Timeframe, EndBar);

      ObjectCreate(0,Name,OBJ_RECTANGLE,0, StartBarTime, StartPrice, EndBarTime, EndPrice);
      ObjectSetInteger(0,Name,OBJPROP_COLOR,Color);
      ObjectSetInteger(0,Name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,Name,OBJPROP_HIDDEN,true);
      ObjectSetInteger(0,Name,OBJPROP_BACK,true);
      ObjectSetInteger(0, Name, OBJPROP_FILL, true);

      return Name;
     }


This code does not work unless EndBar value is 0.

I would like to draw a rectangle that is not pointing to the last bar.

Any suggestions on what to do?

Thank you,

Hendrik

 
lastpunisher:

Hi,


This code does not work unless EndBar value is 0.

I would like to draw a rectangle that is not pointing to the last bar.

Any suggestions on what to do?

Thank you,

Hendrik

Hi 

Add a switch 

bool redrawNow

at the end of the function parameters

and ,above the

return Name;

 add

if(redrawNow){ChartRedraw();}

or the 

ChartRedraw();

without the switch at all

 

Thank you for response Lorentzos.

I made a silly mistake in other part of the code where I cleared the chart and therefore it disappeared instantly.

 
lastpunisher #:

Thank you for response Lorentzos.

I made a silly mistake in other part of the code where I cleared the chart and therefore it disappeared instantly.

Ehehe . It happens sometimes