#twitter-follow { border: 0;position: fixed; top: 240px; left:0;} #live-support { border: 0;position: fixed; top: 370px; left:0;} #knowledge-base { border: 0;position: fixed; top: 170px; left:0;}

## Market Rule based on the Crossover Between Stock Close prices and their Moving Average

by Tom Huggens, 4877 days ago

This composite is calculated based on a trading rule involving the popular technical indicator: the simple moving average.

Here is how this composite is calculated: (This item requires an indicator that can be downloaded here Buy Indicator)
- Create a simple trading rule that returns a signal if the stock close price crosses above its 10-Bar simple moving average
- Using the "Buy Indicator", calculates the average return of a strategy that buys the stock if the above rule is bullish (true) and sells it after 10 days. The strategy is performed using data of the last 60 bars (days, hours, minutes...)
- Compare the strategy average return to zero by returning one (TRUE) if this return is higher than zero (SIGNAL2)
- Calculate the percentage of stocks that have a positive SIGNAL2 value. This is the value returned by this composite.

A value above 50% indicates that the strategy that consists of buying stocks when their close price crosses above their 10-Bar simple moving average is profitable on average for all stocks in the universe (Or stocks referenced by the composite).
You can also directly calculate the composite in a trading strategy (without creating a new symbol - _STRA_SMA). The advantage of using this method is that you can optimize the different values and see whether the market rule you are creating is profitable or not.
Example:
rule1 = comp((BuyInd(cross(close, sma(10)), 10, 50) > 0) * 100, "avg", 1, close > 2);

What is this?

 Type: Composite Index Object ID: 927 Country: All Market: Stock Market Style: Technical Analysis

 Related objects Empty
Number of reviews
Average rate
Click to rate this item
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

Number of reviews
Average rate
Click to rate this item
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