Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
indicator of indicator, using series() #445761
09/23/14 16:05
09/23/14 16:05
Joined: Apr 2014
Posts: 45
Germany
webradio Offline OP
Newbie
webradio  Offline OP
Newbie

Joined: Apr 2014
Posts: 45
Germany
Intending two build a ten-period EMA of two-period ATR, is the following script an appropriate way?
Code:
var Ema_of_Atr(int Period)
{
	var *emaofatr = series(EMA(series(ATR(2)), 10));
	return *emaofatr;
}

I still have to get used to series()

Re: indicator of indicator, using series() [Re: webradio] #445764
09/23/14 17:36
09/23/14 17:36
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Almost. But you're returning a series, so you need to declare

var *Ema_of_Atr(int Period)

or

vars Ema_of_Atr(int Period)

Re: indicator of indicator, using series() [Re: jcl] #445768
09/23/14 20:29
09/23/14 20:29
Joined: Apr 2014
Posts: 45
Germany
webradio Offline OP
Newbie
webradio  Offline OP
Newbie

Joined: Apr 2014
Posts: 45
Germany
Thanks for explaination, jcl! Shoudn't it be one asterisk less then? Otherwise it attempts to return a double
Code:
return emaofatr;

After reading indicators.c, next question arose. Is there a valid reason at all, to return series when writing an indicator? Like intention of further processing? As far as I can see, all delivered indicators return double. So my script would shrink to
Code:
var Ema_of_Atr_simple()
{
	return EMA(series(ATR(2)), 10);
}

And yet another one, about TSI
Code:
// Trend Strength Index, from Engineering Returns 
var TSI(var* Data,int Period)
{
	var* ratio = series(abs(Data[0]-Data[Period])/ATR(Period),0);
	var* TSI = series(SMA(series(SMA(ratio,Period),0),10*Period),0);
	return *TSI;
}

As far as I can see it returns duble. Wouldn't it be simpler to
Code:
return SMA(series(SMA(ratio,Period),0),10*Period);


Re: indicator of indicator, using series() [Re: webradio] #445903
09/29/14 11:59
09/29/14 11:59
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You're right, I had not seen that you're returning the last value of the series only, so your original definition was correct - and the series is not needed at all when you only return its last element.


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