Add Tradeable Trend Line Programmatically
Author: thetraderman
Creation Date: 4/29/2011 2:17 PM
profile picture

thetraderman

#1
I search through the help manual and the site and couldn't find an answer but there are so many posts on the subject I could have missed it. I appologize if I did. As part of my strategy I am at the point where I would like to include a tradeable trendline. I don't want to manually enter it using the menu from the side bar. I would like to add it programmatically and have WL buy/sell depending on the criteria I set of how the bars interact with it. Is there a way I can do it? If so can you kindly direct me to where I can look. The trend lines can be at any angle not just support and resistance lines.

Thanks again!
profile picture

Eugene

#2
Although Tradeable Trendlines can only be drawn manually and accessed in a script after creation, you can draw something similar using WealthScript. See LinearRegLine, LineExtendX, LineExtendY and LineExtendYLog in the QuickRef (hit F11 for their description and code examples).
profile picture

Cone

#3
See the QuickRef Math functions LineExtendY and LineExtendYLog. These functions just solve the equation for a line (y = mx + b) by giving it 2 points and then solving for y at a given x. Using trendlines for backtesting is a tricky business, and there was a nice routine that I created in Version 4 for a TASC Traders' Tip that has yet to be converted.. we'll get there.
profile picture

thetraderman

#4
Thanks Eugene, Cone. Understanding that this feature is not yet available, can I put in a request to have the developers add it in at some time? I will try to use LineExtendX, etc, but that will be much more coding and testing I was hoping to avoid. Too bad. That tradeable trend line is a nice feature.
profile picture

Cone

#5
There's nothing missing. You calculate the value of trendline that you've "drawn" and then determine if you want to trade on its value at the current bar. You can alert AtMarket after a crossover, or you can use stop or limit orders. There's a million ways to do it, and you can do it with the program.
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).