I am trying to draw a polygon on the chart whose height and width change as the bars update. Sort of a support/resistance zone that adjusts itself each bar. And I want to draw multiple polygons as these S/R zones have a finite beginning and end to them. Anyway, using DrawPolygon and feeding a rectangle to it, causes a graphic that is a series of overlapping rectangles which isn't quite the effect I want. I just want one rectangle. Is there a way to clear the previous rectangle and then draw the new one? I also tried to draw 2 lines, but I can't fill the area between them with a color. The PlotSeriesFillBand seemed like a possibility, but I couldn't figure out how to create a DataSeries with a beginning and end. Perhaps some C# or .NET tools might work here? Any suggestions?
Size:
Color:
QUOTE:
And I want to draw multiple polygons as these S/R zones have a finite beginning and end to them.
QUOTE:
I just want one rectangle.
To whom how, but to me looks like contradicting requirements?
Size:
Color:
QUOTE:
Is there a way to clear the previous rectangle and then draw the new one?
Solution:
do not draw the "previous" rectangles. Store the data only for the rectangle(s) that you want to draw and process that information after you've gone through all the bars of the chart.
As Eugene mentioned, though, your requirements conflict. It could be the case that you want to use the information in the rectangles while processing the bars for backtesting, and in that case, you simply don't draw them if you don't want them on the chart.
This won't be precisely what you're looking for, but you may be able to get some ideas from the
Rectangles study/class that I wrote for Version 4. See the Description for usage examples.
Size:
Color:
Sorry for the contradictory request. I understand Cone's suggestion, and that would work for backtesting, but I would like to do it live. To answer Eugene's comments, I want many rectangles in different areas, I didn't want the "..overlapping rectangles" caused by multiple calls to DrawPolygon.
I would like to do this as a strategy running live. Attached is an image of what I would like to do. Rect1 is one zone. Rect2 is another zone that also occurs during some of the bars of rect1. So, if you imagine running live, and we are at 2:00pm bar, only rect1 would be drawn at that point. At 3pm, rect2 would have come and gone, but I would like it to remain on the chart, and rect1 is still "valid" meaning it is still being drawn with each new bar. At 4pm, rect1 and rect2 would not be valid anymore, but rect3 is being drawn, and will continue to be drawn when the next day starts.
Any suggestions would be appreciated. Tried posting a jpg image to better illustrate my point, but did not seem to work. Let me know and I can email it to you, or let me know how to post. I hit IMG button, and then do a copy paste of the image, and click the cursor between the html codes, but it just pastes the local path to the file and not the jpg file itself.
Size:
Color:
QUOTE:
that would work for backtesting, but I would like to do it live.
No, it works for anytime you want to do it.
QUOTE:
...we are at 2:00pm bar,...
I'm saying that you save drawing the rectangle(s) until the end. You put the data in a list and only draw the ones that you programmed that you want to see on the chart. My Version 4 example that I pointed you too does this, I'm sure.
Size:
Color:
Ahh. Got it. So, do the drawing outside the "for loop", but at the end of the Execute method?
Size:
Color:
A side note:
QUOTE:
I hit IMG button, and then do a copy paste of the image, and click the cursor between the html codes, but it just pastes the local path to the file and not the jpg file itself.
How easier would life be if the browser would be so smart to paste graphics from your computer into the text form of a forum response without any human interaction! :)
In reality, though, first thing is to upload your file to any image hosting server, then extract the direct link to the image, and only then paste the URI inside a pair of IMG tags.
Size:
Color: