Click here to Login

Trading Software Trading objects Features How-to Blog Search



Moving Average: Rule-based

by The trader, 758 days ago
Share |

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.


Share This ->
Share |


You have to log in to bookmark this object
What is this?
Additional Information



>>>> More trading objects? click here to search for trading sytems, downloaders, screens, custom drawing tools, indicators... by country, market or style.

>>>> To get this item and hundreds of other items, click here to join and download the Best Trading Software for Free .



No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Write a review no reviews Number of downloads 8 downloads Notes Report an item


Type: Trading Indicator

Object ID: 324


Country:
All

Market: All

Style:
Technical Analysis




Related Trading Objects



Country
Page 1
Trading the Equity Curve
by QuantShare, uploaded several months ago


No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads 4 Notes Report an item
Opening Range Breakout Indicator
by QuantShare, uploaded several months ago
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads 3 Notes Report an item
Wilder's Smoothing - Moving Average
by QuantShare, uploaded several months ago
No notes

Rate an item Rate an item Rate an item Rate an item Rate an item Number of downloads 9 Notes Report an item
Number of reviews
Click to add a review
Average rate
Click to rate this item
Number of times this object was downloaded
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object









Join now
and get instant access for free to the trading software, the Sharing server and the Social network website.
Click here


Related objects

Empty

Number of reviews
Click to add a review
Average rate
Click to rate this item
Number of times this object was downloaded
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object

Technical Analysis


Fundamental Analysis


Forum Threads



Random Blog Posts

Stock split & dividend

Survivorship bias

Transaction Costs

How scripts communicate with each other

How to simulate options strategies

Organizing Trading Objects

Creating a download item: Initial Jobless Claims

How to search for a download item

Show All

Number of reviews
Click to add a review
Average rate
Click to rate this item
Number of times this object was downloaded
Number of rates the current object received
Report an object
if you can't run it for example or if it contains errors
Click to report this object






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

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