Rank: Newbie
Groups: Registered, Registered Users Joined: 10/15/2005(UTC) Posts: 2 Location: Lisboa, Portugal
|
I have the following Volume Weight Average Price code. However the programer defined the "Starting Month", "Starting day of Month", and " Starting Year" as variables that we must setup when we are applying the indicator on a chart.
I would like to know if it is possible to build the VWAP without this variables using, for example, by default a time period of the last 365 or 500 days (for calculation reasons). That will be more user friendly and also will allow us to use this indicator with the Metastock Explorer.
Can someone help me with this idea?
____________________________________________________________________________
Volume Weighted Average Price Code
sm:=Input("starting month",1,12,1);
sd:=Input("starting day of month",1,31,1);
sy:=Input("starting year",1980,2100,2000);
d1:= sd=DayOfMonth() AND sm=Month() AND sy=Year();
pv:=MP()*Cum(V);
denom:= If(Cum(V)-ValueWhen(1,d1,V)=0,1,Cum(V)-ValueWhen(1,d1,V));
If(BarsSince(d1),(pv)/denom, MP())
____________________________________________________________________________
|
|
|
|
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)
|
Try this indicator/exploration MS code:
[code:1:86722a8efc]pds:=252; { lookback *trading* periods }
signal:=Cum(1)=LastValue(Cum(1))-pds;
pv:=MP()*Cum(V);
denom:=Max(Cum(V)-ValueWhen(1,
signal OR Cum(IsDefined(pv))=1,V),1);
x:=pv/denom;
x
[/code:1:86722a8efc]
For a lookback using calendar days (instead of trading periods), you will need to incorporate the Day counter indicator into the MS code above.
jose '-)
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 10/15/2005(UTC) Posts: 2 Location: Lisboa, Portugal
|
José,
Many thanks for your help.
Your VWAP code is working very well. Your help was very important to me.
I wish you a very nice weekend!!
|
|
|
|
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.