|
|
weekly pivot point moving average indicator
Last post 03-26-2008, 3:16 by sennal999. 22 replies.
-
06-15-2007, 13:00 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
weekly pivot point moving average indicator
Please help to develop a moving average indicator as below;
weekly pivot point = ( weekly high + weekly low + end of the week close)/3
3 period weekly pivot point average = (1st week pivot point + 2nd week pivot point + 3rd week pivot point )/3
Thanks.
|
|
-
06-16-2007, 17:45 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: weekly pivot point moving average indicator
Lamkeng
Try this indicator. Notice that it uses the Forum DLL which is available from the files section of this forum. Hope this helps.
Roy
MetaStock Tips & Tools
|
|
{Weekly Pivot Point SMA}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2004-2007}
{User settings}
N:=Input("Weekly Pivot Point SMA, Periods",1,99,3);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Weekly frame timing}
{* Day counter from metastock@wabbit.com.au}
M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();
Y:=Year()+4800-A;B:=M+(12*A)-3;
M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045;
{*}I:=Int(M/7);
I:=I-ValueWhen(2,1,I);
G:=LastValue(Lowest(Sum(I>0,5))=5);M:=G+I;
F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=Alert(A,2)*(A=0);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Calculate weekly HLC prices}
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
PP:=(K+Hw+Lw)/3;
{Calculate and plot SMA of weekly pivot points}
J:=J>0; X:=Cum(J*PP);
(X-ValueWhen(N+1,J,X))/N;
|
|
|
-
06-17-2007, 8:42 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
Re: weekly pivot point moving average indicator
|
-
06-17-2007, 8:43 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
Re: weekly pivot point moving average indicator
Roy,
Thanks for your help.
![Smile [:)]](/emoticons/emotion-1.gif)
Regards,
lamkeng
|
|
-
06-17-2007, 9:23 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
Re: monthly pivot point moving average indicator
Roy,
Thanks a lot for your help , once again I need your help to develop a moving average indicator as below;
monthly pivot point = ( monthly high + monthly low + end of the month close)/3
3 period monthly pivot point average = (1st month pivot point + 2nd month pivot point + 3rd month pivot point )/3
![Smile [:)]](/emoticons/emotion-1.gif)
Thanks.
lamkeng
|
|
-
06-18-2007, 16:24 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: monthly pivot point moving average indicator
Lamkeng
Try this. You'll need the Forum DLL with this indicator as well.
Roy
MetaStock Tips & Tools
|
|
{Monthly Pivot Point SMA}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2004-2007}
{User settings}
N:=Input("Monthly Pivot Point SMA, Periods",1,99,3);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Monthly frame timing}
D:=DayOfMonth();M:=Month();Y:=Year();
A:=ValueWhen(1,Cum(1)=1,Y);
M:=(Y-A)*12+M;I:=M-ValueWhen(2,1,M);
G:=LastValue(Lowest(Sum(I>0,5))=5); M:=G+I;
F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=Alert(A,2)*(A=0);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Calculate monthly HLC prices}
Hm:=HighestSince(1,M,H);
Hm:=ValueWhen(1,J,If(J=1,Hm,ValueWhen(2-G,1,Hm)));
Lm:=LowestSince(1,M,L);
Lm:=ValueWhen(1,J,If(J=1,Lm,ValueWhen(2-G,1,Lm)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hm:=ValueWhen(1,Hm>0,Hm);
Lm:=ValueWhen(1,Lm>0,Lm);
{Calculate and plot monthly pivot point SMA}
PP:=(K+Hm+Lm)/3;
J:=J>0; X:=Cum(J*PP);
(X-ValueWhen(N+1,J,X))/N;
|
|
|
-
06-18-2007, 18:12 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
Re: monthly pivot point moving average indicator
Roy,
Thank you very much . What is the different between static , dynamic and delay mode ? Thanks.
from
lamkeng
|
|
-
06-19-2007, 9:20 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
Re: monthly pivot point moving average indicator
Roy,
Thank you very much . I know what is the different between static , dynamic and Delayed already.
thanks.
from
lamkeng
|
|
-
06-19-2007, 12:52 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: monthly pivot point moving average indicator
Hi Lamkeng
I was about to post the following reply when the forum crashed yesterday. It might help someone else so I'll post anyway.
"Static" reports end-of-month (or end-of-week) values on the last bar of month when possible, otherwise on the first bar of the next month. If you had a month with only 1 EOD bar the end-of-month values for that month could not be reported by the indicator until the beginning of the following month. This would be a rare situation but certainly not unheard of. Note that "Static" does not update on the very last bar of a chart.
"Dynamic" is the same as "Static" except that the current (last) month is plotted dynamically as the month is formed with each EOD bar. The indicator updates the current month as each new bar is added, whereas "Static" cannot update until the first bar of a new month is in place (this only applies to the last bar).
"Delayed" holds reporting of results from every month until the first bar of the new month. Think of it as Dynamic mode delayed by one EOD bar.
These options give you choices about how you use the indicators for display, back test or explorations. For example, Dynamic is probably most useful when plotting on a chart. However, when back testing you might want to set to Delayed mode so that there's no danger of trading end-of-frame values (say the end-of-month CLOSE) before that information is actually available. If a trading system buys and sells with a 1-bar delay then there's no need to use the Delayed mode.
Roy
MetaStock Tips & Tools
|
|
-
06-24-2007, 17:59 |
-
lamkeng
-
-
-
Joined on 06-16-2007
-
-
Posts 10
-
-
|
Moving average 3 days cross over 7 days in a bullish trend
Roy,
Pls advise me on how to develop a sorting criteria for Metastock software for stocks based on Moving average 3 days cross over 7 days in a bullish trend.
Thanks.
lamkeng
|
|
-
07-28-2007, 0:04 |
-
aksh
-
-
-
Joined on 01-21-2007
-
-
Posts 6
-
-
|
Re: Moving average 3 days cross over 7 days in a bullish trend
Hello everyone,
Mr. Roy Larsen is a gem of a person, always ready to help people out. I'm speaking from personal experience.
arun
|
|
-
01-12-2008, 0:16 |
-
mahen1602
-
-
-
Joined on 01-11-2008
-
-
Posts 7
-
-
|
Help in metastock built in formula
HELLO SIR,
HOW CAN I INSTALLED IN MY METASTOCK BUIT IN YOUR weekly pivot point moving average indicator MS FORMULA.
>> Hello sir, >> i mahendra from India-maharastra-mumbai >> >> 1) 5day swing( 5 HHigh Close crossoverclose, 5 LLow croseover >> close) >> >>1) expert advice in 5 day sing in Buy & Sell Signal. >> >> please see this link in amibroker chart in 5 day swing >> http://www.vfmdirect.com/nl/index.shtml >> >> please help me replyme >> mahendra bhavsar.mono :- 91-22-9423226169 >> email:- parulmumbai@yahoo.com > > please request you only one formula built me sir please, & expert with buy -sell signal.
your sent formula is i copy & pest in built indicater & expert in my mstock. >
|
|
-
01-13-2008, 12:39 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: Help in metastock built in formula
Mahen
Sorry, I don't understand your question.
Roy
|
|
-
03-02-2008, 12:53 |
-
sennal999
-
-
-
Joined on 07-30-2007
-
-
Posts 9
-
-
|
Re: weekly pivot point moving average indicator
Dear mstt,
Please help me to develop for DAY PIVOT MOVING AVERAGE INDICATOR WITH MOVING AVERAGE 3 AND 5
Advance Thanks.
senthil kumar.M
|
|
-
03-05-2008, 11:39 |
-
sennal999
-
-
-
Joined on 07-30-2007
-
-
Posts 9
-
-
|
Re: weekly pivot point moving average indicator
Dear mstt,
I have coded this formula. Is it correct?
{Daily Pivot Point SMA}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2004-2007}
{User settings}
N:=Input("Daily Pivot Point SMA, Periods",1,99,3);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Daily frame timing}
{* Day counter from metastock@wabbit.com.au}
M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();
Y:=Year()+4800-A;B:=M+(12*A)-3;
M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045;
{*}I:=Int(M/7);
I:=I-ValueWhen(2,1,I);
G:= LastValue(Highest(Sum(DayOfWeek()<>
ValueWhen(2,1,DayOfWeek()),5))=5);
F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=Alert(A,2)*(A=0);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Calculate weekly HLC prices}
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
PP:=(K+Hw+Lw)/3;
{Calculate and plot SMA of daily pivot points}
J:=J>0; X:=Cum(J*PP);
(X-ValueWhen(N+1,J,X))/N;
REGARDS
SENTHIL KUMAR.M
|
|
-
03-05-2008, 16:10 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: weekly pivot point moving average indicator
Hi Senthil
There is a problem with your adaptation of my Weekly Pivot Point SMA to a daily version for use on intraday charts. I suspect that the problem is in the frame timing module. Never mind because here’s a version that should work properly (it does work for me on a test chart).
The commented last line of code can be enabled and used to check against the result from the nominal output (previous active line). This is done by switching your chart from Intraday to Daily and noting that one plot covers the other (both should have the same value or be so close that it doesn’t matter). As a further check I suggest that you read off the last 5 to 10 indicator values when the chart is set to Daily, then switch to Intraday and verify that the same 5 to 10 last values are observed.
Roy
MetaStock Tips & Tools
{Daily Pivot Point SMA 2008}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2004-2008}
{User settings}
N:=Input("Daily Pivot Point SMA, Periods",1,99,3);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Daily frame timing}
{* Day counter from metastock@wabbit.com.au}
M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();
Y:=Year()+4800-A;B:=M+(12*A)-3;
M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045;
{*}
I:=M-ValueWhen(2,1,M);
B:=I=1 AND Max(Hour(),Minute())=0;
G:=LastValue(Highest(Sum(I>0,5))=5);
I:=I AND B=0 OR ValueWhen(2,1,B); M:=G+I;
F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=Alert(A,2)*(A=0);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Calculate daily HLC prices and pivot point}
Hd:=HighestSince(1,M,H);
Hd:=ValueWhen(1,J,If(J=1,Hd,ValueWhen(2-G,1,Hd)));
Ld:=LowestSince(1,M,L);
Ld:=ValueWhen(1,J,If(J=1,Ld,ValueWhen(2-G,1,Ld)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hd:=ValueWhen(1,Hd>0,Hd);
Ld:=ValueWhen(1,Ld>0,Ld);
PP:=(K+Hd+Ld)/3;
{Calculate and plot SMA of daily pivot point}
J:=J>0; X:=Cum(J*PP);
(X-ValueWhen(N+1,J,X))/N;
{Daily chart pivot point SMA check}
{Mov(Typical(),N,S);}
|
|
-
03-06-2008, 0:25 |
-
mahen1602
-
-
-
Joined on 01-11-2008
-
-
Posts 7
-
-
|
Re: weekly pivot point moving average indicator
To enable us to provide more efficient support, use the "Reply" feature in your email program when responding to this email. Please send unrelated issues in a new email.
----------------------------------------------------------------------- Dear Mahendra Bhavsar Thank you for contacting MetaStock support, my name is William and I will be taking ownership of your issue today. Here are the pivot point formulas you asked for. Daily: new:=ROC(DayOfWeek(),1,$)<>0; yh:=ValueWhen(1,new, Ref(HighestSince(1,new,H),-1)); yl:=ValueWhen(1,new, Ref(LowestSince(1,new,L),-1)); yc:=ValueWhen(1,new, Ref(C,-1)); pp:=(yc+yh+yl)/3; r1:=(pp*2)-yl; s1:=(pp*2)-yh; r2:= pp+r1-s1; s2:= pp-r1+s1; r3:= pp+r2-s2; s3:= pp-r2+s2; r3; r2; r1; pp; s1; s2; s3; Weekly: new:=ROC(DayOfWeek(),1,$)<0; yh:=ValueWhen(1,new, Ref(HighestSince(1,new,H),-1)); yl:=ValueWhen(1,new, Ref(LowestSince(1,new,L),-1)); yc:=ValueWhen(1,new, Ref(C,-1)); pp:=(yc+yh+yl)/3; r1:=(pp*2)-yl; s1:=(pp*2)-yh; r2:= pp+r1-s1; s2:= pp-r1+s1; r3:= pp+r2-s2; s3:= pp-r2+s2; r3; r2; r1; pp; s1; s2; s3; Monthly: new:=ROC(Month(),1,$)<>0; yh:=ValueWhen(1,new, Ref(HighestSince(1,new,H),-1)); yl:=ValueWhen(1,new, Ref(LowestSince(1,new,L),-1)); yc:=ValueWhen(1,new, Ref(C,-1)); pp:=(yc+yh+yl)/3; r1:=(pp*2)-yl; s1:=(pp*2)-yh; r2:= pp+r1-s1; s2:= pp-r1+s1; r3:= pp+r2-s2; s3:= pp-r2+s2; r3; r2; r1; pp; s1; s2; s3; Please contact us if there is anything further we can help you with, have a nice day! Thank You,
|
|
-
03-18-2008, 4:09 |
-
sennal999
-
-
-
Joined on 07-30-2007
-
-
Posts 9
-
-
|
Re: weekly pivot point moving average indicator
Dear mstt,
kindly help me to code exploration formula for DAILY PIVOT POINT SMA PERIOD 5, DYNAMIC, crosses WEEKLY PIVOT POINT SMA 3, DYNAMIC and MONTHLY PIVOT POINT SMA 2 , DYNMIC.
THANKS
SENTHIL KUMAR.M
|
|
-
03-18-2008, 14:15 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: weekly pivot point moving average indicator
Hi Senthil
I need more information before I can consider your request. What do you mean by “dynamic”? I know what it means when used in my code but I’m not sure that your meaning is the same. Also, a “cross” of one signal above two others very rarely occurs on one bar. What would be more realistic to search for is a cross of the faster signal across the higher of the two slower signals. Other cross possibilities would perhaps need to be allowed a range of bars in which to check for successive crosses. Limiting to multiple crossovers on the same bar is not a particularly useful exercise so can you be more specific about this. Is you base data EOD or intraday?
Regards
Roy
|
|
-
03-18-2008, 23:47 |
-
sennal999
-
-
-
Joined on 07-30-2007
-
-
Posts 9
-
-
|
Re: weekly pivot point moving average indicator
Dear mstt,
I am using these indicators on EOD charts. which one is usefull for EOD chart. dyanamic or static?
I don't have a clear view on that.
My strategy is buy = if daily pivot sma crosses over both weekly and monthly pivot sma .
sell = if daily pivot sma crosses over both weekly and monthly pivot sma.
I am using daily pivot sma for intraday.
Thanks
Senthil kumar.M
|
|
-
03-19-2008, 22:53 |
-
mahen1602
-
-
-
Joined on 01-11-2008
-
-
Posts 7
-
-
|
Re: weekly pivot point moving average indicator
Weekly:
new:=ROC(DayOfWeek(),1,$)<0;
yh:=ValueWhen(1,new, Ref(HighestSince(1,new,H),-1));
yl:=ValueWhen(1,new, Ref(LowestSince(1,new,L),-1));
yc:=ValueWhen(1,new, Ref(C,-1));
pp:=(yc+yh+yl)/3;r1:=(pp*2)-yl;s1:=(pp*2)-yh;
r2:= pp+r1-s1;s2:= pp-r1+s1;r3:= pp+r2-s2;
s3:= pp-r2+s2;
r3;r2;r1;pp;s1;s2;s3;
|
|
-
03-24-2008, 16:34 |
-
mstt
-
-

-
Joined on 07-26-2005
-
-
Posts 299
-
-
|
Re: weekly pivot point moving average indicator
Hi Senthil
Static and Dynamic settings both plot historical weekly values as soon as Friday data is available. Dynamic differs on the week currently being formed in that it updates on each day of the week, thus returning a dynamic (changing) value until Friday data completes the current week. For example, the weekly close would be updated on the last bar as each day’s data is added. The Dynamic setting is most appropriate when weekly indicator is used visually on EOD charts.
The Static setting is more appropriate for system tests, remembering that that each weekly close becomes available only with the Friday close. In many cases it would be desirable to use the Static setting with a 1-bar delay. The Delayed mode provides this by holding off the weekly update until Monday data is available, i.e. the presence of Monday data is used to signal that the week ended on the previous bar. The Delayed setting is ideal for system testing and prevents the possible use of future data that could otherwise occur with carelessly written formulas.
Either the Static or Dynamic settings can be used at the weekend (after Friday data is added) for explorations requiring weekly data. I suggest you only use the Static setting for explorations during the week.
I suggest you use Mov(Typ(),5,S) on your EOD charts as the 5-period SMA of the pivot point (assuming pivot point is (H+L+C)/3). You could then monitor for this crossing above the higher of the weekly/monthly pivot point SMAs with something like this...
{Pivot Point Cross}
Pds:=Input("EOD Pivot Point Smoothing",1,10,5);
Wsma:=Fml("Weekly Pivot Point SMA");
Msma:=Fml("Monthly Pivot Point SMA");
Cross(Mov(Typ(),Pds,S),Max(Wsma,Msma));
To prevent errors when creating this indicator make sure that the weekly and monthly pivot point SMAs are created first.
{Weekly Pivot Point SMA}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2004-2008}
{User settings}
N:=Input("Weekly Pivot Point SMA, Periods",1,99,3);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Weekly frame timing}
{* Day counter from metastock@wabbit.com.au}
M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();
Y:=Year()+4800-A;B:=M+(12*A)-3;
M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045;
{*}I:=Int(M/7);
I:=I-ValueWhen(2,1,I);
G:=LastValue(Lowest(Sum(I>0,5))=5);M:=G+I;
F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=Alert(A,2)*(A=0);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Calculate weekly HLC prices}
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
{Calculate and plot SMA of weekly pivot points}
PP:=(K+Hw+Lw)/3;
J:=J>0; X:=Cum(J*PP);
(X-ValueWhen(N+1,J,X))/N;
{Monthly Pivot Point SMA}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2004-2008}
{User settings}
N:=Input("Monthly Pivot Point SMA, Periods",1,99,2);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1);
{0, update at last bar of current frame}
{1, update on each new bar}
{2, update on first bar of new frame}
{Monthly frame timing}
D:=DayOfMonth();M:=Month();Y:=Year();
A:=ValueWhen(1,Cum(1)=1,Y);
M:=(Y-A)*12+M;I:=M-ValueWhen(2,1,M);
G:=LastValue(Lowest(Sum(I>0,5))=5); M:=G+I;
F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=Alert(A,2)*(A=0);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Calculate monthly HLC prices}
Hm:=HighestSince(1,M,H);
Hm:=ValueWhen(1,J,If(J=1,Hm,ValueWhen(2-G,1,Hm)));
Lm:=LowestSince(1,M,L);
Lm:=ValueWhen(1,J,If(J=1,Lm,ValueWhen(2-G,1,Lm)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Hm:=ValueWhen(1,Hm>0,Hm);
Lm:=ValueWhen(1,Lm>0,Lm);
{Calculate and plot monthly pivot point SMA}
PP:=(K+Hm+Lm)/3;
J:=J>0; X:=Cum(J*PP);
(X-ValueWhen(N+1,J,X))/N;
| | |