How to adress the LAST TICK close ?

Questions about MultiCharts and user contributed studies.
User avatar
ym
Posts: 53
Joined: 26 Feb 2010

How to adress the LAST TICK close ?

Postby ym » 17 Jul 2010

Assuming IOG is ON, how can I adress the LAST TICK CLOSE in the current tick calculations ?
Apparently, if I use close[1] it will address the LAST BAR CLOSE, but this is not what I want ...
---
Even if I use an IntrabarPersist variable like in the following example:

Code: Select all

IntrabarPersist MovAvg(0);
MovAvg=Xaverage(price, 12);
Print(MovAvg[0] + "/" + MovAvg[1]);
The MovgAvg[1] value always pertains to the LAST BAR MovAvg value!!!
How can I get the LAST TICK MovAvg value ?

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Postby Dave Masalov » 23 Jul 2010

Dear ym,

Please try the following code:

Code: Select all

IntrabarPersist MovAvg(0), IntrabarPersist MovAvg_prev(0);

MovAvg=Xaverage(price, 12);

Print(MovAvg + "/" + MovAvg_prev);

MovAvg_prev = MovAvg;

User avatar
ym
Posts: 53
Joined: 26 Feb 2010

Postby ym » 23 Jul 2010

it works fine.
thx

janus
Posts: 838
Joined: 25 May 2009
Has thanked: 64 times
Been thanked: 105 times

Postby janus » 24 Jul 2010

Be careful though. Under certain circumstances the study will be repeated extra times for the same tick. See:

http://forum.tssupport.com/viewtopic.ph ... highlight=

User avatar
ym
Posts: 53
Joined: 26 Feb 2010

Postby ym » 24 Jul 2010

Thx for the warning, Janus.

I read you whole thread with this 'repeated first bar' issue when iog is on....
The real-time features of either MC and WINDOWS are effectively quite questionable ...

It reminds me of a currently pending issue that I once raised here :
http://forum.tssupport.com/viewtopic.ph ... ght=update
and that has still not been fully answered.

When a slower timeframe (say data2 : 5mn) is referenced in a strat that applies to a 1mn chart (data1), then the slower timeframe (5mn) is not updating correctly ...

data2 updating correctly on each tick of data1 at 18H45
1100310-1845 - close data1(1mn): 1.36360 - close data2(5mn): 1.36360
1100310-1845 - close data1(1mn): 1.36358 - close data2(5mn): 1.36358
1100310-1845 - close data1(1mn): 1.36358 - close data2(5mn): 1.36358
1100310-1845 - close data1(1mn): 1.36357 - close data2(5mn): 1.36357
1100310-1845 - close data1(1mn): 1.36357 - close data2(5mn): 1.36357

data2 NOT updating correctly on each tick of data1 at 18H46, or 18H49
1100310-1846 - close data1(1mn): 1.36353 - close data2(5mn): 1.36354
1100310-1846 - close data1(1mn): 1.36352 - close data2(5mn): 1.36354
...
1100310-1849 - close data1(1mn): 1.36397 - close data2(5mn): 1.36354
1100310-1849 - close data1(1mn): 1.36397 - close data2(5mn): 1.36354
1100310-1849 - close data1(1mn): 1.36399 - close data2(5mn): 1.36354

then data2 will update correctly again at 18H50 ... !!!
then data2 will be stuck again at 18H52 ... or 18H53 ...


I don't know if this issue relates to the one you raised with the 'repeated first bar' ... but it definitely is a real-time problem for intrabar-oriented code.

TSS is aware of that point and is supposed to work on it in a next version, but maybe you have an idea ... ?

janus
Posts: 838
Joined: 25 May 2009
Has thanked: 64 times
Been thanked: 105 times

Postby janus » 24 Jul 2010

I don't see how the two problems could be related but it's possible. Only TSS can answer that question. It is just as serious and should be fixed ASAP, if not immediately.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How to adress the LAST TICK close ?

Postby JoshM » 24 May 2011

How can I get the LAST TICK MovAvg value ?
My custom indicator updates on every tick, but how can I access the last tick value (on historical data)?

I've already tried Last, which gives zeros, and Close, which gives the close of the bar (if used with BarStatus = 2) otherwise also an zero. Is there any other function for this that I'm not aware off? Any suggestions would be highly appreciated. :)

