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
For Free - No Credit Card Required
Percentage of Bars a Trading rule Generates Buy/Sell Signals
A trading rule has only two states, black or while, true or false. In a given period, the state of a trading rule could remain constant (true or false) or it could change one or several times from one state to another. During this period, it could be interesting to calculate the percentage of time (bars) where the trading rule was true; consequently we will also discover the percentage of trading bars where the trading rule was false.
This trading indicator allows you to perform such calculation for a given number of bars. The indicator function has two parameters. The first one takes the time series or trading rule that you want to analyze and the second parameter takes the number of trading bars that the indicator should analyze to compute the percentage of bars the trading rule was true or higher than zero.
For example, the following formula: PerValue(rsi(14) > 70, 30) calculates for each trading bar, the percentage of times the Relative Strength Index was higher than 70 during the last 30 bars. A value of 100 indicates that the RSI was always higher than 70 during the last 30 bars.
Here is another example:
PerValue(close > sma(10), 20)
This trading indicator returns the percentage of bars, during the previous 20 bars, where the provided trading rule returns a buy signal (may also be interpreted as a sell signal); that is the close price of an asset is higher than its 10-Bar simple moving average.