This is a trading item or a component that was created using QuantShare by one of our members.
This item can be downloaded and used by QuantShare Trading Software.
Trading items are of different types. There are data downloaders, trading indicators, trading systems, watchlists, composites/indices...
You can use this item and hundreds of others for free by downloading QuantShare.
Top Reasons Why You Should Use QuantShare:
Works with US and international markets (stock, forex, options, futures, ETF...)
Offers you the tools that will help you become a profitable trader
Allows you to implement any trading ideas
Exchange items and ideas with other QuantShare users
Our support team is very responsive and will answer any of your questions
We will implement any features you suggest
Very low price and much more features than the majority of other trading software
Probably the most popular trading indicator is the moving average. It is widely used in technical analysis and several other indicators use it in their calculation. For each bar, the moving average indicator calculates the average price of a time-series over the preceding N-bars.
The function name is 'rbsma', which stands for 'rule-based simple moving average'. This type of moving average does not calculate an average value of the last N-bars, but for N-bars that satisfy a specific rule.
Here is an example:
Let us say we want to calculate the average close price of for the last five Monday bars. We then should take the last five bars (bars that occurred on Monday) and calculate the average. Then repeat the process for all the available trading bars.
To do this with the 'rbsma' function, you will need to type:
rbsma(close, DayOfWeek() == 1, 5, 25);
The first parameter is the close price series.
The second parameter is the filter rule. It instructs the application to take into consideration only bars whose 'DayOfWeek' value is equal to one, which is Monday.
The third parameter is the number of occurrences to use in the moving average calculation.
The last parameter value defines the maximum number of bars to look for. A low value could result in the 'rbsma' function not finding the five occurrences where the filter rule passed. This could result in the calculation of a moving average with less than five values.
This doesn't mean that that you should put a very high value in this parameter to avoid this kind of problem. A high value generally needs more computation time and more time to calculate the function.
Here are some other examples:
rbsma(close, rsi(14) > 50, 20, 50);
This moving average rule returns the average close price for bars where the security price relative strength index indicator is above 50.
rbsma(volume, close > ref(close, 1), 20, 50);
This moving average rule returns the average volume for bars where the stock or security price closed higher than yesterday's value.
rbsma(volume, close > ref(close, 1), 20, 50) > rbsma(volume, close < ref(close, 1), 20, 50)
This is a moving average rule that returns one on bars where the average volume for the last 20 occurrences where the security price closed higher is greater than the average volume for the last 20 occurrences where the security price closed lower.
To use the 'rbsma' function as a classic moving average, you just need to set the rule formula to '1'.
rbsma(close, 1, 14, 14) is equal to sma(close, 14)
This function can also be modified to return another rule-based indicator; that is, an indicator that uses bars that pass a specific rule.
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.