Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 9/4/2005(UTC) Posts: 2
|
Hi,
is there any way to gain access to the index (k=1,....,periods) within the summation function to run calculations like sum(C*k, periods) ?
Have been searching in various places and hope I don't bother the forum too much with this question.
Thanks!
Reinhard
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 9/8/2004(UTC) Posts: 2,266
Was thanked: 1 time(s) in 1 post(s)
|
Wienke,
I might not have understood your request, I'm having some reading problems lately :D
Try this :
sum(C*cum(1), periods)
Patrick :mrgreen:
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 9/4/2005(UTC) Posts: 2
|
Patrick,
thanks a lot and sorry the question had not been clear and explained in better way.
What I would need to do is to perform a calculation possibly using sum() that actually uses the index (=number) of the added elements.
E.g. A weighted summation over 3 periods (k=1,2,3) -> sum(k/periods * C, periods). In effect it should calculate the following: 1/3 * C + 2/3 * C + 3/3 * C for each value of the custom indicator.
Have not figured out how to use cum(1) in this context as cum(1) will give me the n-th index order from the start of the chart. I would need the index values (1,2,3) as abovefrom the start of the summation.
Hope this may help to clarify my question. Thank you.
Reinhard Wienke
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Reinhard, try this MS code:
[code:1:69b9c5846e]
================
Summation Index
================
---8<-----------------------
{ Summation index, aka % Exponential Moving Avg}
{ ©Copyright 2005 Jose Silva }
{ For personal use only }
{ josesilva22@yahoo.com }
{ User Inputs }
wght:=Input("Weighting 0~100%",
0,100,66.666667)/100;
x:=Input("use Open=1 High=2 Low=3 Close=4 WClose=5 MP=6",1,6,4);
{ Select price field }
x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,WC(),If(x=6,MP(),C)))));
{ Exponential %-weighted Moving Average }
Ema:=x*wght+PREV*(1-wght);
{ Plot on price chart }
Ema
---8<-----------------------
[/code:1:69b9c5846e]
jose '-)
http://www.metastocktools.com
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.