[KVA]Body Percentage Counter This indicator presents a comprehensive view of the historical candle data within user-defined body percentage ranges. Each column represents a specific body size percentage threshold, starting from as low as 0.01% and extending up to 20%.
The rows categorize candles by their closing and opening price differences, effectively sorting them into green (bullish) and red (bearish) candles based on whether they closed higher or lower than their opening prices.
First Row of the table is the bu
For developers, this table can be immensely useful in determining stop-loss ranges. By analyzing the frequency of candles that fall within certain body percentage ranges, developers can better understand where to set stop-loss orders. For instance, if a developer notices a high frequency of candles with body sizes within a specific percentage range, they may choose to set their stop-loss orders outside of this range to avoid being stopped out by normal market fluctuations.
Moreover, the indicator can be used to:
Volatility Assessment : The indicator can be used to gauge market volatility. Smaller bodies may indicate consolidation periods, while larger bodies might suggest more volatile market conditions.
Optimize Trading Strategies : Adjust entry and exit points based on the prevalence of certain candle sizes.
Risk Management : Determine the commonality of price movements within a certain range to better manage risks.
Backtesting : Use historical data to backtest how different stop-loss ranges would have performed in the past.
Comparative Analysis : Traders can compare the frequency of different body sizes over a selected period, providing insights into how the market is evolving.
Educational Use : For new traders, the indicator can serve as an educational tool to understand the implications of candlestick sizes and their relationship with market dynamics
The data provided in this output can guide developers to make more informed decisions about where to place stop-loss orders, potentially increasing the effectiveness of their trading algorithms or manual trading strategies.
The output of the " Body Percentage Counter" indicator is organized into a table format, which can be broken down as follows:
Header (First Row) : This row lists the body percentage thresholds used to categorize the candles. It starts from 0.01% and increases incrementally to 20%. These thresholds are likely set by the user and represent the range of candle body sizes as a percentage of the total candle size.
Green Candle Count (Second Row) : This row displays the count of green candles—candles where the close price is higher than the open price—that fall within each body percentage threshold. For example, under the column "0.01", the number 25 indicates there are 25 green candles whose body size is 0.01% of the total candle size.
Red Candle Count (Third Row) : This row shows the count of red candles—candles where the close price is lower than the open price—for each body percentage threshold. The numbers in this row reflect the number of red candles that match the body percentage criteria in the corresponding column.
Total Candle Count (Fourth Row) : This row sums the counts of both green and red candles for each body percentage threshold, providing a total count of candles that have a body size within the specific range. For instance, if under "0.01" the green count is 25 and the red count is 26, then the total would be 51.
This organized data representation allows users to quickly assess the distribution of candle body sizes over a historical period, which is especially useful for determining the frequency of price movements that are significant enough to consider for stop-loss settings or other trade management decisions.
Forecasting
Time-itTime-it = Time based indicator
The Time-it indicator parses data by the day of week. Every tradeable instrument has its own personality. Some are more volatile on Mondays, and some are more bullish / bearish on Fridays or any day in between. The key metrics Time-it parses is range, open, high, low, close and +volume-.
The Time-it parsed data is printed in a table format. The table, position, size & color and text color & size can be changed to your preference. Each column parsed data is the last 10 which is numbered 0-9 which refers to the number of the selected day bars ago. For example: if Monday is chosen, 0 is the last closed Monday bar and 9 is the last closed Monday 9 Monday bars ago.
Range = measures the range between high and low for the day.
Open = is the opening price for the day.
High = is the high price for the day.
Low = is the low price for the day.
Close = is the closing price for the day.
+volume- = is the positive or negative volume for the day.
Default settings:
*Represents a how to use tooltip*
Source = ohlc4
* The source used for MA
MA length = 20
* The moving average used
Day bar color on / off
* checked on / unchecked off
Monday = blue
Tuesday = yellow
Wednesday = purple
Thursday = orange
Friday = white
Saturday = red
Sunday = green
Day M, T, W, TH, F, ST, SN.
* Parsed data for the day of week tables
Table, position, size & color:
Top, middle, bottom, left, center, right
* Table position on the chart.
Frame width & border width = 1
Text color and text size
Border color and frame color
Decimal place = 0
* example: use 0 for a round number, use 4 for Forex
*** The Time-it indicator uses parts and/or pieces of code from "Tradingview Up/Down Volume" and "Tradingview Financials on Chart".
Trend Line XrossTrend Line Xross (TLX) Uses User Input Points to draw trendlines and displays the exact intersection point of those trendlines.
This is the public indicator of the practical application for this intersection method included in my entry for Pinefest #1.
To determine the exact intersection point I am using the y-intercept method as seen below.
The code is notated for more information on the technical workings.
One difference to note between this version and the pinefest version is that I had to change the line drawings to use bar_index values so that I can use line.get_price() to grab the current value of the line to make alerts from.
Additionally, there are alerts built-in to this version for every type of cross on all of the visible lines.
Enjoy!
Intersection PointThis publication focusses at the intersection of 2 lines, and a trend estimation derived from a comparison of Intersection Point value against current price value.
The formula to calculate the Intersection Point (IP) is:
change1 = ta.change (valueLine1)
change2 = ta.change (valueLine2)
sf = (valueLine2 - valueLine1 ) / (change1 - change2)
I = valueLine1 + change1 * sf
🔶 USAGE
🔹 Future / Past Intersection
The position where 2 lines would intersect in the future is shown here by extending both lines and a yellow small line to indicate its location:
Of course this can change easily when price changes.
If "Back" is enabled, the IP in history can be seen:
The yellow line which indicates the IP is only visible when it is not further located then +/- 500 bars from current bar.
If this point is further away, lines towards the IP still will be visible (max 500 bars further) without the IP.
🔹 Trend
The calculated intersection price is compared with the latest close and used for estimating the trend direction.
When close is above the intersection price (I), this is an indication the market is trending up, if close is below I, this would indicate the market is trending down.
The included bands can be useful for entry/SL/TP,...
🔶 DETAILS
🔹 Map.new()
All values are put in a map.new() with the function value()
The latest Intersection is also placed in this map with the function addLastIntersectValue() and retrieved at the last bar (right top)
🔹 Intersection Point Line
The intersection price can be made visible by enabling "Intersection Price" in SETTINGS -> STYLE. To ensure lines aren't drawn all over the place, this value is limited to maximum high + 200 days-ATR and minimum low - 200 days-ATR.
🔶 SETTINGS
🔹 Choose the value for both lines :
Type : choose between
• open, high, low, close,
• SMA, EMA, HullMA, WMA, VWMA, DEMA, TEMA
• The Length setting sets 1 of these Moving Averages when chosen
• src 1 -> You can pick an external source here
🔹 Length Intersection Line : Max length of line:
Intersection Line will update untillthe amount of bars reach the "Length Intersection Line"
💜 PURPLE BARS 😈
• Since TradingView has chosen to give away our precious Purple coloured Wizard Badge, bars are coloured purple 😊😉
Ultimate Seasonality Indicator [SS]Hello everyone,
This is my seasonality indicator. I have been working on it for like 2 months, so hope you like it!
What it does?
The Ultimate Seasonality indicator is designed to provide you, the trader, an in-depth look at seasonality. The indicator gives you the ability to do the following functions:
View the most bearish and bullish months over a user defined amount of years back.
View the average daily change for each respective months over a user defined amount of years back.
See the most closely correlated month to the current month to give potential insights of likely trend.
Plot out areas of High and Low Seasonality.
Create a manual seasonal forecast model by selecting the desired month you would like to model the current month data after.
Have the indicator develop an autoregressive seasonal model based on seasonally lagged variables, using principles of machine learning.
I will go over these functions 1 by 1, its a whopper of an indicator so I will try to be as clear and concise as possible.
Viewing Bullish vs Bearish Months, Average Daily Change & Correlation to Current Month
The indicator will break down the average change, as well as the number of bullish and bearish days by month. See the image below as an example:
In the table to the right, you will see a breakdown of each month over the past 3 years.
In the first column, you will see the average daily change. A negative value, means it was a particularly bearish month, a positive value means it was a particularly bullish month.
The next column over shows the correlation to the current dataset. How this works is the indicator takes the size of the monthly data for each month, and compares it to the last X number of days up until the last trading day. It will then perform a correlation assessment to see how closely similar the past X number of trading days are to the various monthly data.
The last 2 columns break down the number of Bullish and Bearish days, so you can see how many red vs green candles happened in each respective month over your set timeframe. In the example above, it is over the pats 3 years.
Plot areas of High and Low Seasonality
In the chart above, you will see red and green highlighted zones.
Red represents areas of HIGH Seasonality .
Green represents areas of LOW Seasonality .
For this function, seasonality is measured by the autocorrelation function at various lags (12 lags). When there is an average autocorrelation of greater than 0.85 across all seasonal lags, it is considered likely the result of high seasonality/trend.
If the lag is less than or equal to 0.05, it is indicative of very low seasonality, as there is no predominate trend that can be found by the autocorrelation functions over the seasonally lagged variables.
Create Manual Seasonal Forecasts
If you find a month that has a particularly high correlation to the current month, you can have the indicator create a seasonal model from this month, and fit it onto the current dataset (past X days of trading).
If we look at the example below:
We can see that the most similar month to the current data is September. So, we can ask the indicator to create a seasonal forecast model from only September data and fit it to our current month. This is the result:
You will see, using September data, our most likely close price for this month is 450 and our model is y= 1.4305x + -171.67.
We can accept the 450 value but we can use the equation to model the data ourselves manually.
For example, say we have a target price on the month of 455 based on our own analysis. We can calculate the likely close price, should this target be reached, by substituting this target for x. So y = 1.4305x + -171.67 becomes
y = 1.4305(455) +- 171.67
y = 479.20
So the likely close price would be 479.20. No likely, and thus its not likely we are to see 455.
HOWEVER, in this current example, the model is far too statistically insignificant to be used. We can see the correlation is only 0.21 and the R squared is 0.04. Not a model you would want to use!
You want to see a correlation of at least 0.5 or higher and an R2 of 0.5 or higher.
We can improve the accuracy by reducing the number of years we look back. This is what happens when we reduce the lookback years to 1:
You can see reducing to 1 year gives December as the most similar month. However, our R2 value is still far too low to really rely on this data whole-heartedly. But it is a good reference point.
Automatic Autoregressive Model
So this is my first attempt at using some machine learning principles to guide statistical analysis.
In the main chart above, you will see the indicator making an autoregressive model of seasonally lagged variables. It does this in steps. The steps include:
1) Differencing the data over 12, seasonally lagged variables.
2) Determining stationarity using DF test.
3) Determining the highest, autocorrelated lags that fall within a significant stationary result.
4) Creating a quadratic model of the two identified lags that best represents a stationary model with a high autocorrelation.
What are seasonally lagged variables?
Seasonally lagged variables are variables that represent trading months. So a lag of 25 would be 1 month, 50, 2 months, 75, 3 months, etc.
When it displays this model, it will show us what the results of the t-statistic are for the DF test, whether the data is stationary, and the result of the autocorrelation assessment.
It will then display the model detail in the tip table, which includes the equation, the current lags being used, the R2 and the correlation value.
Concluding Remarks
That's the indicator in a nutshell!
Hope you like it!
One final thing, you MUST have your chart set to daily, otherwise you will get a runtime error. This can ONLY be used on the daily timeframe!
Feel free to leave your questions, comments and suggestions below.
Note:
My "ultimate" indicators are made to give the functionality of multiple indicators in one. If you like this one, you may like some of my others:
Ultimate P&L Indicator
Ultimate Customizable EMA/SMA
Thanks for checking out the indicator!
K`s Extreme DurationExtreme duration uses a special combination of the RSI and its relative position to deliver a reversal signal.
The following are the conditions to generate signals:
* Bullish signal: The current 8-period RSI is below 50 and above 35 while the previous 5 RSI's are below 35.
* Bearish signal: The current 8-period RSI is above 50 and below 65 while the previous 5 RSI's are above 65.
Machine Learning: Anchored Gaussian Process Regression [LuxAlgo]Machine Learning: Anchored Gaussian Process Regression is an anchored version of Machine Learning: Gaussian Process Regression .
It implements Gaussian Process Regression (GPR), a popular machine-learning method capable of estimating underlying trends in prices as well as forecasting them. Users can set a Training Window by choosing 2 points. GPR will be calculated for the data between these 2 points.
Do remember that forecasting trends in the market is challenging, do not use this tool as a standalone for your trading decisions.
🔶 USAGE
When adding the indicator to the chart, users will be prompted to select a starting and ending point for the calculations, click on your chart to select those points.
Start & end point are named 'Anchor 1' & 'Anchor 2', the Training Window is located between these 2 points. Once both points are positioned, the Training Window is set, whereafter the Gaussian Process Regression (GPR) is calculated using data between both Anchors .
The blue line is the GPR fit, the red line is the GPR prediction, derived from data between the Training Window .
Two user settings controlling the trend estimate are available, Smooth and Sigma.
Smooth determines the smoothness of our estimate, with higher values returning smoother results suitable for longer-term trend estimates.
Sigma controls the amplitude of the forecast, with values closer to 0 returning results with a higher amplitude.
One of the advantages of the anchoring process is the ability for the user to evaluate the accuracy of forecasts and further understand how settings affect their accuracy.
The publication also shows the mean average (faint silver line), which indicates the average of the prices within the calculation window (between the anchors). This can be used as a reference point for the forecast, seeing how it deviates from the training window average.
🔶 DETAILS
🔹 Limited Training Window
The Training Window is limited due to matrix.new() limitations in size.
When the 2 points are too far from each other (as in the latter example), the line will end at the maximum limit, without giving a size error.
The red forecasted line is always given priority.
🔹 Positioning Anchors
Typically Anchor 1 is located further in history than Anchor 2 , however, placing Anchor 2 before Anchor 1 is perfectly possibly, and won't give issues.
🔶 SETTINGS
Anchor 1 / Anchor 2: both points will form the Training Window .
Forecasting Length: Forecasting horizon, determines how many bars in the 'future' are forecasted.
Smooth: Controls the degree of smoothness of the model fit.
Sigma: Noise variance. Controls the amplitude of the forecast, lower values will make it more sensitive to outliers.
Multi-TF AI SuperTrend with ADX - Strategy [PresentTrading]
## █ Introduction and How it is Different
The trading strategy in question is an enhanced version of the SuperTrend indicator, combined with AI elements and an ADX filter. It's a multi-timeframe strategy that incorporates two SuperTrends from different timeframes and utilizes a k-nearest neighbors (KNN) algorithm for trend prediction. It's different from traditional SuperTrend indicators because of its AI-based predictive capabilities and the addition of the ADX filter for trend strength.
BTC 8hr Performance
ETH 8hr Performance
## █ Strategy, How it Works: Detailed Explanation (Revised)
### Multi-Timeframe Approach
The strategy leverages the power of multiple timeframes by incorporating two SuperTrend indicators, each calculated on a different timeframe. This multi-timeframe approach provides a holistic view of the market's trend. For example, a 8-hour timeframe might capture the medium-term trend, while a daily timeframe could capture the longer-term trend. When both SuperTrends align, the strategy confirms a more robust trend.
### K-Nearest Neighbors (KNN)
The KNN algorithm is used to classify the direction of the trend based on historical SuperTrend values. It uses weighted voting of the 'k' nearest data points. For each point, it looks at its 'k' closest neighbors and takes a weighted average of their labels to predict the current label. The KNN algorithm is applied separately to each timeframe's SuperTrend data.
### SuperTrend Indicators
Two SuperTrend indicators are used, each from a different timeframe. They are calculated using different moving averages and ATR lengths as per user settings. The SuperTrend values are then smoothed to make them suitable for KNN-based prediction.
### ADX and DMI Filters
The ADX filter is used to eliminate weak trends. Only when the ADX is above 20 and the directional movement index (DMI) confirms the trend direction, does the strategy signal a buy or sell.
### Combining Elements
A trade signal is generated only when both SuperTrends and the ADX filter confirm the trend direction. This multi-timeframe, multi-indicator approach reduces false positives and increases the robustness of the strategy.
By considering multiple timeframes and using machine learning for trend classification, the strategy aims to provide more accurate and reliable trade signals.
BTC 8hr Performance (Zoom-in)
## █ Trade Direction
The strategy allows users to specify the trade direction as 'Long', 'Short', or 'Both'. This is useful for traders who have a specific market bias. For instance, in a bullish market, one might choose to only take 'Long' trades.
## █ Usage
Parameters: Adjust the number of neighbors, data points, and moving averages according to the asset and market conditions.
Trade Direction: Choose your preferred trading direction based on your market outlook.
ADX Filter: Optionally, enable the ADX filter to avoid trading in a sideways market.
Risk Management: Use the trailing stop-loss feature to manage risks.
## █ Default Settings
Neighbors (K): 3
Data points for KNN: 12
SuperTrend Length: 10 and 5 for the two different SuperTrends
ATR Multiplier: 3.0 for both
ADX Length: 21
ADX Time Frame: 240
Default trading direction: Both
By customizing these settings, traders can tailor the strategy to fit various trading styles and assets.
Expected Move by Option's Implied Volatility Symbols: EAT - GBDC
This script plots boxes to reflect weekly, monthly and yearly expected moves based on "At The Money" put and call option's implied volatility.
Symbols in range: This script will display Expected Move data for Symbols within the range of EAT-GDBC in alphabetical order.
Weekly Updates: Each weekend, the script is updated with fresh expected move data, a job that takes place every Saturday following the close of the markets on Friday.
In the provided script, several boxes are created and plotted on a price chart to represent the expected price moves for various timeframes.
These boxes serve as visual indicators to help traders and analysts understand the expected price volatility.
Definition of Expected Move: Expected Move refers to the anticipated range within which the price of an underlying asset is expected to move over a specific time frame, based on the current implied volatility of its options. Calculation: Expected Move is typically calculated by taking the current stock price and applying a multiple of the implied volatility. The most commonly used multiple is the one-standard-deviation move, which encompasses approximately 68% of potential price outcomes.
Example: Suppose a stock is trading at $100, and the implied volatility of its options is 20%. The one-standard-deviation expected move would be $100 * 0.20 = $20.
This suggests that there is a 68% probability that the stock's price will stay within a range of $80 to $120 over the specified time frame. Usage: Traders and investors use the expected move as a guideline for setting trading strategies and managing risk. It helps them gauge the potential price swings and make informed decisions about buying or selling options. There is a 68% chance that the underlying asset stock or ETF price will be within the boxed area at option expiry. The data on this script is updating weekly at the close of Friday, calculating the implied volatility for the week/month/year based on the "at the money" put and call options with the relevant expiry.
In summary, implied volatility reflects market expectations about future price volatility, especially in the context of options. Expected Move is a practical application of implied volatility, helping traders estimate the likely price range for an asset over a given period. Both concepts play a vital role in assessing risk and devising trading strategies in the options and stock markets.
Expected Move by Option's Implied Volatility Symbols: CLFD-EARN This script plots boxes to reflect weekly, monthly and yearly expected moves based on "At The Money" put and call option's implied volatility.
Symbols in range: This script will display Expected Move data for Symbols within the range of CLFD - EARN in alphabetical order.
Weekly Updates: Each weekend, the script is updated with fresh expected move data, a job that takes place every Saturday following the close of the markets on Friday.
In the provided script, several boxes are created and plotted on a price chart to represent the expected price moves for various timeframes.
These boxes serve as visual indicators to help traders and analysts understand the expected price volatility.
Definition of Expected Move: Expected Move refers to the anticipated range within which the price of an underlying asset is expected to move over a specific time frame, based on the current implied volatility of its options. Calculation: Expected Move is typically calculated by taking the current stock price and applying a multiple of the implied volatility. The most commonly used multiple is the one-standard-deviation move, which encompasses approximately 68% of potential price outcomes.
Example: Suppose a stock is trading at $100, and the implied volatility of its options is 20%. The one-standard-deviation expected move would be $100 * 0.20 = $20.
This suggests that there is a 68% probability that the stock's price will stay within a range of $80 to $120 over the specified time frame. Usage: Traders and investors use the expected move as a guideline for setting trading strategies and managing risk. It helps them gauge the potential price swings and make informed decisions about buying or selling options. There is a 68% chance that the underlying asset stock or ETF price will be within the boxed area at option expiry. The data on this script is updating weekly at the close of Friday, calculating the implied volatility for the week/month/year based on the "at the money" put and call options with the relevant expiry.
In summary, implied volatility reflects market expectations about future price volatility, especially in the context of options. Expected Move is a practical application of implied volatility, helping traders estimate the likely price range for an asset over a given period. Both concepts play a vital role in assessing risk and devising trading strategies in the options and stock markets.
Expected Move by Option's Implied Volatility Symbols: B - CLF
This script plots boxes to reflect weekly, monthly and yearly expected moves based on "At The Money" put and call option's implied volatility.
Symbols in range: This script will display Expected Move data for Symbols within the range of B - CLF in alphabetical order.
Weekly Updates: Each weekend, the script is updated with fresh expected move data, a job that takes place every Saturday following the close of the markets on Friday.
In the provided script, several boxes are created and plotted on a price chart to represent the expected price moves for various timeframes.
These boxes serve as visual indicators to help traders and analysts understand the expected price volatility.
Definition of Expected Move: Expected Move refers to the anticipated range within which the price of an underlying asset is expected to move over a specific time frame, based on the current implied volatility of its options. Calculation: Expected Move is typically calculated by taking the current stock price and applying a multiple of the implied volatility. The most commonly used multiple is the one-standard-deviation move, which encompasses approximately 68% of potential price outcomes.
Example: Suppose a stock is trading at $100, and the implied volatility of its options is 20%. The one-standard-deviation expected move would be $100 * 0.20 = $20.
This suggests that there is a 68% probability that the stock's price will stay within a range of $80 to $120 over the specified time frame. Usage: Traders and investors use the expected move as a guideline for setting trading strategies and managing risk. It helps them gauge the potential price swings and make informed decisions about buying or selling options. There is a 68% chance that the underlying asset stock or ETF price will be within the boxed area at option expiry. The data on this script is updating weekly at the close of Friday, calculating the implied volatility for the week/month/year based on the "at the money" put and call options with the relevant expiry.
In summary, implied volatility reflects market expectations about future price volatility, especially in the context of options. Expected Move is a practical application of implied volatility, helping traders estimate the likely price range for an asset over a given period. Both concepts play a vital role in assessing risk and devising trading strategies in the options and stock markets.
Cycle OscillatorThe Cycle Oscillator is a tool developed to help traders analyze market cycles thanks to a simplified version of the Hurst theory and the easy visualization provided by the detrended cycle.
This indicator has two functions:
- The first one is the plotting of a line that oscillates above and below the zero line, which can be used to find the cycle direction and momentum
- The second feature is the next-cycle bottom forecaster, useful for estimating the timing of the future pivot low based on the pivot low of the oscillator.
This last feature shows graphically the period in which the next low will probably happen, using as a calculation method the timing of the previous indicator's lows.
Additionally, the user can choose to modify the cycle length to analyze bigger or smaller price movements.
This indicator can be greatly used in combination with other Cycle Indicators to gain more confluence in the plotted time areas.
Cycle IndicatorThe Cycle Indicator is a tool developed to help traders analyze market cycles thanks to a simplified version of the Hurst theory.
This indicator has two functions:
- The first one is the plotting of a line that can be used to find the cycle direction and momentum
- The second feature is the next-cycle bottom forecaster, useful for estimating the timing of the future pivot low.
This last feature shows graphically the period in which the next low will probably happen, using as a calculation method the timing of the previous lows.
Additionally, the user can choose to extend this time zone or to limit them to the range between the last pivot high and low.
Expected Move by Option's Implied Volatility Symbols: A - AZZ
This script plots boxes to reflect weekly, monthly and yearly expected moves based on "At The Money" put and call option's implied volatility.
Symbols in range: This script will display Expected Move data for Symbols within the range of A - AZZ in alphabetical order.
Weekly Updates: Each weekend, the script is updated with fresh expected move data, a job that takes place every Saturday following the close of the markets on Friday.
In the provided script, several boxes are created and plotted on a price chart to represent the expected price moves for various timeframes.
These boxes serve as visual indicators to help traders and analysts understand the expected price volatility.
Definition of Expected Move: Expected Move refers to the anticipated range within which the price of an underlying asset is expected to move over a specific time frame, based on the current implied volatility of its options. Calculation: Expected Move is typically calculated by taking the current stock price and applying a multiple of the implied volatility. The most commonly used multiple is the one-standard-deviation move, which encompasses approximately 68% of potential price outcomes.
Example: Suppose a stock is trading at $100, and the implied volatility of its options is 20%. The one-standard-deviation expected move would be $100 * 0.20 = $20.
This suggests that there is a 68% probability that the stock's price will stay within a range of $80 to $120 over the specified time frame. Usage: Traders and investors use the expected move as a guideline for setting trading strategies and managing risk. It helps them gauge the potential price swings and make informed decisions about buying or selling options. There is a 68% chance that the underlying asset stock or ETF price will be within the boxed area at option expiry. The data on this script is updating weekly at the close of Friday, calculating the implied volatility for the week/month/year based on the "at the money" put and call options with the relevant expiry.
In summary, implied volatility reflects market expectations about future price volatility, especially in the context of options. Expected Move is a practical application of implied volatility, helping traders estimate the likely price range for an asset over a given period. Both concepts play a vital role in assessing risk and devising trading strategies in the options and stock markets.
Machine Learning: VWAP [YinYangAlgorithms]Machine Learning: VWAP aims to use Machine Learning to Identify the best location to Anchor the VWAP at. Rather than using a traditional fixed length or simply adjusting based on a Date / Time; by applying Machine Learning we may hope to identify crucial areas which make sense to reset the VWAP and start anew. VWAP’s may act similar to a Bollinger Band in the sense that they help to identify both Overbought and Oversold Price locations based on previous movements and help to identify how far the price may move within the current Trend. However, unlike Bollinger Bands, VWAPs have the ability to parabolically get quite spaced out and also reset. For this reason, the price may never actually go from the Lower to the Upper and vice versa (when very spaced out; when the Upper and Lower zones are narrow, it may bounce between the two). The reason for this is due to how the anchor location is calculated and in this specific Indicator, how it changes anchors based on price movement calculated within Machine Learning.
This Indicator changes the anchor if the Low < Lowest Low of a length of X and likewise if the High > Highest High of a length of X. This logic is applied within a Machine Learning standpoint that likewise amplifies this Lookback Length by adding a Machine Learning Length to it and increasing the lookback length even further.
Due to how the anchor for this VWAP changes, you may notice that the Basis Line (Orange) may act as a Trend Identifier. When the Price is above the basis line, it may represent a bullish trend; and likewise it may represent a bearish trend when below it. You may also notice what may happen is when the trend occurs, it may push all the way to the Upper or Lower levels of this VWAP. It may then proceed to move horizontally until the VWAP expands more and it may gain more movement; or it may correct back to the Basis Line. If it corrects back to the basis line, what may happen is it either uses the Basis Line as a Support and continues in its current direction, or it will change the VWAP anchor and start anew.
Tutorial:
If we zoom in on the most recent VWAP we can see how it expands. Expansion may be caused by time but generally it may be caused by price movement and volume. Exponential Price movement causes the VWAP to expand, even if there are corrections to it. However, please note Volume adds a large weighted factor to the calculation; hence Volume Weighted Average Price (VWAP).
If you refer to the white circle in the example above; you’ll be able to see that the VWAP expanded even while the price was correcting to the Basis line. This happens due to exponential movement which holds high volume. If you look at the volume below the white circle, you’ll notice it was very large; however even though there was exponential price movement after the white circle, since the volume was low, the VWAP didn’t expand much more than it already had.
There may be times where both Volume and Price movement isn’t significant enough to cause much of an expansion. During this time it may be considered to be in a state of consolidation. While looking at this example, you may also notice the color switch from red to green to red. The color of the VWAP is related to the movement of the Basis line (Orange middle line). When the current basis is > the basis of the previous bar the color of the VWAP is green, and when the current basis is < the basis of the previous bar, the color of the VWAP is red. The color may help you gauge the current directional movement the price is facing within the VWAP.
You may have noticed there are signals within this Indicator. These signals are composed of Green and Red Triangles which represent potential Bullish and Bearish momentum changes. The Momentum changes happen when the Signal Type:
The High/Low or Close (You pick in settings)
Crosses one of the locations within the VWAP.
Bullish Momentum change signals occur when :
Signal Type crosses OVER the Basis
Signal Type crosses OVER the lower level
Bearish Momentum change signals occur when:
Signal Type crosses UNDER the Basis
Signal Type Crosses UNDER the upper level
These signals may represent locations where momentum may occur in the direction of these signals. For these reasons there are also alerts available to be set up for them.
If you refer to the two circles within the example above, you may see that when the close goes above the basis line, how it mat represents bullish momentum. Likewise if it corrects back to the basis and the basis acts as a support, it may continue its bullish momentum back to the upper levels again. However, if you refer to the red circle, you’ll see if the basis fails to act as a support, it may then start to correct all the way to the lower levels, or depending on how expanded the VWAP is, it may just reset its anchor due to such drastic movement.
You also have the ability to disable Machine Learning by setting ‘Machine Learning Type’ to ‘None’. If this is done, it will go off whether you have it set to:
Bullish
Bearish
Neutral
For the type of VWAP you want to see. In this example above we have it set to ‘Bullish’. Non Machine Learning VWAP are still calculated using the same logic of if low < lowest low over length of X and if high > highest high over length of X.
Non Machine Learning VWAP’s change much quicker but may also allow the price to correct from one side to the other without changing VWAP Anchor. They may be useful for breaking up a trend into smaller pieces after momentum may have changed.
Above is an example of how the Non Machine Learning VWAP looks like when in Bearish. As you can see based on if it is Bullish or Bearish is how it favors the trend to be and may likewise dictate when it changes the Anchor.
When set to neutral however, the Anchor may change quite quickly. This results in a still useful VWAP to help dictate possible zones that the price may move within, but they’re also much tighter zones that may not expand the same way.
We will conclude this Tutorial here, hopefully this gives you some insight as to why and how Machine Learning VWAPs may be useful; as well as how to use them.
Settings:
VWAP:
VWAP Type: Type of VWAP. You can favor specific direction changes or let it be Neutral where there is even weight to both. Please note, these do not apply to the Machine Learning VWAP.
Source: VWAP Source. By default VWAP usually uses HLC3; however OHLC4 may help by providing more data.
Lookback Length: The Length of this VWAP when it comes to seeing if the current High > Highest of this length; or if the current Low is < Lowest of this length.
Standard VWAP Multiplier: This multiplier is applied only to the Standard VWMA. This is when 'Machine Learning Type' is set to 'None'.
Machine Learning:
Use Rational Quadratics: Rationalizing our source may be beneficial for usage within ML calculations.
Signal Type: Bullish and Bearish Signals are when the price crosses over/under the basis, as well as the Upper and Lower levels. These may act as indicators to where price movement may occur.
Machine Learning Type: Are we using a Simple ML Average, KNN Mean Average, KNN Exponential Average or None?
KNN Distance Type: We need to check if distance is within the KNN Min/Max distance, which distance checks are we using.
Machine Learning Length: How far back is our Machine Learning going to keep data for.
k-Nearest Neighbour (KNN) Length: How many k-Nearest Neighbours will we account for?
Fast ML Data Length: What is our Fast ML Length? This is used with our Slow Length to create our KNN Distance.
Slow ML Data Length: What is our Slow ML Length? This is used with our Fast Length to create our KNN Distance.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
Choose Symbol, candle and Trend modeThis Pine Script code is designed for technical analysis and visualization of price movements on the TradingView platform. It serves as a tool for traders and investors to:
Price Chart Analysis: The code plots the price chart of a selected symbol and utilizes Heikin-Ashi candlesticks to visualize price movements. This aids in better understanding price trends, support and resistance levels, retracements, and other price actions.
Trend Identification: The code also employs the Exponential Moving Average (EMA) to identify the price trend. EMA is commonly used to determine the strength and direction of a trend. Traders and investors can use this information to track trends and develop trading strategies.
Buy and Sell Signals: The code generates buy and sell signals based on EMA. These signals provide information on when to consider buying or selling a specific symbol. This is particularly useful for traders when making trading decisions.
Timeframe Customization: Users can adapt the code to different timeframes. This flexibility is valuable for those looking to develop strategies for both short-term and long-term trading.
Customization: The code allows users to customize various parameters, including the symbol, timeframe, Heikin-Ashi mode, and others. This enables it to be tailored to different assets and trading styles.
Please note that this code is provided for educational and informational purposes only. It does not constitute financial advice or recommendations for specific trading actions. Any trading decisions made using this code should be based on individual research, analysis, and a clear understanding of the associated risks.
AR Forecast Scatterplot [SS]This is a showcase indicator of my recently released SPTS library (the partner of the SPTS indicator).
This is just to show some of the practical applications of the boring statistical functions contained within the library/SPTS indicator :-).
This is an autoregressive (AR), scatter plot forecaster. What this means is it tags a lag of 1, performs an autoregressive assessment over the desired training time, then uses what it learns over that training time to forecast the likely outcome.
Its not a machine learning (I am in the process of creating one like this, but it is taking quite some time to complete), but the model needs to learn to plan the statistical coefficients that will best mimic the current trend.
As of its current state, this actually surpassed my own expectations. I can show you some QQQ examples:
Example #1:
Prediction:
Actual:
Example #2:
Prediction:
Actual:
Pretty nuts, eh?
Statistics, I'm telling you, its the answer haha.
So how do we determine the train time?
Because this is not using machine learning to control for over/under representation of datasize (again, I am making a version that does this, but its a slow process), some quick tips at determine appropriate train time is to use the Tradingview Regression tool:
When you set the parameters to align with the current, strongest trend, it is more reliable.
You will see, that it acutally is forecasting a move back to the exact top of this trend, that is because it is using the same processes as the linear regression trend on Tradingview.
You can use a bar counter indicator ( such as mine available here ) to calculate the number or bars back for your model training.
You can verify that these parameters are appropriate by looking at the Model Data table (which can be toggled on and off). You want to see both a high correlation and a high R2 value.
Quick note on colour:
Green = represents the upper confidence predictions (best case scenario)
Blue = represents the most likely result
red = represents that lower confidence (not as best case scenario)
Hope you enjoy!
Safe trades everyone!
WU Sahm Recession Indicator The Sahm Recession Indicator devised by Economist Claudia Sahm is a rather insightful tool that captures the onset of recessions by utilizing unemployment data, which can provide more real-time insights compared to quarterly GDP reports. If the three-month simple moving average (SMA) of the unemployment rate exceeds the minimum unemployment rate of the previous 12 months by 0.5 percentage points, it indicates a high likelihood of a recession.
This script allows you to visualize this indicator and set up alerts for when this criterion indicates that a recession could be coming.
Asiri Colored CandleNote: To use this code, you must choose Hollow candle
This code color the candle based the relationship current volume to previous volume, according these features:
1- White candle when the current volume greater than the previous one, and all of them greater than moving average for 20 periods of volume
2- Green candle color when the current volume greater than the previous one, and all of them lower than moving average for 20 periods of volume
3- Blue candle it means (Bullish Candle) purchasing candles, with change 3% or higher
4- Yellow candle it means (Bearish Candle) with change 3% or higher
5- The number upper the candle means how much does the volume represent relative to the volume moving average
6- The number lower candle means value of MFI indicator value
كود برمجي يقوم بإعطاء لون للشموع بناء على الحجم
لطي تتمكن من استخدام هذا الكود يجب أن يكون نمط الشموع الذي على الشارت شموع مفرغة
من خصائصه التالي
1- إذا الحجم السفلي الحالي أكبر من الحجم السابق وكلاهما فوق متوسط 20 للحجم والسعر الحالي ارتفع عن السعر السابق يقوم بتلوين الشمعة بيضاء
2- إذا الحجم السفلي الحالي أكبر من الحجم السابق وكلاهما أسفل متوسط 20 للحجم والسعر الحالي ارتفع عن السعر السابق يقوم بتلوين الشمعة خضراء
3- إذا الحجم الحالي أقل من السابق ولكن تكونت شمعة شرائية ارتفعت الشمعة بـ 3% أو تغيرها كان 3% فأعلى يكون لونها أزرق
4- إذا تكونت شمعة بيعية انخفاضها أو تغيرها كان 3% بأعلى يكون لونها أصفر
5- الأرقام أعلى الشموع تبين كم أن الحجم المقابل للشمعة ضعف الحجم لمتوسط حجم 20 فترة سابقة للحجم يعني إذا كان أعلى الشمعة 3 فهذا يعني أن الحجم لهذه الشمعة ارتفع بـ 3 أضعاف متوسط 20 فترة سابقة للحجم ، كما أن هذا الرقم يظهر أعلى شمعة الدوجي التي إغلاقها مساوي لافتتاحها
6- الرقم أسفل الشمعة يبين قيمة مؤشر التدفق النقدي MFI
أخيرا تستطيع التعديل على الكود حسب ما تراه و إخفاء الأرقام أعلى أو أسفل الشموع
لا تنسوني من دعائكم
Leading Economic Indicator (LEI)The Leading Economic Indicator (LEI) is a groundbreaking technical indicator designed to serve as a comprehensive measure of the prevailing direction of economic trends in the United States. This unique index combines two key economic indicators: the Composite Leading Indicator (CLI) from the Organization for Economic Co-operation and Development (OECD) and the Purchasing Managers' Index (PMI) from the Institute for Supply Management (ISM).
The OECD Composite Leading Indicator (CLI) is a globally recognized indicator that assesses the future direction of economic trends by analyzing various leading economic factors. The ISM PMI, on the other hand, provides insights into the business activities of both the manufacturing and services sectors. LEI merges these critical indicators into a single, holistic indicator that empowers traders and investors to grasp the broader economic outlook and the performance of essential economic sectors simultaneously.
By taking into account the CLI and PMI, LEI offers a distinctive perspective, enabling a more accurate assessment of the potential direction of US financial markets.
Usage:
To utilize LEI effectively, it is recommended to apply it on a monthly timeframe (TF Monthly). This extended timeframe is particularly beneficial for investors with a medium to long-term horizon. By focusing on longer-term trends and market stability, LEI becomes an invaluable tool in your investment strategy.
One of the primary applications of LEI is to gauge the risk of market corrections in US financial markets, including the S&P 500, Nasdaq, and Dow Jones indices. Analysts often observe the crossing of the 5-period Simple Moving Average (SMA) with the 10-period SMA. When the 5-period SMA falls below the 10-period SMA, it serves as a potential warning signal for an impending market correction. This feature provides traders with an opportunity to exercise caution and make well-informed investment decisions.
LEI, with its unique blend of the OECD CLI and ISM PMI, provides a reliable tool for assessing the US economic climate, identifying trends, and making informed decisions in the financial markets. It stands as a reference indicator, capturing the essence of economic trends and providing valuable insights to traders and investors.
Sources:
- OECD Composite Leading Indicator (CLI): www.data.oecd.org
- Purchasing Managers' Index: ISM Report on Business (PMI) www.ismworld.org
Linear Regression Forecast Tool [Daveatt]Hello traders,
Navigating through the financial markets requires a blend of analysis, insight, and a touch of foresight.
My Linear Regression Forecast Tool is here to add that touch of foresight to your analysis toolkit on TradingView!
Linear Regression is the heart of this tool, a statistical method that explores the relationship between a dependent variable and one (or more) independent variable(s).
In simpler terms, it finds a straight line that best fits a set of data points.
This "line of best fit" then becomes a visual representation of the relationship in the data, providing a basis for making predictions.
Here's what the Linear Regression Forecast Tool brings to your trading table:
Multiple Indicator Choices: Select from various market indicators like Simple Moving Averages, Bollinger Bands, or the Volume Weighted Average Price as the basis for your linear regression analysis.
Customizable Forecast Periods: Define how many periods ahead you want to forecast, adjusting to your analysis needs, whether that's looking 5, 7, or 10 periods into the future.
On-Chart Forecast Points: The tool plots the forecasted points on your chart, providing a straightforward visual representation of potential future values based on past data.
In this script:
1. We first calculate the indicator using the specified period.
2. We then use the ta.linreg function to calculate a linear regression curve fitted to the indicator over the last Period bars.
3. We calculate the slope of the linear regression curve using the last two points on the curve.
We use this slope to extrapolate the linear regression curve to forecast the next X points of the indicator.
4/ Finally, we use the plot function to plot the original indicator and the forecasted points on the chart, using the offset parameter to shift the forecasted points to the right (into the future).
This method assumes that the trend represented by the linear regression curve will continue, which may not always be the case, especially in volatile or changing market conditions.
Examples:
Works with a moving average
Works with a Bollinger band
The code can be adapted to work with any other indicator (imagine RSI, MACD, other Moving Average Type, PSAR, Supertrend, etc...)
Conclusion
The Linear Regression Forecast Tool doesn't promise to tell the future but provides a structured way to visualize possible future price trends based on historical data. I
Remember, no tool can predict market conditions with certainty.
It's always advisable to corroborate findings with other analysis methods and stay updated with market news and events.
Happy trading!
Machine Learning: Optimal RSI [YinYangAlgorithms]This Indicator, will rate multiple different lengths of RSIs to determine which RSI to RSI MA cross produced the highest profit within the lookback span. This ‘Optimal RSI’ is then passed back, and if toggled will then be thrown into a Machine Learning calculation. You have the option to Filter RSI and RSI MA’s within the Machine Learning calculation. What this does is, only other Optimal RSI’s which are in the same bullish or bearish direction (is the RSI above or below the RSI MA) will be added to the calculation.
You can either (by default) use a Simple Average; which is essentially just a Mean of all the Optimal RSI’s with a length of Machine Learning. Or, you can opt to use a k-Nearest Neighbour (KNN) calculation which takes a Fast and Slow Speed. We essentially turn the Optimal RSI into a MA with different lengths and then compare the distance between the two within our KNN Function.
RSI may very well be one of the most used Indicators for identifying crucial Overbought and Oversold locations. Not only that but when it crosses its Moving Average (MA) line it may also indicate good locations to Buy and Sell. Many traders simply use the RSI with the standard length (14), however, does that mean this is the best length?
By using the length of the top performing RSI and then applying some Machine Learning logic to it, we hope to create what may be a more accurate, smooth, optimal, RSI.
Tutorial:
This is a pretty zoomed out Perspective of what the Indicator looks like with its default settings (except with Bollinger Bands and Signals disabled). If you look at the Tables above, you’ll notice, currently the Top Performing RSI Length is 13 with an Optimal Profit % of: 1.00054973. On its default settings, what it does is Scan X amount of RSI Lengths and checks for when the RSI and RSI MA cross each other. It then records the profitability of each cross to identify which length produced the overall highest crossing profitability. Whichever length produces the highest profit is then the RSI length that is used in the plots, until another length takes its place. This may result in what we deem to be the ‘Optimal RSI’ as it is an adaptive RSI which changes based on performance.
In our next example, we changed the ‘Optimal RSI Type’ from ‘All Crossings’ to ‘Extremity Crossings’. If you compare the last two examples to each other, you’ll notice some similarities, but overall they’re quite different. The reason why is, the Optimal RSI is calculated differently. When using ‘All Crossings’ everytime the RSI and RSI MA cross, we evaluate it for profit (short and long). However, with ‘Extremity Crossings’, we only evaluate it when the RSI crosses over the RSI MA and RSI <= 40 or RSI crosses under the RSI MA and RSI >= 60. We conclude the crossing when it crosses back on its opposite of the extremity, and that is how it finds its Optimal RSI.
The way we determine the Optimal RSI is crucial to calculating which length is currently optimal.
In this next example we have zoomed in a bit, and have the full default settings on. Now we have signals (which you can set alerts for), for when the RSI and RSI MA cross (green is bullish and red is bearish). We also have our Optimal RSI Bollinger Bands enabled here too. These bands allow you to see where there may be Support and Resistance within the RSI at levels that aren’t static; such as 30 and 70. The length the RSI Bollinger Bands use is the Optimal RSI Length, allowing it to likewise change in correlation to the Optimal RSI.
In the example above, we’ve zoomed out as far as the Optimal RSI Bollinger Bands go. You’ll notice, the Bollinger Bands may act as Support and Resistance locations within and outside of the RSI Mid zone (30-70). In the next example we will highlight these areas so they may be easier to see.
Circled above, you may see how many times the Optimal RSI faced Support and Resistance locations on the Bollinger Bands. These Bollinger Bands may give a second location for Support and Resistance. The key Support and Resistance may still be the 30/50/70, however the Bollinger Bands allows us to have a more adaptive, moving form of Support and Resistance. This helps to show where it may ‘bounce’ if it surpasses any of the static levels (30/50/70).
Due to the fact that this Indicator may take a long time to execute and it can throw errors for such, we have added a Setting called: Adjust Optimal RSI Lookback and RSI Count. This settings will automatically modify the Optimal RSI Lookback Length and the RSI Count based on the Time Frame you are on and the Bar Indexes that are within. For instance, if we switch to the 1 Hour Time Frame, it will adjust the length from 200->90 and RSI Count from 30->20. If this wasn’t adjusted, the Indicator would Timeout.
You may however, change the Setting ‘Adjust Optimal RSI Lookback and RSI Count’ to ‘Manual’ from ‘Auto’. This will give you control over the ‘Optimal RSI Lookback Length’ and ‘RSI Count’ within the Settings. Please note, it will likely take some “fine tuning” to find working settings without the Indicator timing out, but there are definitely times you can find better settings than our ‘Auto’ will create; especially on higher Time Frames. The Minimum our ‘Auto’ will create is:
Optimal RSI Lookback Length: 90
RSI Count: 20
The Maximum it will create is:
Optimal RSI Lookback Length: 200
RSI Count: 30
If there isn’t much bar index history, for instance, if you’re on the 1 Day and the pair is BTC/USDT you’ll get < 4000 Bar Indexes worth of data. For this reason it is possible to manually increase the settings to say:
Optimal RSI Lookback Length: 500
RSI Count: 50
But, please note, if you make it too high, it may also lead to inaccuracies.
We will conclude our Tutorial here, hopefully this has given you some insight as to how calculating our Optimal RSI and then using it within Machine Learning may create a more adaptive RSI.
Settings:
Optimal RSI:
Show Crossing Signals: Display signals where the RSI and RSI Cross.
Show Tables: Display Information Tables to show information like, Optimal RSI Length, Best Profit, New Optimal RSI Lookback Length and New RSI Count.
Show Bollinger Bands: Show RSI Bollinger Bands. These bands work like the TDI Indicator, except its length changes as it uses the current RSI Optimal Length.
Optimal RSI Type: This is how we calculate our Optimal RSI. Do we use all RSI and RSI MA Crossings or just when it crosses within the Extremities.
Adjust Optimal RSI Lookback and RSI Count: Auto means the script will automatically adjust the Optimal RSI Lookback Length and RSI Count based on the current Time Frame and Bar Index's on chart. This will attempt to stop the script from 'Taking too long to Execute'. Manual means you have full control of the Optimal RSI Lookback Length and RSI Count.
Optimal RSI Lookback Length: How far back are we looking to see which RSI length is optimal? Please note the more bars the lower this needs to be. For instance with BTC/USDT you can use 500 here on 1D but only 200 for 15 Minutes; otherwise it will timeout.
RSI Count: How many lengths are we checking? For instance, if our 'RSI Minimum Length' is 4 and this is 30, the valid RSI lengths we check is 4-34.
RSI Minimum Length: What is the RSI length we start our scans at? We are capped with RSI Count otherwise it will cause the Indicator to timeout, so we don't want to waste any processing power on irrelevant lengths.
RSI MA Length: What length are we using to calculate the optimal RSI cross' and likewise plot our RSI MA with?
Extremity Crossings RSI Backup Length: When there is no Optimal RSI (if using Extremity Crossings), which RSI should we use instead?
Machine Learning:
Use Rational Quadratics: Rationalizing our Close may be beneficial for usage within ML calculations.
Filter RSI and RSI MA: Should we filter the RSI's before usage in ML calculations? Essentially should we only use RSI data that are of the same type as our Optimal RSI? For instance if our Optimal RSI is Bullish (RSI > RSI MA), should we only use ML RSI's that are likewise bullish?
Machine Learning Type: Are we using a Simple ML Average, KNN Mean Average, KNN Exponential Average or None?
KNN Distance Type: We need to check if distance is within the KNN Min/Max distance, which distance checks are we using.
Machine Learning Length: How far back is our Machine Learning going to keep data for.
k-Nearest Neighbour (KNN) Length: How many k-Nearest Neighbours will we account for?
Fast ML Data Length: What is our Fast ML Length? This is used with our Slow Length to create our KNN Distance.
Slow ML Data Length: What is our Slow ML Length? This is used with our Fast Length to create our KNN Distance.
If you have any questions, comments, ideas or concerns please don't hesitate to contact us.
HAPPY TRADING!
Purchasing Managers Index (PMI)The Purchasing Managers Index (PMI) is a widely recognized economic indicator that provides crucial insights into the health and performance of an economy's manufacturing and services sectors. This index is a vital tool for anticipating economic developments and trends, offering an early warning system for changes in these sectors.
The PMI is calculated based on surveys conducted among purchasing managers in various businesses and organizations. These managers are asked about their perceptions of current business conditions and their expectations for future economic activity within their sectors. The responses are then compiled and used to calculate the PMI value.
A PMI value above 50 typically indicates that the manufacturing or services sector is expanding, suggesting a positive economic outlook. Conversely, a PMI value below 50 suggests contraction, which may be an early indication of economic challenges or a potential recession.
In summary, the Purchasing Managers Index (PMI) is an essential economic indicator that assesses the health of manufacturing and services sectors by surveying purchasing managers' opinions. It serves as an early warning system for changes in economic activity and is a valuable tool for forecasting economic trends and potential crises.
This code combines the Purchasing Managers Index (PMI) data with two Simple Moving Averages (SMA) and some visual elements.
Let's break down how this indicator works:
1. Loading PMI Data:
The indicator loads data for the "USBCOI" symbol, which represents the PMI data. It fetches the monthly closing prices of this symbol.
2. Calculating Moving Averages:
Two Simple Moving Averages (SMAs) are calculated based on the PMI data. The first SMA, sma_usbcoi, has a length defined by the input parameter (default: 2). The second SMA, sma2_usbcoi, has a different length defined by the second input parameter (default: 14).
3. Color Coding and Thresholds:
The line color of the PMI plot is determined based on the value of the PMI. If the PMI is above 52, the color is teal; if it's below 48, the color is red; otherwise, it's gray. These threshold values are often used to identify specific conditions in the PMI data.
4. Crossing Indicator:
A key feature of this indicator is to determine if the PMI crosses the first SMA (sma_usbcoi) from top to bottom while also being above the value of 52. This is indicated by the crossedUp variable. This condition suggests a specific situation where the PMI crosses a short-term moving average while indicating strength (above 52).
5. Visual Elements:
A "💀" skull emoji is defined as skullEmoji.
The PMI is plotted on the chart with color coding based on its value, as described earlier.
The two SMAs are also plotted on the chart.
When the crossedUp condition is met (PMI crosses the first SMA from top to bottom while above 52), a skull emoji (indicating potential danger) is plotted at the top of the indicator window.