Here's what I have so far:

Code: Select all

vars: intrabarpersist barHigh(0),
intrabarpersist barLow(0),
lastTick(0);

if CurrentBar = 1 then
ClearDebug;

//lastTick = Last; // Gives zero values
lastTick = Close; // Gives zero values

If BarStatus(1) = 0 then begin // If the tick is the first of the bar, initialize the values to the first tick for comparison purposes
barHigh = lastTick;
barLow = lastTick;
end;

if BarStatus(1) = 1 then begin // If the tick lays inside the bar, compare the values
if lastTick > barHigh then
barHigh = lastTick;
if lastTick < barLow then
barLow = lastTick;
end;

If BarStatus(1) = 2 then begin // Print the values when the bar had closed
Print(date:6:0, "-", time:4:0, " high of bar: ", barHigh:3:3, " low of bar: ", barLow:3:3, " close at: ", Close:3:3);
barLow = 0;
barHigh = 0;
end;
(I know that High and Low also give these values - I've just chosen them here to easily compare them to the chart).

The above code gives me the following output:

Code: Select all

1110516-1608 high of bar: 0.000 low of bar: 0.000 close at: 107.415
1110516-1609 high of bar: 0.000 low of bar: 0.000 close at: 107.420
1110516-1620 high of bar: 0.000 low of bar: 0.000 close at: 107.420
1110516-1623 high of bar: 0.000 low of bar: 0.000 close at: 107.420
1110516-1629 high of bar: 0.000 low of bar: 0.000 close at: 107.425
1110516-1630 high of bar: 0.000 low of bar: 0.000 close at: 107.420
1110516-1645 high of bar: 0.000 low of bar: 0.000 close at: 107.415

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

Re: How to adress the LAST TICK close ?

Postby TJ » 24 May 2011

How can I get the LAST TICK MovAvg value ?
My custom indicator updates on every tick, but how can I access the last tick value (on historical data)?

I've already tried Last, which gives zeros, and Close, which gives the close of the bar (if used with BarStatus = 2) otherwise also an zero. Is there any other function for this that I'm not aware off? Any suggestions would be highly appreciated. :)

Here's what I have so far:
....
LAST is for quote field use only.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How to adress the LAST TICK close ?

Postby JoshM » 24 May 2011

LAST is for quote field use only.
Thanks TJ for your quick response. Yes I know, Last is for real-time only. That's why I explicitly stated in my question that I used historical data. So practically I'm looking for an 'Last' function which works the same on historical data as the (normal) Last function works on real-time data, so that I can calculate with the ticks that run through the indicator when backtesting. Perhaps I could have explained that better in my initial post.

Regards,

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

Re: How to adress the LAST TICK close ?

Postby TJ » 24 May 2011

LAST is for quote field use only.
Thanks TJ for your quick response. Yes I know, Last is for real-time only. That's why I explicitly stated in my question that I used historical data. So practically I'm looking for an 'Last' function which works the same on historical data as the (normal) Last function works on real-time data, so that I can calculate with the ticks that run through the indicator when backtesting. Perhaps I could have explained that better in my initial post.

Regards,
I did not say it is for real time only.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: How to adress the LAST TICK close ?

Postby JoshM » 24 May 2011

I did not say it is for real time only.
True. Yet I don't understand it.

If Last is an quote field (like you said and the manual confirms), but quote fields cannot be referenced historically (according to the manual and seemingly confirmed by all the zeros I keep getting), but they are not for real-time only (implying they can also be used for something different, such as historically?), how can Last (being a quote field) be referenced historically?

Would you care to elaborate and help this beginner out? :)

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

Re: How to adress the LAST TICK close ?

Postby TJ » 24 May 2011

I did not say it is for real time only.
True. Yet I don't understand it.

If Last is an quote field (like you said and the manual confirms), but quote fields cannot be referenced historically (according to the manual and seemingly confirmed by all the zeros I keep getting), but they are not for real-time only (implying they can also be used for something different, such as historically?), how can Last (being a quote field) be referenced historically?

Would you care to elaborate and help this beginner out? :)
I did not say it is not for real-time only.


Return to “MultiCharts”