Hi,
Can you access any other functions via the alert properties of programmatically plotted horizontal lines? For example, instead of firing an alert on a close across I’d like to delete the line.
If not, how does one achieve this with an open-ended quantity of lines (and open-ended quantity of variables)? Hence my interest in the lines' built-in properties (alerts or anything else).
Any other ideas on an approach are most welcome.
Many thanks
Plotting and deleting horizontal lines programatically [SOLVED]
Re: Plotting and deleting horizontal lines programatically
Another approach I've been looking at is removing the lines with a moving average eraser, but I haven't been able to figure out how to access the lines' price property. How is price accessed in ITrendLineObject? Attached screenshot shows the kinds of errors I'm getting. There are others.
Thanks for any help.
Thanks for any help.
- Attachments
-
- horiz trendline price property--what is it.png
- (22.29 KiB) Downloaded 1132 times
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Plotting and deleting horizontal lines programatically
The `PriceValue()` method that you're trying to use here requires a DateTime value that specifies for which date and time the trend line should retrieve its price value. In other words, without such a DateTime value the `PriceValue()` method doesn't know whether it should return the trend line's price for this bar, a previous bar, or some future bar.Another approach I've been looking at is removing the lines with a moving average eraser, but I haven't been able to figure out how to access the lines' price property.
If you want the trend line's price for the current bar, you'd use something like:
Code: Select all
myTrendLine.PriceValue(Bars.Time[0]);
Code: Select all
myTrendLine.PriceValue(Bars.Time[1]);
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: Plotting and deleting horizontal lines programatically
Not sure if I fully understand, but the `Alert` property of a trend line can disable the trend line's alerts, set the alerts to fire intra-bar, or set the line's alerts to fire on the close of the bar.Can you access any other functions via the alert properties of programmatically plotted horizontal lines? For example, instead of firing an alert on a close across I’d like to delete the line.
I think I don't understand what you're saying here. But regarding one line versus a whole bunch of lines: it doesn't matter, because how we work with a single line is the same as how we work with multiple lines. The only difference is that, when we have a collection of multiple lines, then we'll need to work with each line individually (like, removing each line).If not, how does one achieve this with an open-ended quantity of lines (and open-ended quantity of variables)? Hence my interest in the lines' built-in properties (alerts or anything else).
It's not possible in PowerLanguage .NET to enable the alerts of all trend lines in one go or do something else with all trend lines unless you loop over all trend lines on the chart. (But in that case you'd still treat each line as an individual line, and just work with a group of lines that are processed quickly after each other.) Hope this makes sense.
Re: Plotting and deleting horizontal lines programatically
Thanks, Josh. Your material is excellent and fills a real void, I was able to use it to develop the automatic placement of trendlines, but I'm having difficulty with the removals. My question about using the alerts properties I'll just drop, I'm probably just barking up the wrong tree, and I'll just focus on the 2nd approach.
Thanks for the DateTime explanation. I've adjusted the code and now I have the opportunity to show you the second error I've been seeing (see attached.) I've found a reference on the subject but don't know how to apply it to the present situation. I've gone back and forth over your material but obviously I'm not getting it.
Again, any kind of further help appreciated.
Thanks for the DateTime explanation. I've adjusted the code and now I have the opportunity to show you the second error I've been seeing (see attached.) I've found a reference on the subject but don't know how to apply it to the present situation. I've gone back and forth over your material but obviously I'm not getting it.
Again, any kind of further help appreciated.
- Attachments
-
- error.png
- (16.38 KiB) Downloaded 1129 times
-
- double to bool.png
- (100.33 KiB) Downloaded 1129 times
Re: Plotting and deleting horizontal lines programatically [SOLVED]
Eureka. Found an approach that works. Dumped the MA and went back to matching a price variable to the trendline price directly. Very simple and obvious in hindsight. Thanks again Josh for the great resource you've developed.
- Attachments
-
- trendline delete.png
- (8.16 KiB) Downloaded 1133 times