TL_NEW ID is always 1?  [SOLVED]

Questions about MultiCharts and user contributed studies.
mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

TL_NEW ID is always 1?

Postby mefTrader » 31 Oct 2012

MC8 Build 5622


I am using the following piece of code

Code: Select all

TLSwingHigh = TL_New( Date[Strength], Time[Strength], TLPrice, Date, Time, TLPrice ) ;


The ID TLswingHigh seems to always return 1 for all the trend lines on the screen - rather than each one having a unique ID?

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: TL_NEW ID is always 1?

Postby mefTrader » 31 Oct 2012

I am plotting various trendlines at different points in time .... that is why I thought they would have different IDs

User avatar
TJ
Posts: 7150
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 987 times
Been thanked: 2040 times

Re: TL_NEW ID is always 1?

Postby TJ » 31 Oct 2012

mefTrader wrote:MC8 Build 5622


I am using the following piece of code

Code: Select all

TLSwingHigh = TL_New( Date[Strength], Time[Strength], TLPrice, Date, Time, TLPrice ) ;


The ID TLswingHigh seems to always return 1 for all the trend lines on the screen - rather than each one having a unique ID?

You will need to show more codes. The line itself does not illustrate the source of the problem.

User avatar
TJ
Posts: 7150
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 987 times
Been thanked: 2040 times

Re: TL_NEW ID is always 1?

Postby TJ » 31 Oct 2012

You can prove if MultiCharts has a bug:
create the following indicator (put it in subchart 2 and plot it as a line),
if the bug is in MultCharts, all the plotted value will be 1, as in your claim.
If the bug is in your code, you will see the plotted value increment with each bar.

Code: Select all

var: TLSwingHigh(-1);

TLSwingHigh = TL_New( Date, Time, close, Date, Time, close ) ;
Plot1(TLSwingHigh, "TLSwingHigh");

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: TL_NEW ID is always 1?

Postby mefTrader » 31 Oct 2012

ok tried that code and I can see it incrementing...

Printing out my ID stuck at 1. Weird

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: TL_NEW ID is always 1?

Postby mefTrader » 01 Nov 2012

I think the problem is with TL_Delete ? If you add the following code to your script above the ID seems to revert to 1 briefly and then back to 6 in the accumulation plot....

I think the ID should keep incrementing and there should be no glitch? This is the problem I am having in my custom script - once I use TL_Delete , the IDs revert to 1!

Code: Select all

if (TLSwingHigh = 5) then
begin
  tl_delete(1);
end;

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: TL_NEW ID is always 1?

Postby mefTrader » 01 Nov 2012

Tried tl_delete(2) and it seems to be re-using the deleted IDs before returning to 6 etc...
ok no problem

mefTrader
Posts: 141
Joined: 23 Jun 2011
Has thanked: 9 times
Been thanked: 7 times

Re: TL_NEW ID is always 1?  [SOLVED]

Postby mefTrader » 01 Nov 2012

I sorted my issue - "TL_Delete" seems to be fine

gianluca71
Posts: 15
Joined: 22 Aug 2018
Has thanked: 2 times

Re: TL_NEW ID is always 1?

Postby gianluca71 » 12 Sep 2018

Hi,
I have similar problem with TL numeration. I tried to plot ID number of the TL from zigzag indicator but strangely the ID not correspond to each TL As you can see in the attached picture (every horizontal line of the bottom red line should be correspond to each TL). I attached also the modified code that is the original zigzag with an added row at the bottom.

Code: Select all

inputs:
   Price( Close ),
   RetracePnts( 5 ),
   LineColor( Yellow ),
   LineWidth( 1 ) ;

variables:
   var0( 0 ),
   var1( Price ),                                         
   var2( Date ),                                         
   var3( Time ),                                         
   var4( 0 ),                                                         
   var5( false ),
   var6( false ),
   var7( false ),
   var8( -1 ) ; // cambiato da 0

                                                                               

var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0  <> -1 then
   begin
      condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
      if condition1 then                                     
         begin
            var5 = true ;
            var6 = true ;
            var4 = 1 ;
         end
      else
      begin
         condition1 = var4 = 1 and var0 >= var1 ;
         if condition1 then                                         
         begin
            var5 = true ;
            var7 = true ;
         end;
      end ;
   end
