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

Notification

Icon
Error

Options
Go to last post Go to first unread
kskdut  
#1 Posted : Wednesday, March 27, 2013 11:56:01 PM(UTC)
kskdut

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/12/2013(UTC)
Posts: 2

hi

I want to plot a horizontal line using code, with fixed start dates and end dates (multiple date inputs options and marked by different colors for identifying them separately)


mstt  
#2 Posted : Thursday, March 28, 2013 12:58:49 AM(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)

Hi K

The start date for a line can be set by by using something like my Date Filter, normally a filter that is TRUE between two dates and FALSE before the start date and after the end date.

The next step in the process is to use the date filter to trigger the Condition parameter of a ValueWhen() function. See the line of code below. and in completed form in the code box further down.

ValueWhen(1, Fml("Date Filter"), "your line value");

The third part of the process is to count the bars from where the Date Filter goes from TRUE to FALSE (the end date) through to the last bar. The number this generates is used to "shuffle" the result from ValueWhen() above first to the right and then to the left (innermost delaying Ref() function first). This shuffle converts all trailing bar results to N/A - one Ref() function delays your signal by "Shuffle" bars and the other Ref() then returns the signal plot back to its original position, but with everything after the end date which now returns N/A instead of a valid plot.

It's up to you to figure out how to compact the code and make multiple lines. I suspect you might need to create a template for the multiple colored line segments that you're asking for..

If earlier segments of the line are to be overwritten by later segments then output them first so that the lines to be partially covered precede (as outputs) the lines that overwrite them.


Code:

 
 {Date Filter Adaptation}
 {Roy Larsen, 2003-2013}

Sd:=Input("Start day" ,1,31,1);
Sm:=Input("Start month",1,12,1);
Sy:=Input("Start year" ,1980,2015,2013);
Ed:=Input("End day" ,1,31,15);
Em:=Input("End month" ,1,12,3);
Ey:=Input("End year" ,1980,2020,2013);
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);
D:=Start*(End OR (Start AND Alert(Start=0,2))); {Date Filter output}

Line:=ValueWhen(1,Cum(D)>0,25);
Shuffle:=LastValue(Cum(Cum(D)>0 AND D=0));
Ref(Ref(Line,-Shuffle),+Shuffle);


Roy
kskdut  
#3 Posted : Thursday, March 28, 2013 2:12:47 AM(UTC)
kskdut

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/12/2013(UTC)
Posts: 2

Thanks for your reply roy.

I want to create a template for the multiple colored line segments; I don’t want any inputs sections (as six are maximum options) in the code, as I prefer fixed start dates and end dates.

Like this :

Start:=(DayOfMonth()>=1 AND

Month()=1 AND Year()=2013) OR Year()>2013 OR

(Year()=2013 AND Month()>1);

End:=(DayOfMonth()<=15 AND

Month()=3 AND Year()=2013) OR Year()<2013 OR

(Year()=2013 AND Month()<3);

I want to put multiple lines(different dates with same value ) in that code .

ksk

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.