Gamestudio Links
Zorro Links
Newest Posts
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/10/26 12:46
phantom() not defined in indicators.c
by jcl. 08/07/26 11:45
Pause button for evaluation shell?
by jcl. 08/07/26 11:43
Accepting new programming clients
by AndrewAMD. 08/06/26 21:25
Fun Arcade Car Physics (nfs style)
by Ezzett. 08/02/26 21:11
ZorroGPT
by TipmyPip. 07/31/26 22:56
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (Quad), 5,787 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
ParkerBlair, JackWalker, riggi89, shuhari, KD1990
19225 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: 28,131
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,131
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: 28,131
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,131
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 | 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