Hikkake Hunter 2.0This script serves as a successor to a previous script I wrote for identifying Hikkakes nearly two years ago.
The old version has been preserved here:
█ OVERVIEW
This script is a rework of an old script that identified the Hikkake candlestick pattern. While this pattern is not usually considered a part of the standard candlestick patterns set, I found a lot of value when finding a solution to identifying it. A Hikkake pattern is a 3-candle pattern where a middle candle is nested in between the range of the prior candle, and a candle that follows has a higher high and a higher low (bearish setup) or a lower high and a lower low (bullish setup). What makes this pattern unique is the "confirmation" status of the pattern; within 3 candles of this pattern's appearance, there must be a candle that closes above the high (bullish setup) or below the low (bearish setup) of the second candle. Additional flexibility has been added which allows the user to specify the number of candles (up to 5) that the pattern may have to confirm after its appearance.
█ CONCEPTS
This script will cover concepts mainly focusing on candlestick analysis, price analysis (with higher timeframes), and statistical analysis. I believe there is also educational value presented with the use of user-defined-types (UDTs) in accomplishing these concepts that I hope others will find useful.
Candlestick Analysis - Identification and confirmation of the patterns in the deprecated script were clunky and inefficient. While the previous script required the use of 6 candles to perform the confirmations of patterns (restricted solely to identifying patterns that confirmed in 3 candles or less), this script only requires 3 candles to identify and process patterns by utilizing a UDT representing a 'pattern object'. An object representing a pattern will be created when it has been identified, and fields within that object will be set for processing by the functions it is passed to. Pattern objects are held by a var array (values within the array persist between bars) and will be removed from this array once they have been confirmed or non-confirmed.
This is a significant deviation from the previous script's methods, as it prevents unnecessary re-evaluations of the confirmation status of patterns (i.e. Hikkakes confirmed on the first candle will no longer need to be checked for confirmations on the second or third; a pitfall of the deprecated version which required multiple booleans tracking prior confirmation statuses). This deviation is also what provides the flexibility in changing the number of candles that can pass before a pattern is deemed non-confirmed.
As multiple patterns can be confirmed simultaneously, this script uses another UDT representing a linked-list reduction of the pattern object used to process it. This liked-list object will then be used for Price Analysis.
Price Analysis - This script employs the use of a UDT which contains all the returns of confirmed patterns. The user specifies how many candles ahead of the confirmed pattern to calculate its return, as well as where this calculation begins. There are two settings: FROM APPEARANCE and FROM CONFIRMATION (default). Price differences are calculated from the open of the candle immediately following the candle which had confirmed the pattern to the close of the candle X candles ahead (default 10). ( SEE FEATURES )
Because of how Pine functions, this calculation necessitates a lookback on prior candles to identify when a pattern had been confirmed. This is accomplished with the following pseudo-code:
if not na(confirmed linked-list )
for all confirmed in list
GET MATRIX PLACEMENT
offset = FROM CONFIRMATION ? 0 : # of candles to confirm
openAtFind = open
percent return = ((close - openAtFind) / openAtFind) * 100
ADD percent return TO UDT IN MATRIX
All return UDTs are held in a matrix which breaks up these patterns into specific groups covered in the next section.
Higher Timeframes - This script makes a request.security call to a higher timeframe in order to identify a price range which breaks up these patterns into groups based on the 'partition' they had appeared in. The default values for this partitioning will break up the chart into three sections: upper, middle, and lower. The upper section represents the highest 20% of the yearly trading range that an asset has experienced. The lower section represents the trading range within a third (33%) of the yearly low. And the middle section represents the yearly high-low range between these two partitions.
The matrix containing all return UDTs will have these returns split up based on the number of candles required to confirm the pattern as well as the partition the pattern had appeared in. The underlying rationale is that patterns may perform better or worse at different parts of an asset's trading range.
Statistical Analysis - Once a pattern has been confirmed, the matrix containing all return UDTs will be queried to check if a 'returnArray' object has been created for that specific pattern. If not, one will be initialized and a confirmed linked-list object will be created that contains information pertinent to the matrix position of this object.
This matrix contains the returns of both the Bullish and Bearish Hikkake patterns, separated by the number of candles needed to confirm them, and by the partitions they had appeared in. For the standard 3 candles to confirm, this means the matrix will contain 18 elements (dependent on the number of candles allowed for confirmations; its size will range from 12 to 30).
When the required number of candles for Price Analysis passes, a percent return is calculated and added to the returnArray contained in the matrix at the location derived from the confirmed linked-list object's values. The return is added, and all values in the returnArray are updated using Pine's built in array.___ functions. This returnArray object contains the array of all returns, its size, its average, the median, the standard deviation of returns, and a separate 3-integer array which holds values that correspond to the types of returns experienced by this pattern (negative, neutral, and positive)*.
After a pattern has been confirmed, this script will place the partition and all of the aforementioned stats values (plus a 95% confidence interval of expected returns) related to that pattern onto the tooltip of the label that identifies it. This allows users to scroll over the label of a confirmed pattern to gauge its prior performance under specific conditions. The percent return of the specific pattern identified will later be placed onto the label tooltip as well. ( SEE LIMITATIONS )
The stats portion of this script also plays a significant role in how patterns are presented when using the Adaptive Coloring mode described in FEATURES .
*These values are incremented based on user-input related to what constitutes a 'negative' or 'positive' return. Default values would place any return by a pattern between -3% and 3% in the 'neutral' category, and values exceeding either end will be placed in the 'negative' or 'positive' categories.
█ FEATURES
This script contains numerous inputs for modifying its behavior and how patterns are presented/processed, separated into 5 groups.
Confirmation Setting - The most important input for this script's functioning. This input is a 'confirm=true' input and must be set by the user before the script is applied to the chart. It sets the number of candles that a pattern has to confirm once it has been identified.
Alert Settings - This group of booleans sets which types of alerts will fire during the scripts execution on the chart. If enabled, the four alerts will trigger when: a pattern has been identified, a pattern has been confirmed, a pattern has been non-confirmed, and show the return for that confirmed pattern in an alert. Because this script uses the 'alert' function and not 'alertcondition', these must be enabled before 'any alert() function call' is set in TradingView's 'alerts' settings.
Partition Settings - This group of inputs are responsible for creating (and viewing) the partitions that breaks the returns of the patterns identified up into their respective groups. The user may set the resolution to grab the range from, the length back of this resolution the partitions get their values from, the thresholds which breaks the partitions up into their groups, and modify the visibility (if they're shown, the colors, opacity) of these partitions.
Stats Settings - These inputs will drastically alter how patterns are presented and the resulting information derived from them after their appearance. Because of this section's importance, some of these inputs will be described in more detail.
P/L Sample Length - Defines the number of candles after the starting point to grab values from in the % return calculation for that pattern.
P/L Starting Point - Defines the starting point where the P/L calculation will take place. 'FROM APPEARANCE' will set the starting point at the candle immediately following the pattern's appearance. 'FROM CONFIRMATION' will place the starting point immediately following the candle which had confirmed the pattern. ( SEE LIMITATIONS )
Min Returns Needed - Sets how many times a specific pattern must appear (both by number of candles needed to confirm and by partition) before the statistics for that pattern are displayed onto the tooltip (and for gradient coloration in Adaptive Coloring mode).
Enable Adaptive Coloring - Changes the coloration of the patterns based on the bullish/bearishness of the specified Gradient Reference value of that pattern compared to the Return Tolerance values OR the minimum and maximum values of that specified Gradient Reference value contained in the matrix of all returns. This creates a color from a gradient using the user-specified colors and alters how many of the patterns may appear if prior performance is taken into account.
Gradient Reference - Defines which stats measure of returns will be used in the gradient color generation. The two settings are 'AVG' and 'MEDIAN'.
Hard Limit - This boolean sets whether the Return Tolerance values will not be replaced by values that exceed them from the matrix of returns in color gradient generation. This changes the scale of the gradient where any Gradient Reference values of patterns that exceed these tolerances will be colored the full bullish or bearish gradient colors, and anything in between them will be given a color from the gradient.
Visibility Settings - This last section includes all settings associated with the overall visibility of patterns found with this script. This includes the position of the labels and their colors (+ pattern colors without Adaptive Coloring being enabled), and showing patterns that were non-confirmed.
Most of these inputs in the script have these kinds of descriptions to what they do provided by their tooltips.
█ HOW TO USE
I attempted to make this script much easier to use in terms of analyzing the patterns and displaying the information to the user. The previous script would have the user go to the 'data window' side bar on TradingView to view the returns of a pattern after they had specified which pattern to analyze through the settings, needlessly convoluted. This aim at simplicity was achieved through the use of UDTs and specific code-design.
To use, simply apply the indicator to a chart, set the number of candles (between 2 and 5) for confirming this specific pattern and adjust the many settings described above at your leisure.
█ LIMITATIONS
Disclaimer - This is a tool created with the hopes of helping identify a specific pattern and provide an informative view about the performance of that pattern. Previous performance is not indicative of future results. None of this constitutes any form of financial advice, *use at your own risk*.
Statistical Analysis - This script assumes that all patterns will yield a NORMAL DISTRIBUTION regarding their returns which may not be reflective of reality. I personally have limited experience within the field of statistics apart from a few high school/college courses and make no guarantees that the calculation of the 95% confidence interval is correct. Please review the source code to verify for yourself that this interval calculation is correct (Function Name: f_DisplayStatsOnLabel).
P/L Starting Point - Because of when the object related to the confirmation status of a pattern is created (specifically the linked-list object) setting the 'P/L Starting Point' to 'FROM APPEARANCE' will yield the results of that P/L calculation at the same time as 'FROM CONFIRMATION'.
█ EXAMPLES
Default Settings:
Partition Background (default):
Partition Background (Resolution D : Length 30):
Adaptive Coloration:
Show Non-Confirmed:
Hunter
GAP HunterThis indicator shows the GAPs that are formed according to whether the opening price is above or below the rate specified in the selection box. An alarm can be set on these conditions.
Boom Hunter - Entry Point Screener AlertsStock screener for Boom Hunter and Boom Hunter Pro entry zones. This script will screen 18 different stocks for entry zones.
1. Enter in any ticker ID's from charts you wish to scan in the settings.
2. Go to desired timeframe.
3. Click add alert button at top toolbar.
4. Select Boom Screener indicator, input alert notification settings and/or change alert name and click create.
The script will then scan the stocks and alert you of any entry zones from the timeframe you set the alerts.
A new alert needs to be created for each timeframe you wish to screen.
Boom Hunter ProBoom Hunter Pro is the ultimate indicator for targeting perfect long entries and epic shorts. Boom Hunter comes with a super fast oscillator that uses Ehlers Early Onset Trend (EOT). This is the Center Of Gravity Oscillator (COG) with a super smoothing filter and a roofing filter. This indicator is tuned for 1 hour charts but can be used on any time frame.
Colored bars can be turned on to assist in finding an entry. Purple signifies a drag and potential dump.
Fibonacci lines can be turned on to track price action and find entries/exit.
This indicator follows the same rules as COG. For more information please see my COG HOWTO here:
Doji Hunter█ OVERVIEW
This script is built to search for 8 different Doji candlestick patterns in markets and makes them appear on screen with bar coloring and creating color-coded labels/shapes. It will identify the following variants based upon user input for various rules to abide by:
Gapping Up
Gapping Down
Gravestone
Dragonfly
Long-Legged
Rickshaw Man
Northern (Doji in uptrend)
Southern (Doji in downtrend)
Note: for the remainder of this description, the types for inputs will be marked by italic text.
█ OPTIONS
This script features a wide range of options available to the user to modify how it functions. The first set of inputs dictate how the trend analysis is done with moving averages. The second and third sets of inputs dictate specific rules for how Doji candles are analyzed and the colors used for when they appear.
█ INPUTS (short)
1 — Moving Average Rules:
The Northern and Southern Doji variants require some trend analysis which will be done by Moving Averages. The inputs in this section change various things about the moving average(s) to be used. In the second section of inputs, there is one boolean option that will nullify the need for trend detection and consolidates the Northern and Southern Doji variants into one.
2/3 — Doji Rules and Colors:
The next two sections of inputs correspond to the various rules that dictate how various doji variants will be analyzed, as well as the colors that correspond to each variant. The colors will also apply to each of the labels/shapes used.
4 — Diagnostics:
The last boolean will allow the user to see extra detail with regards to how and when dojis are detected. Note: This is not a part of any prior section and is simply included as a last functional item to the list of all inputs.
An example of multiple labels being shown on screen for various types of Dojis (DJI 1D chart):
█ INPUTS (extended)
1 — Moving Average Rules:
This section consists of 10 different inputs specific to the rules on how the moving average functions for trend analysis.
"Trend Rule" ( string list) determines which Moving Average will be used for trend detection. It has 3 options: "MA 1", "MA 2", or "BOTH". The second input "Trend Source" determines which OHLC (or combination) value to use in comparison to either MA 1 or MA 2 (EX: Trend Rule -> "MA 1" and Trend Source -> "close": if close > MA 1 -> uptrend, downtrend otherwise). If "BOTH" is selected then "Trend Source" is ignored and added nuance in the script ensures that the shorter MA being above the longer MA yields an uptrend (downtrend otherwise).
The next 8 inputs focus on 4 different parts of both MA 1 and 2.
Length ( integer(s) )
Color
Switch between SMA/EMA ( boolean(s) )
Source for MA
Note: Additional attention to detail has been made here as trend direction is ignored if "BOTH" is selected for the MA Rules and the lengths of both Moving Averages are set to be the same.
2/3 — Doji Rules and Colors:
The next two sections include 19 inputs that are related to how this script will analyze and identify the different variants of Doji candles.
"Identify Pattern On Close" ( boolean ) modifies which candles are to be used for determining when Doji candles are recognized. This changes an offset used for historical reference on some global variables which will force the script to only identify patterns after the current candle has closed.
"Doji Body Tolerance" ( float ) tells the script the maximum % the candle body may be of the high-low range to be considered a Doji candle.
"Doji Wick Sample" ( integer ) defines how many prior candles to sample from in calculating the current average upper and lower wick sizes.
"Simplify Northern/Southern Dojis" ( boolean ) makes this script ignore trend direction for Doji detection and consolidates Northern and Southern Dojis into being recognized as the same. This has an added effect of removing the plotted moving averages from the screen.
"Northern/Southern Display" ( string list ) that has multiple options for how Northern and Southern Dojis will be displayed on screen. Because of how labels may be extremely taxing on TradingView's servers to display, the default setting is "shapes" where Northern and Southern (N/S) Dojis will be marked with a colored triangle at the top of the candle. If "Simplify Northern/Southern Dojis" is true, all N/S Dojis will be marked with an x-cross instead. Other options include "labels" which enables the use of labels accompanied by their respective tooltip and color, or "none" where N/S Dojis will be only noticeable by their changed barcolor.
"Allow Gravestone/Dragonfly Shadows" ( boolean ) allows a bit of additional nuance to the definition of Gravestone or Dragonfly Dojis with small shadows.
"Gravestone/Dragonfly Shadow Tolerance" ( float ) defines the maximum % that the lower wick/upper wick (respectively) may be relative to the high-low range for Gravestone or Dragonfly Dojis to still be considered valid.
"Doji Long Wick Setting" ( string list) is a list of settings for three different ways of confirming if a Doji is Long-Legged. The settings are "one", "two", and "average". These define how many wick lengths of a candle need to exceed the calculated average wick lengths (EX: "both" -> upper wick length > upper wick average and lower wick length > lower wick average). The "average" setting will combine the lengths of both wicks and both prior wick averages, divide both of these sums by 2 and compare them instead.
"Doji Long Wick Tolerance" ( float ) defines how large compared to the averages that wick lengths need to be in order for them to be considered "Long-Legged" (EX: 1.50 -> upper/lower wick needs to exceed 150% the average of previous upper/lower wicks).
"Rickshaw Man Body Placement Tolerance" ( float ) defines how close to the high-low range's midpoint the candle body's midpoint needs to be in order for it to be considered a Rickshaw Man Doji candle instead.
The remaining 9 inputs define the colors to use for differentiating between all Doji variants this script will recognize.
█ USAGE
My hope for this script is that users find this easy to use/understand and will tinker with the input values to better identify Doji candlesticks across a wide range of markets.
Suggestions for changes in the future are welcome.
Relative VolumeVolume can be a very useful tool if used correctly. Relative volume is designed to filter out the noise and highlight anomalies assisting traders in tracking institutional movements. This tool can be used to identify stop loss hunters and organized dumps. It uses a variety of moving averages to hide usual activity and features an LSMA line to show trend. Trend columns are shown to highlight activity and can be seen at bottom of the volume columns, this is done using ZLSMA and LSMA.
The above chart shows an example of 2 indicators being used on the 15 min chart. The bottom indicator is set to the 1 min chart. Traders can see a large dump on the 1 min chart as institutions wipe out any tight stop losses. Next they buy back in scooping up all those long positions.
This is an example layout using a split screen setup and multiple timeframes ranging from 1 min to 30 mins. This gives a clear indication of trends and make it easy to pickup on institutional behaviour. Tip: Double clicking indicator background will maximize RVOL to the split screen window.