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
Number of Consecutive Trading Bars Condition was True
This function calculates the maximum number of consecutive bars that a condition was true in the past N-bars. The function name is "MaxConsecutiveBars" and it has two parameters: Condition and period.
As an example, if we use this function with "close > sma(30)" condition and 100 as a lookback period, the function will return, for each bar, the longest period where price was above its 30-bar simple moving average in the past 30 bars.
Other examples:
rule = MaxConsecutiveBars(close > open, 50);
Returns the maximum consecutive number of times the stock or asset closed up in the past 50 days.
rule = MaxConsecutiveBars(volume > ref(volume, 1), 100) < 4;
Returns true if the volume didn't increase more than 3 times in a row during the past 100 days.
rule = MaxConsecutiveBars(close > sma(30), 30) == 30;
Returns true if price was above its moving average in the last 30 days. This trading formula is equivalent to: istrue(close > sma(30), 30)
rule = MaxConsecutiveBars(rsi(14) > 70, 60) < 3;
In the past 60 days, the Relative strength index (RSI) never stayed above level 70 more than 2 days/bars in a row.