Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 652 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How is trima calculated #439811
04/10/14 12:09
04/10/14 12:09
Joined: May 2013
Posts: 245
S
swingtraderkk Offline OP
Member
swingtraderkk  Offline OP
Member
S

Joined: May 2013
Posts: 245
Hi jcl,

How is zorro's trima calculated?

I've been reading a lot on other forums about TMAs, and specifically how some peek into the future. i.e. using your example of the trima from the manual,
Quote:
the weights for a 7 period Triangular Moving Average would be 1, 2, 3, 4, 3, 2, 1. This gives more weight to the middle of the time series. It causes better smoothing, but greater lag.

the result given in those TMAs is not assigned to barindex 0, but to barindex 3 i.e. the center of the triangle.

1) Can you confirm that zorro's trima calculates the averages with the triangular weights but assigns the result to the most recent bar.

2) Clearly the other tmas cannot actually see the future, so their calculation at bar 0 is simply a linear weighted moving average of half the length of the trima, and all values at period +1 back are fine as they can access both sides of the triangle to get their values, but as the barindex goes from the period to zero, the triangular trima moves from being triangular to being linear. This is the claimed benefit of the TMAs as this process is a form of prediction of where the TMA is going next, and users of the TMA claim that it is the slope of the TMA that is useful. Can zorro replicate this type of recalculation of past indicator values using its series()?

3) If the past values are recalculated what will show on zorro's plots? I suspect that only the first calculated value will show.

4) If it is simply the slope of the TMA that is important, is the following easy way to program this in zorro correct?

Code:
var TMAslope(vars input, int period)

{
	var tma0		= WMA(input,period/2);
	int denom;
	var num;
	var tma1;
	int i;
	
	i=0;
	denom=0;
	num=0;
	tma1=0;
	
	for (i=1; i<=period/2; i++)
	{
		denom	+= i;
		int k	=  (period/2+1)-i;
		num	+= (input[k]*i);
		
		
	} 
	
	denom = denom+1;
	num	= num+input[0];
	
	var tma1	= num/denom;
	
	
	return (tma0 - tma1)/ATR(100);
}


Re: How is trima calculated [Re: swingtraderkk] #439974
04/14/14 06:53
04/14/14 06:53
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, the triangular sum of the last 7 bars is assigned to the recent bar. What you describe in 2) sounds like a "repainting" indicator. You could program this of course, but it makes no sense for automated trading. None of Zorro's included indicators repaints or peeks into the future.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1