Sample code for moving trendlines

Questions about MultiCharts and user contributed studies.
PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Sample code for moving trendlines

Postby PD Quig » 21 Dec 2012

I would appreciate it if any of the assembled multitude here on the forum could offer up a code sample that demonstrates how to move (i.e., delete existing and re-draw new) trendlines. My goal is to auto-create Fibonacci retracements that adjust themselves as the endpoint price moves. I know how to draw the initial lines, but have yet to write any code that removes and replaces trendlines as price changes.

The Easy Language Functions And Reserved Words document shows a lot of potentially applicable TL functionality (TL_Delete, TL_Exist, etc.), but it would be helpful to see a straight-forward example of how to put it all together.

Thanks in advance for the help.

PDQ

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Sample code for moving trendlines

Postby TJ » 21 Dec 2012

I would appreciate it if any of the assembled multitude here on the forum could offer up a code sample that demonstrates how to move (i.e., delete existing and re-draw new) trendlines. My goal is to auto-create Fibonacci retracements that adjust themselves as the endpoint price moves. I know how to draw the initial lines, but have yet to write any code that removes and replaces trendlines as price changes.

The Easy Language Functions And Reserved Words document shows a lot of potentially applicable TL functionality (TL_Delete, TL_Exist, etc.), but it would be helpful to see a straight-forward example of how to put it all together.

Thanks in advance for the help.

PDQ
have you tried the manual?

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Sample code for moving trendlines

Postby PD Quig » 21 Dec 2012

And a happy holidays to you, too.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Sample code for moving trendlines

Postby PD Quig » 21 Dec 2012

As the moderator of a software user forum—a forum that has as its sole purpose the sharing of good ideas, expertise, tips, tricks, and best practices—your response to an honest request for help is “read the f*cking manual”? Really?

How about this: some people derive satisfaction from spending hours or days trying to figure out how implement their ideas in software. And that’s really admirable—if it’s a hobby. But when it’s your business, it’s a pretty stupid waste of time thrashing around with the “manual” when you could move up the learning curve faster by tapping into people with greater knowledge. This seems perfectly logical to me but, no worries, I guess I’ll look for my answers elsewhere.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Sample code for moving trendlines

Postby TJ » 21 Dec 2012

As the moderator of a software user forum—a forum that has as its sole purpose the sharing of good ideas, expertise, tips, tricks, and best practices—your response to an honest request for help is “read the f*cking manual”? Really?

How about this: some people derive satisfaction from spending hours or days trying to figure out how implement their ideas in software. And that’s really admirable—if it’s a hobby. But when it’s your business, it’s a pretty stupid waste of time thrashing around with the “manual” when you could move up the learning curve faster by tapping into people with greater knowledge. This seems perfectly logical to me but, no worries, I guess I’ll look for my answers elsewhere.
It's a standard first question.

You can always tell us what you have tried that didn't work, post your attempted effort, we can then debug it together.

If you want a basic explanation or basic example, you can try the manual.
If there is anything you don't understand in the manual, we are here to help.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Sample code for moving trendlines

Postby PD Quig » 21 Dec 2012

I spent a couple of hours poring over the Easy Language reference guide and determined that there was reason to believe management of TL's after creation might have some tricks to it (checking for the existence of a TL before trying to reference it in subsequent code, error trapping, etc.) that might not be obvious. I checked out the MC Wiki (is that the manual to which you refer?), but that seemed to me mainly a re-hashing of the EL docs. If there were samples of code I guess I missed them.

I've got several automated strategies that I've developed over the past few years that work fine so I almost never write code anymore, but I'm looking at a new indicator. It turns out that TS's education site has a decent TL webcast that includes a zip file download with a word doc and code samples. FYI.

http://www.TS.com/education/e ... sylanguage

Thanks,

PDQ

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Re: Sample code for moving trendlines

Postby bowlesj3 » 22 Dec 2012

determined that there was reason to believe management of TL's after creation might have some tricks to it
Actually you are dead on. It is tricky for sure. I wrote the solution found in the link below after moving trend lines proved too difficult and unpredictable. These functions work 999 times out of 1000 which is a heck of a lot better than what I was getting before I wrote them. I have some self debugging code in them you may wish to remove after a while. I have done that since I wrote these but not updated the zip files.
viewtopic.php?f=5&t=7748

The above link is in the "user Contributed Studies" link below.
viewforum.php?f=5

I would suggest doing a complete front to back scan of the "User contributed studies" without reading any detail until you have a list of things that may just be useful. I did that for (the manual, the commands list in the manual and the functions that come with MC) but I have never done it with the user contributed. I should have because I think it is a good idea. I certainly go back to my short list of potentially useful commands often. I think it is a mistake to dig in to specific commands too much until you have your short list. It is kind of like gathering the tools you need for a job before you start to do the work of learning them and applying them. In my opinion this is the best forward thinking shortcut of all. I remember my shortlist of commands by having them in my calendar system to remind me they are there. Once I have remembered to go back to them (finding them with a search string) I bump the reminder of their existence ahead a few years.

Another tip. Scan this link before you do too much coding. You will find information on some strange aspects to coding in EL.
viewtopic.php?f=16&t=7665

In fact, take this overview scanning a step farther and gather some short list things to study from the FAQs link.
Last edited by bowlesj3 on 24 Dec 2012, edited 3 times in total.

PD Quig
Posts: 191
Joined: 27 Apr 2010
Location: San Jose
Has thanked: 67 times
Been thanked: 10 times

Re: Sample code for moving trendlines

Postby PD Quig » 22 Dec 2012

Just checking in during a break from some brandy eggnog and Christmas present wrapping, and saw your post. I'll dig into your links tomorrow, but for now just wanted to say that I appreciate your input. Thanks again!


Return to “MultiCharts”