Consecutive count backtester / quantifytools- Overview
Consecutive counting is a simple method to mechanically define trending states to the upside and downside. Consecutive counts are calculated by taking reference price level (e.g. close 4 candles ago) and count closes above/below it up to a maximum count that resets the consecutive count back to 1. This tool provides the means to backtest each count by measuring % change in price after each count (e.g. % gain 2 candles after a given count).
Users can define reference source that starts the consecutive count (e.g. close 4 candles ago), maximum count where counter resets (e.g. after 9th count) and backtesting period (e.g. price change 2 candles after count).
Filters add extra conditions that must be met on the consecutive count to qualify as valid, which are also reflected on the backtest metrics. The counts can be refined using the following filters:
- RSI above/below X
- Price above/below/at moving average of choice
- Relative volume above/below X
Average gain corresponding to each count as they occur can be toggled off for less clutter. Average price change can also be visualized using candle color. Colors, gradient and table/label sizes are fully customizable.
- Practical guide
Example #1: Identify reversal potential
Consecutive counting is a simple yet effective method to for detecting reversals, for which 7-9 counts are traditionally used. Whether that holds true or not can now be put through a test with different variations of the method as well as using additional filters to improve the probability of a turn.
Example #2: Identify trend following potential
Consecutive counts can also have utility value for trend following. When historical short term change is to the downside, expect downside, when to the upside, expect upside.
Consecutive
Candles - 2 or 3 consecutive pattern + Custom pips thresholdFEATURES:
- Detect a 2 or 3 consecutive candlestick pattern. Input the value into the first input value.
- Choose the minimum and the maximum amount of pips of the candle that you want to detect. The indicator will detect candles within that pips range and highlight the consecutive pattern
- Choose to not use the pips threshold. If disabled the indicator will constantly check for consecutive candles pattern.
- Choose if calculate pips taking into consideration OC (Open - Close of candles - Body) or HL (High - Low - Body + Wick)
VISUALS:
- Enable Boxes: when enabled a box is drawn around the pattern detected
- Enable Lines: when enabled lines from top/bottom/mid of the boxes are drawn
- Extend the lines
BuP = Bullish Pattern
BeP = Bearish Pattern
AIM:
The aim of the indicator was to spot 2 common patterns in one indicator: Three White Soldiers and Three Black Crows
The rest is all implementation because I like coding.
Anyway on all timeframes 3 consecutive candles with a similar body length seems to be an alarm that Market Makers are joining the gfame before a major manipulation so it worth keep an eye on those.
From my experimentation from ltf 1 minute timeframe to htf 1H timeframe, 3 consecutive candles with a body length between 10 and 20 pips could be the ones to keep an eye on before a reversal or a strong continuation.
For sure they are zonez and levels where MM would come back later.
Adjust the settings as you want and happy trading!
This is just an indicator nothing more
Consecutive Unswept Lower Highs/ Higher Lows CounterCounts consecutive Lower Highs and Higher Lows; number resets to zero when previous pivot high or low gets swept
-To help give an idea of when a retracement / run-on-stops may be overdue. i.e. the higher the counter number grows, the longer we've gone without a proper retracement.
//inputs//
~pivot lookback/lookforward: increase this for more significant pivot highs and lows.
~number of pivot high 'counter' labels (pairs) to show in history.
~formatting options.
Consecutive positive/negative candlesConsecutive positive/negative candles
Shows the consecutive negative or positive candles
Determine Consecutive Candles█ OVERVIEW
This is a simple script that will plot labels over or under candles to show where there had been consecutive candles that closed in a similar fashion. This script was inspired by a Tweet about Bitcoin experiencing its first 7th-consecutive weekly black candle and I sought out to test that.
█ INPUTS
There are three inputs for this script.
"offset" ( integer ) - (Can be 0 or 1) Allows the user to apply this script at the currently closing candle or the most recently closed candle.
"Number of Candles" ( integer ) - (From 3 to 100*) Allows the user to select how many candles to back test for consecutive-ness.
"Black or White" ( boolean ) - Allows the user to select what kinds of candles to look for in this script. (true - Black , false - White ).
*Publishing open-sourced, this selection was arbitrary and can be modified at will.
█ USAGE
Because I had created this in a little over an hour, this is just a simple experiment that I wanted to share with others. Its applications are unknown to me, but I am interested in hearing how others may find what this script does useful.
Up/Down Long StrategyThis is a consecutive bar up/down strategy for going long only where you can specify how many bars up to buy and how many bars down to sell. It also has code to check and make sure the condition is still true when launching the official alert, which helps back testing and live results line up, however be sure to enter commission and slippage into the properties to accurately reflect profits. I added back testing date ranges to this so you can easily pull up and see back tested results for a certain date range. I also added a buy and sell message fields in the properties so you can launch alerts that will work with automated trading services. Simply enter your buy message and sell message into those fields in the properties and then when you create an alert enter {{strategy.order.alert_message}} into the alert body and it will dynamically pull in your buy and sell messages when it fires alerts.
Up/Down StrategyThis is a consecutive bar up/down strategy where you can specify how many bars up to buy and how many bars down to sell. It also has code to check and make sure the condition is still true when launching the official alert, which helps back testing and live results line up, however be sure to enter commission and slippage into the properties to accurately reflect profits. I added back testing date ranges to this so you can easily pull up and see back tested results for a certain date range. I also added a buy and sell message fields in the properties so you can launch alerts that will work with automated trading services. Simply enter your buy message and sell message into those fields in the properties and then when you create an alert enter {{strategy.order.alert_message}} into the alert body and it will dynamically pull in your buy and sell messages when it fires alerts.
Sequential Filter - An Original Filtering ApproachRemoving irregular variations in the closing price remain a major task in technical analysis, indicators used to this end mostly include moving averages and other kind of low-pass filters. Understanding what kind of variations we want to remove is important, irregular (noisy) variations have mostly a short term period, fully removing them can be complicated if the filter is not properly selected, for example we might want to fully remove variations with a period of 2 bars and lower, if we select an arithmetic moving average the filter output might still contain such variations because of the ripples in the frequency response passband, all it would take is a variation of high amplitude for that variation to be clearly visible.
Although all it would take for better filtering is a filter with better performance in the frequency domain (gaussian, Butterworth, Bessel...) we can design innovative approaches that does not rely on the model of classical moving averages, today a new technical indicator is proposed, the technical indicator fully remove variations lower than the selected period.
The Indicator Approach
In order for the indicator output to change the closing price need to produce length consecutive up's/down's, length control the variation threshold of the indicator, variations lower than length are fully removed. Lets see a visual example :
Here length = 3, the closing price need to make 3 consecutive up's/down's, when the sequence happen the indicator output is equal to src , here the closing price, else the indicator is equal to its precedent value, hence removing other variations. The value of 3 is the value by default, this is because i have seen in the past that the average smallest variations period where in general of 3 bars.
Because the indicator focus only on the variation sign, it totally ignore the amplitude of the movement, this provide an effective way to filter short term retracement in a fluctuation as show'n below :
The candle option of the indicator allow the indicator to only focus on the body color of a candle, thus ignoring potential gaps, below is an example with the candle option off :
If we activate the "candle" option we end up with :
Note that the candle option is based on the closing and opening price, if you use the indicator on another indicator output make sure to have the candle option off.
Length and Indicator Color
The closing price is infected by noise, and will rarely make a large sequence of consecutive up's/down's, the indicator can therefore be useful to detect consecutive sequence of length period, here 6 is selected on BTCUSD :
A consecutive up's/down's of period 6 can be considered a relatively rare event.
It is important to note that the color of the indicator used by default has nothing to do with the consecutive sequence detected, that is the indicator turning red doesn't necessarily mean that a consecutive down's sequence has occurred, but only that this sequence has occurred at a lower value than the precedent detected sequence. This is show'n below :
In order to make the indicator color based on the detected sequence check the "Color Based On Detected Sequence" option.
Conclusion
An original approach on filtering price variations has been proposed, i believe the indicator code is elegant as well as relatively efficient, and since high values of length can't really be used the indicator execution speed will remain relatively fast.
Thanks for reading !
Consecutive Candle Count Momentum StrategyVery simple strategy based on consecutive candle count. Simple but can be very profitable if you know how to execute.
Example:
- Buy when consecutive up closes exceeds 3
- Sell when consecutive down closes exceeds 3
For a buy signal, if price closes higher within 5 candles, it is defined as a win.
For a sell signal, if price closes lower within 5 candles, it is defined as a win.
Win rates for buy/sell signals are calculated over history of security.
Moving Average Consecutive Up/Down Strategy (by ChartArt)This simple strategy goes long (or short) if there are several consecutive increasing (or decreasing) moving average values in a row in the same direction. The bars can be colored using the raw moving average trend. And the background can be colored using the consecutive moving average trend setting. In addition a experimental line of the moving average change can be drawn.
The strategy is based upon the "Consecutive Up/Down Strategy" which was created by Tradingview.
All trading involves high risk; past performance is not necessarily indicative of future results. Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown.
Custom Indicator Clearly Shows If Bulls or Bears are in Control!The Two Versions of this Indicator I learned from Two Famous and Highly Successful Traders. This Indicator shows With No Lag Clear Up and Down Trends in Market by Documenting Clearly If Bulls or Bears are in Control. The Version In SubChart 1 Shows Consecutive Closes if the Current Close is Greater than of Less than the Midpoint of the Previous Bar (Why Midpoint Explained in Detail in 1st Post). The Version in SubChart 2 Shows Consecutive Closes that are Greater than or Less Than the Previous Close (Will Discuss Specific Uses in 1st Post). Works on Stocks, Forex, Futures, on All Timeframes.