How to plot two different time frames in the same chart
Updated on 2012-02-18 04:11:47
|
Steps:
- Open a new chart by selecting "View" then "New Chart"
- Select "Daily" time frame (Bottom-Left corner)
- Right click on the chart then select "Create new pane"
- Right click on the new pane then select "Edit Formula"
We will use the "Timeframeapply" function to plot the close series in a different time frame (weekly for example)
This function gets two arguments:
Argument 1: The time frame to apply. When using EOD data, specify the number of days (Example: 7 for weekly) and when using intraday data, specify the number of seconds (Example: 60 for minute bars)
Argument 2: Time-series to calculate in the specified time frame
Example:
a = Timeframeapply(7, close);
Plot(a, "TF7", colorBlack, chartLine, StyleSymbolNone);
Click on "Update Graph" to apply the formula. You will see on the chart that the daily and weekly close time series are not synchronized. In fact, the variable returned by "Timeframeapply" is compressed; you must decompress it in order to synchronize the dates of both time series.
a = Timeframeapply(7, close);
a = Timeframedecompress(a);
Plot(a, "TF7", colorBlack, chartLine, StyleSymbolNone);
You can reference EOD data from intraday charts by specifying a negative value in the time frame argument of the "Timeframeapply" function. (Example: -1 to get daily data)
|