How to plot arrows below/above candlesticks on a chart
Updated on 2012-02-11 03:08:10
|
In order to add arrows on a chart, you have to update the chart's formula.
Steps:
- Right click on a chart then select "Edit Formula"
- "PlotArrow" is the function we must use to plot arrows
PlotArrow Parameters:
Time-Series: Plots an arrow above/below a candlestick when the value of the time series is different from zero
Description: Text to display above/below arrows
TopBottom: A constant that specify whether to plot the arrows below or above candlesticks
Color: The color used to draw the different arrows
Example:
cross1 = cross(sma(10), sma(30));
PlotArrow(cross1, "Last Cross: ".barssince(cross1[1]), AboveHigh, colorRed);
The above example plots an arrow on the bar where the 10-bar simple moving average (SMA) crosses above the 30-bar SMA.
Above each arrow, we display the number of bars since the last crossover. This is calculated using the "barssince" function and the "cross1" variable one bar ago (cross1[1]).
If you want to create arrows with different colors, you can call the "PlotArrow " function several times and use a different color each time.
Example:
Plots a green arrow when the stock is trading at a 75-bar high
Plots a red arrow when the stock is trading at a 75-bar low
PlotArrow(close == hhv(close, 75), "", AboveHigh, colorGreen);
PlotArrow(close == llv(close, 75), "", BelowLow, colorRed);
|