Click here to Login




Technical Analysis Using Multiple Timeframes - Second Part

Updated on 2010-03-24





If you have not yet read the first part of this article, please go to Technical Analysis Using Multiple Timeframes.

In the previous post, we introduced the "TimeframeSet" function, whose role is to instruct the trading software to use specific timeframe.
Here is an example:
technical analysis

Once you apply the new timeframe, subsequent calculations will be done using this timeframe. The third line in the above formula calculates the Relative Strength Index using a weekly period. The fourth and fifth lines use the "Plot" function to draw these two RSI vectors or time-series.
After using the "TimeframeSet" function, you can switch back to the default timeframe by calling the following function "TimeframeRestore();".

The next two functions we will introduce are used to compress and decompress time-series calculated using a different timeframe than the original one.
The first function, called “TimeframeDecompress”, decompresses a time-series and then returns it.
To see how it works, type the following line just after the relative strength index line (b = rsi(14);):
b = TimeframeDecompress(b);

This line decompresses the RSI vector and returns an uncompressed time-series. Here is how it looks like:
technical analysis - different timeframe

To get the opposite effect, that is, to compress a decompressed time-series, you should use a function whose name is 'TimeframeCompress'.
With a weekly compressed time-series, when you use the "ref" function with an argument of one to reference the previous bar, you will get the previous week value. However, if you use the "ref" function to get the previous bar of a decompressed weekly time-series, you will get either the current week value or the previous week value. It depends on the current bar date; if the current bar' day of week is Monday, then you will get the previous week value; in all other cases, you will get the current week value.

Now, we will introduce three timeframe-related functions that perform calculation in a specific timeframe and then returns a compressed time-series. The main advantage of using these functions is that the entire process is performed in a single line and thus these functions are well suited to create trading rules (For example, they can be used in the rules analyzer, screener, simulator...)

TimeframeGetSeries:
This function returns an array for the specified timeframe. The array could be a security's close price, open price, high price, low price, volume or open interest.

TimeframeGetSeries1:
This function is different from the first one in that it allows you to specify an external ticker symbol. You will get the close price, open price... for a custom timeframe and for the specified ticker symbol.
Example:
b = TimeframeGetSeries1("goog", 7, close, LastData);

This single line instructs the application to return the weekly Google stock's close price.

TimeframeApply:
This is certainly the most interesting function. With a single line, it allows you to change the timeframe of time-series.
Examples:
b = TimeframeApply(7, sma(close, 10));
Returns the weekly 10-bar simple moving average of the security's close price.

b = TimeframeApply(31, Macd());
Returns the monthly Moving Average Convergence/Divergence (MACD) of a stock.

The time-series that results from the "TimeframeGetSeries", "TimeframeGetSeries1" and "TimeframeApply" functions are compressed.











one comment (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1405 days ago

Profile Graphs
Posted 1510 days ago

QuantShare
Previous Posts

Short Index - Part 2
Posted 5334 days ago

Short Index - Part 1
Posted 5341 days ago

Historical Market Data
Posted 5362 days ago

Historical volatility estimators
Posted 5375 days ago

Short Selling Stocks
Posted 5383 days ago

Stock split & dividend
Posted 5389 days ago

Survivorship bias
Posted 5396 days ago


More Posts

Back







QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.