This screen shot shows the TypicalPrice indicator plotted on a daily chart. We are interested in having this indicator show on the most recent 10 bars of a chart (cyan), and erasing the indicator beyond the 10th bar (yellow).
Fig. 1. Chart showing unwanted portion of indicator plot in yellow
To erase the portion of the indicator shown in yellow, we can plot over the original plot with a second plot command, replacing the color with the background color (black) as follows:
This produces the chart shown below:
Fig. 2. Unwanted portion of plot overplotted in black to hide original plot
This chart contains an undesirable result in that the overplotted indicator leaves a trail of black lines passing through the candlestick bodies and tails. To improve the appearance of an erased indicator, the indicator can be shifted from its original value to a value that is beyond the range of the candlestick bodies and tails. However, it is preferable not to shift the original indicator more than necessary to prevent the chart from rescaling the vertical axis and shrinking or compressing the price action. It is also desirable to make the shifted plot as narrow as possible to avoid overplotting and covering over any more of the small dots comprising the chart grid that necessary.
A convenient function to use to produce the desired shift is the fast calculation version of the Lowest Low function, LowestFC:
Using a DisplaceLength of 15 (greater than the length of the price that we desire to display, PriceLength = 10), produces the chart below:
Fig. 3. Chart with unwanted portion of plot displayed entirely below the bar lows
And finally, we change the color of the original function that has been shifted away from the candlestick bodies and tails to match the background color of the chart (black), producing:
Fig. 4. Displayed unwanted portion of plot is now overplotted in black, producing final desired hidden result
This leaves a chart with minimal evidence that a indicator has been erased.
The reserved word transparent was introduced to Easylanguage in version 9.0 providing an simpler method to erase a plot:
Note that the second line over-writes PriceLength bars back from the current bar effectively making invisible whatever was plotted by the first statement.
The final code may be visualized by clicking the PlotErase Indicator link below.
Initial posted version: 01/02/08
Latest Update: 01/31/10
*.ELD files are compiled for TS 8.7
All ELD and code text files packaged here:
Users of earlier versions of Tradestation may compile the code
from the text files included in the above *.zip file.
The code may be visualized here: