How to plot a stock using different periods in the same chart
Updated on 2012-06-28 10:50:31
|
This article will show you how to display the same stock or security on two different panes where each pane uses its own period.
Steps:
- Open a new chart then create a new pane
- Right click on the second pane then select "Edit Formula"
- Type the following formula then click on "Update Graph"
period = 3600; // One hour (3600 seconds)
close1 = TimeframeCompress(TimeframeGetSeries(period, close, LastData));
open1 = TimeframeCompress(TimeframeGetSeries(period, open, LastData));
high1 = TimeframeCompress(TimeframeGetSeries(period, high, LastData));
low1 = TimeframeCompress(TimeframeGetSeries(period, low, LastData));
PlotCandleStick1(open1, high1, low1, close1, "Timeframe: ".period, colorBlack, StyleSymbolNone);
If your have an intraday period in your chart then this formula will plot a one-hour Japanese candlestick graph.
The first line gets the period in seconds (1h = 60 * 60 = 3600 seconds)
The four next lines calculate the close, open, high, low fields in the new time frame. This is achieved by getting the new period data using "TimeframeGetSeries" then compressing it with "TimeframeCompress".
More info about this can be found here: Technical Analysis Using Multiple Timeframes
Finally, the last line plots the Japanese candlestick graph using the special function "PlotCandleStick1".
|