Getting only one reading with TL_GetActive  [SOLVED]

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Getting only one reading with TL_GetActive

Postby arjfca » 02 May 2017

Hello again

A little code is written to modify the style of an active trend line style. The goal is to toggle between Style 1 and style 2

The problem is that once I manually select a trendline the style will oscillate between these two values
I did try to set a verification flag ModificationDone that I reset on every pass, but the problem remained.

I want the setting style to remain after the trendline is not anymore selected.

Any idea

Martin

Code: Select all


Active_TL = TL_GetActive;
if TL_GetBeginVal (Active_TL) = TL_GetEndval(Active_TL) then begin
If modificationDone = False then begin
ModificationDone = True;
ActualStyle = TL_GetStyle(Active_TL);
If ActualStyle = 1 then
TL_SetStyle(Active_TL, 2)
else
TL_SetStyle(Active_TL,1);
End;
end;

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Getting only one reading with TL_GetActive

Postby arjfca » 02 May 2017

I did replace The TL_Get_Active for MC_GetActive

The trendline does not oscillate anymore but the code does not react every time to the selected trendline. I need to select it few time before I see the style change

Martin

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: Getting only one reading with TL_GetActive

Postby Kristina MultiCharts » 03 May 2017

Hello arjfca,

Please set your flag ModificationDone as IntraBarPersist.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Getting only one reading with TL_GetActive

Postby arjfca » 03 May 2017

Problem persist. I did remove the validation flag, It was causing more problems.

Now the code do respond but within a delay of up to 15 seconds. I did test it on a tick charts and many ticks passed before code do respond

I added a validation for the reading of the MC_GetActive value. With it, only one reading. Now remain the delay. Why does it take so long to respond.

Code: Select all

Active_TL = mc_tl_getactive;
If Active_TL <> Old_Active_TL then begin
if active_TL <> -1 and (TL_GetBeginVal (Active_TL) = TL_GetEndval(Active_TL)) then begin
ActualStyle = TL_GetStyle(Active_TL);
If ActualStyle = 1 then
TL_SetStyle(Active_TL, 2)
else
TL_SetStyle(Active_TL,1);

Print ("TL_Active: ", Active_TL:0:0, " Style: ", TL_GetStyle(Active_TL):0:0);
end;
Old_Active_TL = Active_TL;

End;

User avatar
Kristina MultiCharts
Posts: 63
Joined: 04 Sep 2014
Has thanked: 5 times
Been thanked: 34 times

Re: Getting only one reading with TL_GetActive

Postby Kristina MultiCharts » 03 May 2017

Hello,

Please make your variables IntraBarPersist and as soon as new tick arrives the style will be changed. If you want the style to change on mouse clicks, you can add ProcessMouseEvents and set it to True.

arjfca
Posts: 1292
Joined: 23 Nov 2010
Has thanked: 725 times
Been thanked: 223 times

Re: Getting only one reading with TL_GetActive  [SOLVED]

Postby arjfca » 03 May 2017

Hello,

Please make your variables IntraBarPersist and as soon as new tick arrives the style will be changed. If you want the style to change on mouse clicks, you can add ProcessMouseEvents and set it to True.

Hello Kristina

Variables are set with the Intabarapersist and the code does not respond to the tick movement immediately. I will add the Mouse event and see if it respond faster


Resolved I just format the indicator and un select : Skip identical price tick ...

Martin


Return to “MultiCharts”