November 14, 2007
Selected Date Range
A bar range, for processing, can be stipulated at the formula level.
The following code plots the Close, over a four month period, using the DateNum function (BarIndex can also be used in a similar way).
1 2 3 4 5 6 7 8 9 10 | //P_SelectedRange ///////////Plot a selected date range in the middle of chart using BarIndex or DateNum //Plot(IIf(BarIndex() >= 978 AND BarIndex() <= 988,C,Null),"",1,1); Plot(IIf(DateNum() >= 1050101 AND DateNum() <= 1050430,C,Null),"",1,1); ///////////Plot a selected range at the end of a chart LastBarIndex = LastValue(BarIndex()); //Plot(IIf(BarIndex() >= LastBarIndex - 10 AND BarIndex() <= LastBarIndex(),C,1)," ",8,1); //Plot(IIf(BarIndex() >= LastBarIndex - 10,C,1)," ",8,1); |

If the last line of code is uncommented the Close,for the last 10 bars only, will be plotted.
The formula can be adapted for use in other modes (filter, scan etc).
ATTACHED FILE:
Filed by brian_z at 9:43 pm under AFL - The Basics


(2 votes, average: 4 out of 5)