# Draw TL_New (rookie question).Could we set a given TL number

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1200
Joined: 23 Nov 2010
Has thanked: 699 times
Been thanked: 218 times

### Draw TL_New (rookie question).Could we set a given TL number

Hello

Is it possible to preset a a trendline number

I want to set to
98 a trendline of the last day high
99 a trendline to the last day low

Martin

TJ
Posts: 6348
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 954 times
Been thanked: 1828 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

arjfca wrote:Hello

Is it possible to preset a a trendline number

I want to set to
98 a trendline of the last day high
99 a trendline to the last day low

Martin

don't understand what you mean.

You can re-locate a trendline anywhere. Why preset?

arjfca
Posts: 1200
Joined: 23 Nov 2010
Has thanked: 699 times
Been thanked: 218 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

don't understand what you mean.

You can re-locate a trendline anywhere. Why preset?

My idea was to use a fix number to make sure that I won't play with these number another time. But I do understand now that it is not a necessity. As mentioned, that was a rookie question

Martin

bowlesj3
Posts: 1915
Joined: 21 Jul 2007
Has thanked: 128 times
Been thanked: 388 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

I do it by putting the study at the top of the list of studies in the chart using the alpha order technique (A_whatever) and using a set of low numbers starting with 1. MC starts assigning the numbers for the chart (sub-charts included) starting at 1 and working up. Once it is assinged for the MC session it can not be used again. So you need to assign it on the first bar of the chart. In some studies I have a starting trend line number since I never know if I want to assign a new set of fixed numbers at the bottom again. I did it because I wanted other studies to go after these numbers. Later I started using GVs to record a starting series of numbers so I could know the last number in the series. Regarding arrows I know the arrow is in the RSI since the number is less than 100 in its value where as in the price area it is well above that.There are lots of tricks one can use once one knows all the commands in the group of commands for arrows or text or trend lines. Color is handy for a trick and I hope they some day allow us to put pre- formatted (arrows,TLs and text) on a tool bar to make it so we can drop them on the chart fast and make use of these tricks more extensively.

When you have the study running on every tick and assign a drawing ID number after currentbar=1 (and you have studies deleting this same drawing type) you have to be careful because the EL code keeps deleting the drawing over and over on each new tick up until barstatus=2. Only when barstatus=2 is reached is the ID number locked for sure. There is no way to stop this. For this reason you should not use intrabarpersist for the ID number of a drawing ever because you want the temporary ID number the EL code created set back to zero when the next mid bar tick comes in to match the fact that the drawing is removed from the chart. So I have some code that waits for the barstatus=2 before I actually store the ID for later potential deletion of the drawing. This is okay if you have a lot of random drawings going out. However if you know what will be going out it is better to assign them on currentbar=1 and hide them when not in use. It saves all this work. Not being aware of this removal of new drawings up until bartstatus=2 can cause new programmers to create a lot of problem code (LOL, I was one of them).

tick1
Study1 ID_A gets 1 (an IF statement cause the EL code to no run TL_new again - the ID is stored in a GV)
study2 ID_B gets 2
study3 ID_C gets 3

tick2
all drawings are erased and all IDs are set to zero since there is no intrabarpersist.
study2 ID_B gets 1
study3 ID_C gets 2

tick3 (last tick for the bar and these assignments are locked)
study2 ID_B gets 1
study3 ID_C gets 2

So later Study1 wants to delete the drawing. The drawing has already vanished and not been put out there again. Not only that the study1 code thinks it needs to remove ID value 1. So it goes and delete the drawing from the other study2. It will drive the programmer crazy trying to figure out what is going on since they automatically assume that this automatic deletion until the end of the bar is not occurring.

Anyone brand new to MC should study this link and run the tests. Oddly enough it may even be more important if they have experience as a programmer since EL is a bit strange in the way it works.
viewtopic.php?f=5&t=6871&hilit=intrabarpersist
These users thanked the author bowlesj3 for the post (total 2):

Posts: 611
Joined: 09 Apr 2010
Has thanked: 378 times
Been thanked: 225 times
Contact:

### Re: Draw TL_New (rookie question).Could we set a given TL nu

I often add several studies, that each contain several different trendlines, sometimes they interfere with each other (changing colors etc)... It seems to me, being able to Number each trendline would eliminate the confusion and conflicts between trendlines, mentioned above by Bowles. The GV method might help in keeping them sorted, but being able to assign a number to them, would eliminate the need for GV's, visual order, etc. to keep them sorted.
I'm fairly new to drawing trendlines but numbering them, seems like a logical solution, to prevent conflicts.

TJ
Posts: 6348
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 954 times
Been thanked: 1828 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

I used to have trendlines interfering with others (changing colors, deleting the wrong lines, etc).
I thought it was a bug in MultiCharts,
but after carefully tracking my codes, I have determined that it was coding error that caused the color changes. After fixing the codes, I have not had an interference since.

Posts: 611
Joined: 09 Apr 2010
Has thanked: 378 times
Been thanked: 225 times
Contact:

### Re: Draw TL_New (rookie question).Could we set a given TL nu

TJ wrote:I used to have trendlines interfering with others (changing colors, deleting the wrong lines, etc).
I thought it was a bug in MultiCharts,
but after carefully tracking my codes, I have determined that it was coding error that caused the color changes. After fixing the codes, I have not had an interference since.

***********************************************************************
I think the easiest way to solve this is to show 2 simple trend-line studies, the ONLY difference is that one is plotting at the last high and the other is plotting at the last low. The one plotting the last high is yellow , the last low is green.. When BOTH are applied on the same chart, they interfere with each other, changing colors.. If you could explain what must be different for them to work independently, that would solve my problem.. I thought separate studies would automatically be independent.

