K
In the August issue of MSTT I explained one method that should allow you to do what you want. The only drawback that I can see is that the line would have to be dotted (bottom of the available Styles list) so as not to create additional clutter. There are two things that my approach would need.
1. Clearly defined events to trigger each line segment.
2. Clearly defined values at which to plot the line.
I envisage a single bar event being used to trigger an alert, thus providing the device to set the length of the line. ValueWhen(1, event, price) could then be used to set the price for the line. These signals could then be combined to plot the line value for the required number of bars and zero for all other bars.
If(Alert( event, {plot} periods), ValueWhen(1, event, line), 0);
What you have at this point is a plot that switches between line value and zero. Unfortunately the signal you now have cannot be scaled to the price chart because it will distort that chart, as well as plot zero many bars. The trick to keeping your plot scaled to price without distortion is to generate an N/A plot as the last indicator output. ValueWhen(1,1=0,0) will do the trick nicely. This expression cannot plot anything because 1=0 is never TRUE and so never provides an event to kick start ValueWhen().
Here's a working example based on a PS Trading System pivot low pattern.
periods:=5;
event:=L<Ref(H,-2) AND Ref(L,-1)>Ref(L,-2) AND
Ref(L,-3)>Ref(L,-2) AND Ref(L,-4)>Ref(L,-2);
line:=ValueWhen(1,event,Ref(L,-2));
If(Alert( event, {plot} periods), ValueWhen(1, event, line), 0);
ValueWhen(1,1=0,0);
I said to start with that you'd need to use a dotted line. This is necessary to blank out the sections of line where it moves from zero to price or price to zero.
If you want to see what happens without the last line of code, just put braces around it. Hope this helps.
Roy
MetaStock Tips & Tools