This lesson will show you how to draw an horizontal line that starts at a particular bar in the past and ends at the last bar. The line will show the last 25 bars low (25 is approx. a month). - First we need to calculate the 25 bars low using the "llv" function - Next we need to get the low at the last bar and this is done using the "lastvalue" function - Next we will add a condition that will return the low if the analyzed bar is within the last 25 bars or zero otherwise - Next we will convert each zero into NaN (Not a numeric) so that the line is not displayed at any bar that has zero as value For the above step, you will need to download the following function: ZeroToNan - Finally, we will plot the line and give it a red color using the "plot" function Here is the complete code: a = llv(low, 25); a = lastvalue(a); a = iff(count() > TotalBars() - 25, a, 0); a = zerotonan(a); plot(a, "", colorRed);
|
|