else
   begin
   var0 = SwingLow( 1, Price, 1, 2 ) ;
   if var0 <> -1 then
      begin
         condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
         if condition1 then                                        
         begin
            var5 = true ;
            var6 = true ;
            var4 = -1 ;
         end
         else
         begin
            condition1 = var4 = -1 and var0 <= var1 ;
            if condition1 then                                               
            begin
               var5 = true;
               var7 = true ;
            end ;
         end;
      end ;
   end ;

if var5 then
                                        
   begin
   var1 = var0 ;
   var2 = Date[1] ;
   var3 = Time[1] ;
   var5 = false ;
   end ;

if var6 then
                                
   begin
   var8 = TL_New( var2, var3, var1, var2[1], var3[1], var1[1] ) ;
{   TL_SetExtLeft( var8, false ) ;
   TL_SetExtRight( var8, false ) ;}
   TL_SetSize( var8, LineWidth ) ;
   TL_SetColor( var8, LineColor ) ;
   var6 = false ;
   end
else if var7 then
                                        
   begin
   TL_SetEnd( var8, var2, var3, var1 ) ;
   var7 = false ;
   end ;


Plot1(var8, "var8", red, Default, 2); // riga aggiunta per testare la TL. var8 dovrebbe restiruire gli ID di ogni singola TL

[attachment=0]Immagine.jpg[/attachment]

Have you any idea to solve the problem?
Many thanks and regard.
Attachments
Immagine.jpg
Immagine.jpg (264.66 KiB) Viewed 525 times

User avatar
TJ
Posts: 7150
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 987 times
Been thanked: 2040 times

Re: TL_NEW ID is always 1?

Postby TJ » 12 Sep 2018

Congratulations, you have learned a new lesson in the wonderful world of "Hindsight" Technical Analysis.


The new zig-zag was determined when the ID was changed,
but the beginning of the new zig-zag was a few bars previous (hindsight),
so the indicator went back a few bars to plot the zig-zag.

;-)>

gianluca71
Posts: 15
Joined: 22 Aug 2018
Has thanked: 2 times

Re: TL_NEW ID is always 1?

Postby gianluca71 » 12 Sep 2018

Sorry TJ but I did'n understood where the problem come from...
If so the ID number is a unreliable number, then is wrong?
Cheers

User avatar
ABC
Posts: 625
Joined: 16 Dec 2006
Has thanked: 119 times
Been thanked: 354 times
Contact:

Re: TL_NEW ID is always 1?

Postby ABC » 12 Sep 2018

gianluca71,

the value of your plot changes when a new trend line is drawn. The line is not created on the bar of the low/high (although it uses this point as the line's starting point for the drawing), but usually a few bars later when a new swing in the opposite direction is detected. That's what TJ is referring to and you can see this either in real time or by using the playback feature.

Regards,

ABC
Last edited by ABC on 12 Sep 2018, edited 2 times in total.

User avatar
TJ
Posts: 7150
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 987 times
Been thanked: 2040 times

Re: TL_NEW ID is always 1?

Postby TJ » 12 Sep 2018

gianluca71 wrote:Sorry TJ but I did'n understood where the problem come from...
If so the ID number is a unreliable number, then is wrong?
Cheers


It is NOT a problem.

This is how this indicator works.

There are 2 critical time line you need to see:
1. Point of Determination
2. Point of Change


The indicator was doing bar-by-bar analysis of the price action.
At some point, the indicator DETERMINED that the trend had changed.

That "Point of Determination" is when you received a new ID.

But the trend did not CHANGE at the time the determination was made.

The trend had ALREADY CHNAGED. (Thus I say this is a hindsight analysis.)

What the indicator doing was,
instead of plotting the zig-zag at the point where the determination was made,
it went back a few bars and plot it at the point of change.

That's why the two points do not align.
These users thanked the author TJ for the post:
sptrader

gianluca71
Posts: 15
Joined: 22 Aug 2018
Has thanked: 2 times

Re: TL_NEW ID is always 1?

Postby gianluca71 » 12 Sep 2018

Thanks guys, I' ll verify what you suggest to me especially the playback feature that I did't knew.
:-) Cheers


Return to “MultiCharts”