logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Spaceant  
#1 Posted : Friday, June 8, 2007 7:31:01 AM(UTC)
Spaceant

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2005(UTC)
Posts: 182

Hi,

I want to code an exploration to find out the rising stock, comparing today's close (Jun 8) versus a particular date, say May 31 2006. Well, I know that I can count the number of trading days betwenn the above days, say 200 (not a counted number), I can use the following code

Column A

ROC(C,200,%)

Filter

ColA>0

However, there are some securities with missing data between the dates due to various reasons (e.g. suspended trading, etc). the ROC with 200 periods will not always pointing to the specific date.

Any smarter way to code this?

Sa

*PP  
#2 Posted : Friday, June 8, 2007 11:08:40 AM(UTC)
*PP

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 4/1/2006(UTC)
Posts: 135
Location: Romania

Hey Gary,

I think this is what u are looking for:


perd1:=Input("Day",1,31,31);
perd2:=Input("Month",1,12,5);
perd3:=Input("Year",1900,2199,2006);
perd4:=
ValueWhen(1,(DayOfMonth()>=perd1 AND Month()=perd2 AND Year()=perd3),LastValue(Cum(1))-Cum(1));
perd5:=If(IsDefined(perd4),1,0);
perd:=LastValue(BarsSince(perd5=1 AND Ref(perd5,-1)=0));
end:=LastValue(Cum(1));
start:=BarsSince(Cum(1)=end-perd);
a1:=ValueWhen(1,start=0,C);
a2:=ValueWhen(1,start>=0 AND Cum(1),C);
a3:=(a2-a1)/a1*100;
a3

This indicator will show performance from specified date. Then u should only make an exploration with this indicator value in one of the columns.[:)]

Cheers

Spaceant  
#3 Posted : Saturday, June 9, 2007 12:20:04 AM(UTC)
Spaceant

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2005(UTC)
Posts: 182

Hi Paul,

Thanks! I think that is what I want and will test it.

Sa

HyperionAUT  
#4 Posted : Sunday, June 30, 2013 8:59:51 AM(UTC)
HyperionAUT

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 12/19/2012(UTC)
Posts: 54
Location: Austria

Hey..... I still try to make it work, but i can not figure it out.

Any suggestions, how to do it?

I similar look for a % return value if i wanna search for:

31.12.2009 to 30.10.2011 performance for all DOW stocks.

Kind regards,

Clemens

mstt  
#5 Posted : Sunday, June 30, 2013 3:39:00 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Normal 0 false false false MicrosoftInternetExplorer4

Hi Clemens

The code shown below is a mix of my Date Filter indicator and PP's solution to the original question in this thread. The indicator code is shown first. What this does is plot the percentage gain or loss starting from the Start date through to the end data, and it then holds the end date value through to the last bar of the current chart.

Exploration code follows the indicator. The number of bars loaded should be sufficient to generate a result from all securities with sufficient data. Any securities with insufficient data will report an N/A, but in any case the bar count in Column B will tell you the number of bars available for those securities. Column A will return the same result as the indicator unless insufficient bars are loaded.

I hope this is satisfactory.

Roy

Code:


 

{Indicator}

 

{Date Range Percentage Gain/Loss}

 

Sd:=Input("Start day" ,1,31,1);

Sm:=Input("Start
month",1,12,1);

Sy:=Input("Start year"
,1980,2015,2011);

Ed:=Input("End day" ,1,31,31);

Em:=Input("End month" ,1,12,12);

Ey:=Input("End year" ,1980,2020,2012);

Start:=(DayOfMonth()>=Sd AND

Month()=Sm AND Year()=Sy) OR
Year()>Sy OR

(Year()=Sy AND Month()>Sm);

End:=(DayOfMonth()<=Ed AND

Month()=Em AND Year()=Ey) OR
Year()<Ey OR

(Year()=Ey AND Month()<Em);

Range:=Start*(End OR
Start*Alert(Start=0,2));

Start:=Range*Alert(Range=0,2);

StartPrice:=ValueWhen(1,Start,C);

EndPrice:=ValueWhen(1,Range,C);

100*(EndPrice-StartPrice)/StartPrice;

 

 

{Exploration}

 

{Date Range Percentage Gain/Loss}

 

 {Column
A: PcntGain}

 

Sd:=31; {Starting day}

Sm:=12; {Starting month}

Sy:=2009;{Starting year}

Ed:=30; {Ending day}

Em:=10; {Ending month}

Ey:=2011;{Ending year}

Start:=(DayOfMonth()>=Sd AND

Month()=Sm AND Year()=Sy) OR
Year()>Sy OR

(Year()=Sy AND Month()>Sm);

End:=(DayOfMonth()<=Ed AND

Month()=Em AND Year()=Ey) OR
Year()<Ey OR

(Year()=Ey AND Month()<Em);

Range:=Start*(End OR
Start*Alert(Start=0,2));

Start:=Range*Alert(Range=0,2);

StartPrice:=ValueWhen(1,Start,C);

EndPrice:=ValueWhen(1,Range,C);

100*(EndPrice-StartPrice)/StartPrice;

 

 {Column
B: ScanBars}

Cum(1);

 

st1\:*{behavior:url(#ieooui) } /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}
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.