Click here to Login




How to create market indicators using the composite function - Part 2

Updated on 2010-08-24






After introducing the "Count" and "Sum" calculation methods and how to use them in order to create market indicators (Market Indicators), we will continue our presentation with a new type in the composite function.

The "Avg" calculation method calculates the average number of the different values of the provided time series or indicator. Internally, this method simply calculates the sum of the time series values that occurred on the same date and also keeps track of the number of these values. At the end, the function divides the sum that was calculated first by the number of values.
The "Avg" function is very powerful and it can be used in different ways to calculate composites and indices. Almost any kind of market indices can be created by applying the composite function with the "Avg" calculation method; this includes capitalization-weighted indices (such as the S&P 500 or Russell 2000), equal-weighted indices, fundamental-weighted indices and volume-weighted indices.

Here are some market indicator examples:

Comp(rsi(14), "avg")
This trading indicator calculates the average RSI or relative strength index value of all stocks or securities included in the analysis. You can then compare this composite to the oversold or overbought threshold levels and determine whether the market is bullish or bearish based on the relative strength index interpretation.

Comp(sma(30), "avg")
The above indicator returns the average 30-bar simple moving average of all your stocks. This can be used for example by calculating another composite that returns the average 60-Bar simple moving average and then comparing both values. The signal the market generates is bullish if the first moving average is higher than the second one -> Comp(sma(30), "avg") > Comp(sma(60), "avg")

Comp(close > ref(close, 1), "avg")
Used with the "sum" function, this formula would have returned the number of advancing stocks. However, with the "avg" function, the formula returns the percentage of advancing stocks or the proportion of stocks that are advancing among stocks included in the analysis (Backtesting, Screening, Rules analyzing...)

The next trading indicator assumes you have a fundamental database that contains the market capitalization data for all of your stocks. Note that you can also use this function if you only have the number of outstanding shares data; this is because the market capitalization of a stock is equal to its share price multiplied by the number of outstanding shares.

Comp(GetData("fund", "mkcap") * close, "avg")
Here is how to create a capitalization-weighted market index. Take the time-series that corresponds to the market capitalization data of your stock and then multiply that value with the close price. Applying the composite's average method to this formula produces our custom capitalization-weighted index.


In composite calculations, the "Avg" function is one of the most powerful tools to create different and various market indices or composites. The composite plug-in still has many other calculation methods; we will see that in a future post.











no comments (Log in)

QuantShare Blog
QuantShare
Search Posts




QuantShare
Recent Posts

Create Graphs using the Grid Tool
Posted 1449 days ago

Profile Graphs
Posted 1554 days ago

QuantShare
Previous Posts

Correlation of market indicators
Posted 5308 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.