Keep a rectangle updated?

 

Hi guys,

I use a script to print a rectangle to display support and resist zones. Now my problem is that the script only prints the rectangles to the current bar because I use TimeCurrent() as the second time value. I read in another thread that a future time value expands the rectangle like a ray. I tried it and it worked fine. But then I have the problem that I can't change the height of the rectangle. Sometimes I have to adjust the support and resist zones. Then I doubleclick on the rectangle and change the height a little bit and that is not possible with a rectangle which reaches out of the screen.

Therefore I thought about making an indicator which gets the information of all rectanges displayed in the chart, deletes them and creates the same rectangles but with a new TimeCurrent(). This is the only idea I have to keep a rectangle updated.

Has anyone a better idea? Thanks!!

 
 double NewPrice1=1.0000;
 double NewPrice2=2.0000;
 ObjectSet("MyRectangle",OBJPROP_PRICE1,NewPrice1);
 ObjectSet("MyRectangle",OBJPROP_PRICE2,NewPrice2);
 
Thanks, GumRai... I don't know why I didn't have the idea just to change the object-properties... Stupid me! :D
 
Nobody is stupid here. You just don't realized that you could do like that. That's all. XD
 

Yes! :D

But I have another question: When the rectangle should expand until the current bar, I use TimeCurrent() as TIME2. But what to I have to add if I want the rectangle be expanded one more bar more to the right? I saw that time values for the future are done like Time[0]+86400. But I don't know exactly the 86400 means. So what must I add to Time[0] or TimeCurrent() to expand it one more bar?

 
+86400 means you are adding 86400 seconds to Time[0]
 
mar:

Yes! :D

But I have another question: When the rectangle should expand until the current bar, I use TimeCurrent() as TIME2. But what to I have to add if I want the rectangle be expanded one more bar more to the right? I saw that time values for the future are done like Time[0]+86400. But I don't know exactly the 86400 means. So what must I add to Time[0] or TimeCurrent() to expand it one more bar?


Time[0]+Period()*60

But if it happens that the next bar does not immediately follow the close of the current bar (weekend or missing bar) it will revert to the same as Time[0]

 
mar: Thanks, GumRai... I don't know why I didn't have the idea just to change the object-properties... Stupid me! :D
Or use ObjectMove like in my TLine code
 
Thanks guys!!
 
GumRai:


Time[0]+Period()*60

But if it happens that the next bar does not immediately follow the close of the current bar (weekend or missing bar) it will revert to the same as Time[0]

Better to use PeriodSeconds()
 
You mean Time[0]+PeriodSeconds() ?
Reason: