Ticks Left Indicator

Questions about MultiCharts and user contributed studies.
KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Ticks Left Indicator

Postby KhaosTrader » 01 Jan 2013

Hi,

I want to put a "ticks left" indicator on my chart, and i am running into a few issues, first, the tick count is not correct, as it seems that ticks are skipped (in playback i have been testing this).

Second, i want the indicator to be at the right of the last bar, and this has been a challenge to figure out how to do on the tick chart.

Here is some code:

Code: Select all

vars:
vTextID(0),
intrabarpersist vTickCount(0);



if barstatus(1)=2 then begin

vTickCount = 1500;

end;
vTickCount = vTickCount-1;
text_delete(vTextID);
vTextID = text_new(date,time,high,"<- " + numtostr(vTickCount,0));

User avatar
TJ
Posts: 7283
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 992 times
Been thanked: 2070 times

Re: Ticks Left Indicator

Postby TJ » 01 Jan 2013

Hi,

I want to put a "ticks left" indicator on my chart, and i am running into a few issues, first, the tick count is not correct, as it seems that ticks are skipped (in playback i have been testing this).

Second, i want the indicator to be at the right of the last bar, and this has been a challenge to figure out how to do on the tick chart.

Here is some code:

Code: Select all

vars:
vTextID(0),
intrabarpersist vTickCount(0);
if barstatus(1)=2 then begin
vTickCount = 1500;
end;
vTickCount = vTickCount-1;
text_delete(vTextID);
vTextID = text_new(date,time,high,"<- " + numtostr(vTickCount,0));
Please draw a diagram.

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: Ticks Left Indicator

Postby KhaosTrader » 01 Jan 2013

Hi,

I just want a number of ticks left text box for the current bar which will be displayed to the right of the last bar.

User avatar
arnie
Posts: 1593
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 511 times

Re: Ticks Left Indicator

Postby arnie » 02 Jan 2013

Hi,

I just want a number of ticks left text box for the current bar which will be displayed to the right of the last bar.
It seems you want a counter.

Se if you find any here:

http://www.tradersxchange.com/viewforum ... 143302d322

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: Ticks Left Indicator

Postby KhaosTrader » 02 Jan 2013

Ok, i found this, and it looks good, however, if i put offset to "1" then it moves the counter way to far to the right , if i set it to 0, its right on the bar.... I want it just an inch or so to the right, I use a 1000 tick chart.

Here is the code..

Code: Select all


Input:
Offset(1),
bDrawClose(false),
ClosePriceDigits(2),
BarsBeforeClose(5);

input:
soundFile("c:\WINDOWS\Media\ding.wav"),
soundTrigger(1000);

VAR:
IntrabarPersist Bar_Number( 0 ),
IntrabarPersist Bar_Ticks ( 0 ),
TextID(0),
txt(""), snd_ret(true);

//***** Accumulate Intrabar Ticks *****
Bar_Ticks = Bar_Ticks + 1;

// ***** Reset Tick Count Each Bar *****
if BarNumber <> Bar_Number then
begin
Bar_Number = BarNumber;
Bar_Ticks = 0 ;
end; // reset each bar

value1 = BarInterval - Bar_Ticks;

if BarNumber = 1 then
TextID = Text_New(Date, Time, Close, NumToStr(value1, 0))
else
begin
txt = "< " + NumToStr(value1, 0);
if bDrawClose = true then txt = txt + ", " + NumToStr(close, ClosePriceDigits);
Text_SetString(TextID, txt);
Text_SetLocation(TextID, Date, Time + Offset, Close);
Text_SetStyle(TextID, 0, 2);

if value1 <= BarsBeforeClose then
Text_SetColor(TextID, Green)
else
if value1 < BarInterval/3 then
Text_SetColor(TextID, Yellow)
else
if value1 < 2*BarInterval/3 then
Text_SetColor(TextID, LightGray)
else
Text_SetColor(TextID, DarkGray);

if value1 = soundTrigger and soundFile <> "" then snd_ret = PlaySound(soundFile);
end;

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: Ticks Left Indicator

Postby KhaosTrader » 02 Jan 2013

thanks arnie for the link, lots of interesting code there :)

User avatar
arnie
Posts: 1593
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 481 times
Been thanked: 511 times

Re: Ticks Left Indicator

Postby arnie » 02 Jan 2013

Ok, i found this, and it looks good, however, if i put offset to "1" then it moves the counter way to far to the right , if i set it to 0, its right on the bar.... I want it just an inch or so to the right, I use a 1000 tick chart.
See if this suit your needs:

On line 32 you have:

Code: Select all

txt = "< " + NumToStr(value1, 0);
change it to:

Code: Select all

txt = spaces(offset) + "<" + NumToStr(value1, 0);
Also, on line 36 you have:

Code: Select all

Text_SetLocation(TextID, Date, Time + Offset, Close);
Change it to:

Code: Select all

Text_SetLocation(TextID, Date, Time, Close);
Set the space you want by continuing using the Offset input.

KhaosTrader
Posts: 186
Joined: 10 May 2012
Has thanked: 14 times
Been thanked: 11 times

Re: Ticks Left Indicator

Postby KhaosTrader » 05 Jan 2013

ok i added spaces, and that works, thank you.

However, i am noticing that the tick count is not right, that it sometimes doesnt "fire every tick" or something, not sure why that is.

User avatar
Andrew MultiCharts
Posts: 1587
Joined: 11 Oct 2011
Has thanked: 931 times
Been thanked: 558 times

Re: Ticks Left Indicator

Postby Andrew MultiCharts » 07 Jan 2013

However, i am noticing that the tick count is not right, that it sometimes doesnt "fire every tick" or something, not sure why that is.
Update on Every Tick and Skip Identical Ticks features may affect your indicator calculation.


Return to “MultiCharts”