//Study #1

Code: Select all

`Vars:TL.M1(-1);  oncebegintL.M1 = tL_new(d, t, 0, d, t, 0);   tl_setextleft(tL.M1,true);      end; tl_setend(tl.M1, d, t, H);tl_setbegin(tl.M1, d, t,H);Value1=TL_SetColor(1,yellow);`

// here is study #2-

Code: Select all

`Vars:TL.M1(-1);  oncebegintL.M1 = tL_new(d, t, 0, d, t, 0);   tl_setextleft(tL.M1,true);      end; tl_setend(tl.M1, d, t, L);tl_setbegin(tl.M1, d, t,L);Value1=TL_SetColor(1,green);`

TJ
Posts: 6348
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 954 times
Been thanked: 1828 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

TJ wrote:I used to have trendlines interfering with others (changing colors, deleting the wrong lines, etc).
I thought it was a bug in MultiCharts,
but after carefully tracking my codes, I have determined that it was coding error that caused the color changes. After fixing the codes, I have not had an interference since.

***********************************************************************
I think the easiest way to solve this is to show 2 simple trend-line studies, the ONLY difference is that one is plotting at the last high and the other is plotting at the last low. The one plotting the last high is yellow , the last low is green.. When BOTH are applied on the same chart, they interfere with each other, changing colors.. If you could explain what must be different for them to work independently, that would solve my problem.. I thought separate studies would automatically be independent.

//Study #1

Code: Select all

`Vars:TL.M1(-1);  oncebegintL.M1 = tL_new(d, t, 0, d, t, 0);   tl_setextleft(tL.M1,true);      end; tl_setend(tl.M1, d, t, H);tl_setbegin(tl.M1, d, t,H);Value1=TL_SetColor(1,yellow);`

// here is study #2-

Code: Select all

`Vars:TL.M1(-1);  oncebegintL.M1 = tL_new(d, t, 0, d, t, 0);   tl_setextleft(tL.M1,true);      end; tl_setend(tl.M1, d, t, L);tl_setbegin(tl.M1, d, t,L);Value1=TL_SetColor(1,green);`

The correct code should be:
(see last line)

Code: Select all

`Vars:TL.M1(-1);  oncebegintL.M1 = tL_new(d, t, 0, d, t, 0);   tl_setextleft(tL.M1,true);     end;tl_setend(tl.M1, d, t, H);tl_setbegin(tl.M1, d, t,H);TL_SetColor( tL.M1 , yellow);`
These users thanked the author TJ for the post:
arjfca

Posts: 611
Joined: 09 Apr 2010
Has thanked: 378 times
Been thanked: 225 times
Contact:

### Re: Draw TL_New (rookie question).Could we set a given TL nu

That's it !!!- thanks TJ, your a genius at coding.. I can see the difference now and it makes sense, (now I have to change about 20 different studies, but well worth it)-

bowlesj3
Posts: 1915
Joined: 21 Jul 2007
Has thanked: 128 times
Been thanked: 388 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

It does not matter whether you pre-assign low trend line numbers as I have done or if MC was changed to allow you to assign a higher range with a gap at the front (for example starting from 500 to 600). Either way you would need to have these studies run first and pre-place those lines out there so MC knows in advance to skip over them when it does its assigning. Yes MC could be programmed to have a table you fill out in advance somewhere telling it to skip over in advance but this is a lot more cumbersome than just doing what I do (put your studies at the front and pre-assign all possible trend lines in advance starting from 1 and working up). So you can do it but you just have to start from 1 and work up. So lets say you have 3 studies you want to do a preassign on.
Study1 (1 to 50)
Study2 (51 to 102)
Study3 (103 to 150).
Just make sure they are in alpha order such that they are executed first on the chart and make sure all the lines are placed on Currentbar=1 but hidden then use the functions I wrote in this link below to move them rather than delete and add them over and over again (saves MC work actually).
viewtopic.php?f=5&t=7748&hilit=movetrendline
NOTE: this function almost never fails to do a proper move (I have seen it do a nutty move about 3 times at most and it is a heck of a lot better than reading the manual and trying to figure it out).
These users thanked the author bowlesj3 for the post:
arjfca

bowlesj3
Posts: 1915
Joined: 21 Jul 2007
Has thanked: 128 times
Been thanked: 388 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

One note: I do not want to promote the use of trend lines in the true sense of the word and send someone completely new down what I consider a waist of time path. I use to use them and dumped them after 6 years of struggling with them (way too slow for day trading and very inaccurate/subjective I find). I replaced them with RSI trend lines (actually levels) and bollinger band trend lines. I have to figure out where the trend line is with every single trend (not hard most times). I use lines a huge amount of time but they are not used as trend lines. If someone can get true trend lines to work for them that is great. I did not feel comfortable with them (never could trust them).
Last edited by bowlesj3 on 18 Mar 2012, edited 4 times in total.

Posts: 611
Joined: 09 Apr 2010
Has thanked: 378 times
Been thanked: 225 times
Contact:

### Re: Draw TL_New (rookie question).Could we set a given TL nu

I'm not using the Trendlines for "trend", just to set levels for Hi or Lo of day, expected ranges etc..
These users thanked the author sptrader for the post (total 2):
arjfcabowlesj3

bowlesj3
Posts: 1915
Joined: 21 Jul 2007
Has thanked: 128 times
Been thanked: 388 times

### Re: Draw TL_New (rookie question).Could we set a given TL nu

I'm not using the Trendlines for "trend", just to set levels for Hi or Lo of day, expected ranges etc..