Hi,
I'm creating an indicator to show support and resistance using the Peak and Trough functions. I wanted to draw a line for each new support and resistance level until that level has been broken. The DrawLine function doesn't return an object or handle where I can extend the line or delete the line when it has been violated.
Do you have any suggestions on an alternative way to do the above or access the line object so it can be modified?
Size:
Color:
Size:
Color:
Size:
Color:
Thanks guys. I think I can figure it out with these examples.
Size:
Color:
Hi Guys,
So I went through the examples from above and still have one question. Once I have drawn something on the PricePane is there any way to modify the existing drawing?
For example:
a) I draw a line from a given point to the current bar.
b) Once new bar is created, how do I extend the existing line one bar further? Or hide/delete the old line and create a new one with the new end point?
Thanks in advance.
Size:
Color:
QUOTE:
Once I have drawn something on the PricePane is there any way to modify the existing drawing?
There is no "modify". The script runs once each time you load the chart or when a new bar is added in a streaming chart. If you need to modify a drawing, you should not have drawn it!
I know what you mean though. What you need to do is *wait* until you're ready for the final draw. Store whatever you need in variables, classes, lists, etc. If something becomes obselete, remove it. Draw whatever's left. All the "Trendline Breakout" scripts do this.
a) See DrawLine()
b) Use LineExtendY() or if viewing in semilog, LineExtendYLog().
See the examples in the QuickRef (F11).
Size:
Color:
Got it. Thanks Cone.
Size:
Color:
QUOTE:
I wanted to draw a line for each new support and resistance level until that level has been broken.
I've just added a new extension method to Community.Components that will facilitate this for everyone. Once you identify a trendline, you only need to call this.CheckExtendedTrendline() for each bar after the trendline is established. The method returns 0 if the trendline is not broken, or the bar number on which it was crossed by the number of consecutive bars specified (1 is the default if not specified).
Maybe we can get Eugene to push this out for a 2020.10 release later today??
CODE:
Please log in to see this code.
And here's an example of a simple script that uses it. It finds the last two peaks and the bar on which the trendline is broken by the number of consecutive bars passed, and draws the line.
CODE:
Please log in to see this code.
Size:
Color:
QUOTE:
Maybe we can get Eugene to push this out for a 2020.10 release later today??
Done.
Size:
Color: