Siligardos Nov 2006 Code for Building Automatic Trendlines
Author: sedelstein
Creation Date: 11/24/2012 4:31 PM
profile picture

sedelstein

#1
There is code here for a technique to draw automatic trendlines

It is an earlier version of WL. I tried using the translator w/o luck
I tried searching as well.
Asking here after looking around for a while

Does it exist anywhere on WL?

http://www.traders.com/Documentation/FEEDbk_docs/2006/11/TradersTips/TradersTips.html

Thanks for the help

profile picture

Eugene

#2
I have no idea what on Earth is SISeries from Giorgio's code (it looks like never been published), so plotting these mysterious series have been removed. For the rest, here it goes. Substitute your ticker instead of ^GSPC:

CODE:
Please log in to see this code.
profile picture

sedelstein

#3
Thank you for your help Eugene. I will give it a try
profile picture

sedelstein

#4
Thanks Eugene. Works like a charm

I'll modify it to draw the lines on either the closes (as it is now) or Highs (for downtrends) or Lows (for uptrends)

Stylistically, I also want to have different colors for up and down lines.

Could you offer a suggestion as to where to effect this? That is, my question is How do I best program the option for the uptrend / downtrend colors.

Regards
profile picture

sedelstein

#5
Actually, after looking at the code, I'm seeing that the Close is passes to these routines and that modifying it to draw the lines off the Highs and/or Lows is a little tricky.

If time allows and you feel it worthwhile to the WL Community, could you possibly take a stab at it?

profile picture

sedelstein

#6
Hold On, Think I've got it. Will post the code shortly
profile picture

sedelstein

#7
Here is somewhat changed code. (Not necessarily elegant but works)
I added a strategy parameter so that I could change the percentage for the Peak/Trough Indicator

Changing it via the slider doesnt appear to work. That is, I would have expected the trendlines to change as I varied the slider.

Thoughts?

CODE:
Please log in to see this code.
profile picture

Eugene

#8
QUOTE:
Changing it via the slider doesnt appear to work. That is, I would have expected the trendlines to change as I varied the slider.

Why would you expect that? The PTpct variable is unused.
profile picture

sedelstein

#9
oh! Duh!
profile picture

sedelstein

#10
I'm now trying to write similar code using a PivotPointBar.Series method instead of PTBar.Series

I think it will work better based on what I see in http://www2.wealth-lab.com/WL5Wiki/PivotPointBar.ashx?HL=pivotpointbar

It's a little trickier as instead of one function (PTBar) there are now 2 series to work with as PivotBointBar has to be called 2x, once for peaks and once for troughs.

Any easy way to combine the two calls to produce something equivalent to the single series obtained by PTBar.Series?

Suggestions appreciated
profile picture

sedelstein

#11
I've created a series of Pivot Points, similar to the PTBars. A series that has the bar numbers of the previous pivot points just like PTBars does.

CODE:
Please log in to see this code.


But find this series blows up the whole routine.
Pretty stuck here. If you can offer some help, I'd appreciate it

Thanks
profile picture

sedelstein

#12
Eugene, I can use your help. I think my problem is something I'm doing in c#

I wrote the following code

CODE:
Please log in to see this code.


I ran this on 2000 bars of GLD and also did the math in Excel

The code produces changing values for bars (bar3,bar2,bar1) but bar3=bar2=bar1 ??

Here is what I get in Excel and by hand. I get the right result.

myPivots bar3 bar2 bar1
11/23/2012 1999 1999 1995 1989
11/21/2012 1994 1994 1989 1985
11/20/2012 1994 1994 1989 1985
11/19/2012 1994 1994 1989 1985
11/16/2012 1994 1994 1989 1985
11/15/2012 1994 1994 1989 1985
11/14/2012 1990 1990 1985 1983
11/13/2012 1990 1990 1985 1983
11/12/2012 1990 1990 1985 1983
11/9/2012 1990 1990 1985 1983
11/8/2012 1985 1985 1983 1980


Here is what the code produces. I think the logic is correct. Could it be something with Dataseries objects or casting in C#?
1999 11/23/2012 1999 1999 1999 1999
1998 11/21/2012 1994 1994 1994 1994
1997 11/20/2012 1994 1994 1994 1994
1996 11/19/2012 1994 1994 1994 1994
1995 11/16/2012 1994 1994 1994 1994
1994 11/15/2012 1994 1994 1994 1994
1993 11/14/2012 1990 1990 1990 1990
1992 11/13/2012 1990 1990 1990 1990
1991 11/12/2012 1990 1990 1990 1990
1990 11/9/2012 1990 1990 1990 1990
1989 11/8/2012 1985 1985 1985 1985

Oddly, if I supply PTBars instead of my own calculated pivots, the code works, hand checked with the same Excel program which leads me to believe it is something with C# or the way I am using the DataSeries object

Thanks for your help. Hope it is something obvious to you.
profile picture

sedelstein

#13
error in the series construction - sorry for the confusion
profile picture

Eugene

#14
In a duplicate thread that no longer exists, grtrader asked:

In the post for "Silgados Nov 2006 Code For Building Trendlines", there is some code written for which I cannot find the definitions of:

DrawActiveTrendline
UpwardTrendline
DownwardTrendline

I searched Wealth Lab Wiki, but could not find anything.
profile picture

Eugene

#15
Here in this thread you should find the roots. No Wiki definitions ever existed.
profile picture

KGo

#16
For reference, here is the original indicator code for this strategy.
profile picture

Eugene

#17
Looking at Giorgio's comment to the WL4 code posted by KGo, there wasn't any harm done for not including the peeking SISeries. ;)
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).