|
|
Plot indicators from a defined date
Last post 07-27-2006, 22:50 by Jose. 4 replies.
-
07-26-2006, 10:54 |
-
ageitalia
-
-
-
Joined on 06-16-2006
-
Italy
-
Posts 20
-
-
|
Plot indicators from a defined date
Take a security, whose you plot the latest 100 bars.
Then you plot a 20 days moving average and a 14 days RSI.
Well, it would be interesting to add a "show plotting since" function, in order to show on the chart just a fraction of various indicatos chosen.
Sometimes plotting different MAs and indicators could add some troubles and confusion; so it would be great to show 14-d RSI and 25-d MA for the latest 50 bars only, if requested by the user.
________________________ Gaetano Evangelista gae@ageitalia.net AGE Italia sas www.ageitalia.net www.smartTrading.it
|
|
-
07-26-2006, 14:48 |
-
hayseed
-
-
-
Joined on 03-07-2005
-
-
Posts 1,354
-
-
|
hey ageitalia.... you can plot from certain dates fairly easily..... the quick code below, with vast room for improvement, will plot rsi from date of your choosing.... same principle can be applied to moving averages..... wabbits dll will help on the ma's...... the date uses last 2 digits for year.... so feburary 28, 2006 would be input as 060228 or 60228...... h
Code: startdate:=Input("start plot date yymmdd",010101,101231,060403);
pds:=input("rsi periods",2,20,5);
date:=(Year()-2000)*10000 + Month()*100+ DayOfMonth();
30;50;70;
If(date>startdate,RSI(pds),50)
|
|
-
07-26-2006, 22:09 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
This "Display plot restriction" indicator is a code example for restricting output to a specific date range:
Code:
{Restricts plot display to selected date period.
©Copyright 2005~2006 Jose Silva.
The grant of this license is for personal use
only - no resale or repackaging allowed.
http://www.metastocktools.com }
{ Sample plot to restrict }
plot:=RSI(14);
{ Restrict date inputs }
StDay:=Input("start Day",1,31,1);
StMnth:=Input("start Month",1,12,1);
StYear:=Input("start Year",1800,2200,2006);
EnDay:=Input("end Day",1,31,31);
EnMnth:=Input("end Month",1,12,3);
EnYear:=Input("end Year",1800,2200,2006);
{ Selected date period }
start:=Year()>StYear
OR (Year()=StYear AND (Month()>StMnth
OR Month()=StMnth AND DayOfMonth()>=StDay));
end:=Year()<EnYear
OR (Year()=EnYear AND (Month()<EnMnth
OR Month()=EnMnth AND DayOfMonth()<=EnDay));
period:=start
AND (end OR (start AND Alert(start=0,2)));
{ Start/End signals }
start:=start AND Alert(start=0,2);
end:=PeakBars(1,period OR Cum(1)=2,1)=0;
{ Restrict plot to selected date }
pds:=LastValue(BarsSince(end));
restricted:=
Ref(Ref(plot,-pds),pds)*ValueWhen(1,start,1);
{ Plot in own window }
restricted
jose '-)
MetaStockTools.com
|
|
-
07-27-2006, 9:43 |
-
ageitalia
-
-
-
Joined on 06-16-2006
-
Italy
-
Posts 20
-
-
|
Re: Display plot restriction
Jose: This "Display plot restriction" indicator is a code example for restricting output to a specific date range:
Bravissimo!!!
and it can work with different indicators!
A very good work, just I suppose this task may be inserted in a future release of our beloved program...
Grazie ancora
P.S.: A little note: there's only a small bug in the code: it doesn't take into account the latest bar. The "end day" has to be the next to last bar (daily, weekly, etc.
________________________ Gaetano Evangelista gae@ageitalia.net AGE Italia sas www.ageitalia.net www.smartTrading.it
|
|
-
07-27-2006, 22:50 |
-
Jose
-
-

-
Joined on 01-20-2005
-
Koh Pha-Ngan, Earth
-
Posts 1,087
-
-
|
Display plot restriction v2.0
A small bug? C'mon... that's a feature! ;)
Code:
========================
Display plot restriction
========================
---8<-------------------------------------
{ Display plot restriction v2.0
Restricts plot display to selected dates.
©Copyright 2005~2006 Jose Silva.
The grant of this license is for personal use
only - no resale or repackaging allowed.
http://www.metastocktools.com }
{ Sample plot to restrict }
plot:=Mov(C,5,E);
{ Restrict date inputs }
StDay:=Input("start Day",1,31,1);
StMnth:=Input("start Month",1,12,1);
StYear:=Input("start Year",1800,2200,2006);
EnDay:=Input("end Day",1,31,31);
EnMnth:=Input("end Month",1,12,3);
EnYear:=Input("end Year",1800,2200,2006);
{ Selected date periods }
start:=Year()>StYear
OR (Year()=StYear AND (Month()>StMnth
OR Month()=StMnth AND DayOfMonth()>=StDay));
end:=Year()<EnYear
OR (Year()=EnYear AND (Month()<EnMnth
OR Month()=EnMnth AND DayOfMonth()<=EnDay));
{ Date signals }
date1:=start AND Alert(start=0,2);
date2:=end=0 AND Alert(end,2);
date2:=Zig(end AND Cum(1)>1,1,$)=1;
{ Restrict out of range date signals to chart }
start:=
If(LastValue(Cum(date1))>0,date1,Cum(1)=1);
end:=If(LastValue(Cum(date2))>0,date2,
LastValue(Cum(1))=Cum(1));
{ Restrict plot to selected date period }
pds:=LastValue(BarsSince(end));
restricted:=
Ref(Ref(plot,-pds),pds)*ValueWhen(1,start,1);
{ Plot in own window }
restricted
---8<-------------------------------------
jose '-)
MetaStockTools.com
|
|
|
|