Trend Shift ProThe indicator is designed to identify shifts or changes in trends as blocks, the indicator's focus on analyzing the Median of Means, Interquartile Range, and Practical Significance for potential trend changes in the market using non parametric Cohen's D. The script is designed to operate on blocks of 21 bars. The key parts of the script related to this are the conditions inside the "if" statements: The bar_index % 21 == 0 condition checks if the current bar index is divisible by 21, meaning it's the beginning of a new block of 21 bars. This condition is used to reset and calculate new values at the start of each block.
Therefore, signals or calculations related to the median of means (MoM), interquartile range (IQR), and Cohen's D are updated and calculated once every 21 bars. What this means is the frequency of signals is shown once every 21 bars.
Price Movements of Blocks:
Block-Based Analysis: This approach divides the price data into blocks or segments, often a fixed number of bars or candles. Each block represents a specific interval of time or price action. It involves No Smoothing: Unlike moving averages, block-based analysis does not apply any smoothing to the price data within each block. It directly examines the raw prices within each block.
Let's break down the key concepts and how they are used for trading:
Median of Means (MoM):
The script calculates the median of the means of seven subgroups, each consisting of three bars in shuffled order.
Each subgroup's mean is calculated based on the typical price (hlc3) of the bars within that subgroup.
The median is then computed from these seven means, representing a central tendency measure.
Note: The Median of Means provides a robust measure of central tendency, especially in situations where the dataset may have outliers or exhibit non-normal distribution characteristics. By calculating means within smaller subgroups, the method is less sensitive to extreme values that might unduly influence the overall average. This can make the Median of Means more robust than a simple mean or median when dealing with datasets that have heterogeneity or skewed distributions.
Interquartile Range (IQR):
The script calculates the IQR for each block of 21 bars.
The IQR is a measure of statistical dispersion, representing the range between the first quartile (Q1) and the third quartile (Q3) of the data.
Q1 and Q3 are calculated from the sorted array of closing prices of the 21 bars.
Non-Parametric Cohen's D Calculation:
Cohen's D is a measure of effect size, indicating the standardized difference between two means.
In this script, a non-parametric version of Cohen's D is calculated, comparing the MoM values of the current block with the MoM values of the previous block.
The calculation involves the MoM difference divided by the square root of the average squared IQR values.
Practical Significance Threshold:
The user can set a threshold for practical significance using the Threshold input.
The script determines practical significance by comparing the calculated Cohen's D with this threshold.
Plotting:
The script plots the MoM values using both straight lines and circles, with the color of the circles indicating the direction of the MoM change (green for upward, red for downward, and blue for no change).
Triangular shapes are plotted when the absolute value of Cohen's D is less than the practical significance threshold.
Overall Purpose for Trading:
The indicator is designed to help traders identify potential turning points or shifts in market sentiment. and use it as levels which needs to be crossed to have a new trend.
Changes in MoM, especially when accompanied by practical significance as determined by Cohen's D, may signal the start of a new trend or a significant move in the market.
Traders using this indicator would typically look for instances where the MoM values and associated practical significance suggest a high probability of a trend change, providing them with potential entry or exit signals. It's important for users to backtest and validate the indicator's effectiveness in different market conditions before relying on it for trading decisions.
Iqr
Rolling summaryStatistical methods based on mean cannot be effective all the time when attributed to financial data since it doesn't usually follow normal distribution, the data can be skewed or/and have extreme values which can be described as outliers.
In order to deal with this problem it is appropriate to use median-based techniques.
The most common one is called five-number summary/box plot, which plots median of the dataset, 25th (Q1) & 75th (Q3) percentiles (the medians of lower & upper parts of the original dataset divided by the original median), and whiskers calculated by taking range between Q1 and Q3, multiplying it by 1.5 and adding it to Q3 and subtracting it from Q1. The values which are outside the whiskers are considered outliers. Default settings of the script correspond to the classic box plot.
Seven-number summary can be also plotted by this script, by turning on 4 additional percentiles/Bowley’s seven-figure summary by turning on first 2 additional percentiles and changing their values to 10 and 90 respectively.
P.S.: Mean can be also turned in just to check the difference.
Interquartile Range BandsInterquartile Range Bands script.
This indicator was originally developed by Alex Orekhov at his home.
The idea based on the interquartile range en.wikipedia.org
If price breaks out from the bands then it is `outlier` price.
After breakouts price always returns to its median.
Watch squeeze/expansion periods.
Anyway use it as a supplement to the other indicators.
I will glad to get your feedback.