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
|