Finding Trend Line Segment Start and Stop Bar Numbers
Author: DonGordon
Creation Date: 3/28/2020 10:24 PM
profile picture

DonGordon

#1
If I draw a trend line between two bars, no left or right extension, is there a way to get the bar numbers of where the trend line segment starts and ends?

Ultimately, I want to find the trend line values, using the TrendLineValue function between the first bar of the trend line segment and the last bar of the trend line segment.

Thanks for your help!
profile picture

Eugene

#2
QUOTE:
If I draw a trend line between two bars, no left or right extension, is there a way to get the bar numbers of where the trend line segment starts and ends?

Sorry but this is not supported by the TrendLineValue.
profile picture

Cone

#3
If the idea is to manually draw a Trendline and later generate a trading signal/alert, then you'll find this useful:
http://www2.wealth-lab.com/WL5Wiki/kbTrendlinesInSM.ashx

.. and after reviewing that solution, it just occurred to me that it could be improved by a simple change to include the name of the trendline in the filename. That way, you could look up trendlines with different names, like "Support" and "Resistance".
profile picture

DonGordon

#4
Many thanks Eugene and Cone for the input. I was afraid TrendLineValue did not support this. Perhaps an opportunity for a future feature. I know from many years of use that AmiBroker returns the start and end value of a hand drawn/named trend line segment. As I'm switching over, I was hoping WL would do the same.

To Cone's question, I'm actually looking to calculate the distance between the trend line and the Highs or Lows above/below the trend line segment. This is used to determine upside or downside break objectives. I've figured out a work around but it involves getting part of the answer through the WL function and then entering the partial answer into a spreadsheet to get the rest of the answer. I may convert this over to enter the data into a Strategy Parameter. Not as clean as I'd like but it will work.

Thanks again for your help!
profile picture

Eugene

#5
QUOTE:
To Cone's question, I'm actually looking to calculate the distance between the trend line and the Highs or Lows above/below the trend line segment. This is used to determine upside or downside break objectives

Don, you might find some insight in purely programmatic ways of doing it via LineExtend* methods rather than the manually drawn trendlines. Cone has created strategies which you can download into Wealth-Lab right from "Open Strategy" dialog (Ctrl+O) download feature:


Check "Download public strategies", click "Begin download", then search for "trendline" in Strategy Name.
profile picture

DonGordon

#6
Eugene;

Thanks for the pointer to the public strategies and Cone's work. Being new to WL, I hadn't found the wealth of code in the library. This is great.

I did review Cone's work on Trendlines, brilliant stuff, but didn't find a direct solution to what I was doing. That said, Cone's work did spark the idea the works for my need.

Given my trend line touch points are always the last two fractals, it works nicely given the drawn trend line snaps to the highs of the fractals. Not sure at this point that I've accommodated all exceptions but it's a good start. Here's the code segment:

CODE:
Please log in to see this code.
Many thanks for the help and direction !!!
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).