Market Structure Targets Model [LuxAlgo]The Market Structure Targets Model indicator provides an algorithmic approach to setting targets from market structure shifts (MSS) and market structure breaks (MSB), two popular Smart Money Concept (SMC) concepts. Depending on the target % settings, they can be used as take profit, confirmation levels, or potential reversal points.
🔶 USAGE
Our Market Structure Targets Model scripts provide automated and customizable targets from MSS and MSB. Each displayed target can be used in several ways described in the sub-sections below:
🔹 Take Profit
The targets can be used as take profit levels, where the target distance can be set separately for bullish/bearish MSS/MSB respectively.
🔹 Confirmation Levels
Alternatively, targets can be used as an additional confirmation level of a trend reversal when set at a lower percentage, filtering out fake signals that might be given from market structures. In this way, targets can be used as potential entry levels.
🔹 Potential Reversal Points
In some circumstances, targets being reached can be indicative of trend reversals. The percentage of the targets would be typically set higher to allow for trend exhaustion.
The above examples highlight this usage for bearish reversal scenarios, while the image below highlights it for bullish reversal scenarios.
🔹 Support/Resistance Levels
The targets, being horizontal levels, can also serve as potential support/resistances, with breakouts potentially confirming new trends. It is important to remain observant of the market structure. An MSS or MSB in the opposite direction provides essential information to be included in future decisions.
Using multiple timeframes can help detect longer-term trends. Depending on the user's preference, they can choose the appropriate timeframe for their needs.
Note that Target lines will only be drawn when the Target Level exceeds the close value when it is drawn.
🔹 Maximum Target Duration
The Maximum Target Duration setting removes unreached target levels when the amount of bars since the associated market structure of that target exceeds the user set limit. This effectively allows the removal of any target that might no longer be relevant to newer trends.
🔹 Type: Switch/Hold
This setting is another way to control unreached target levels.
Switch: When a new MSS/MSB is found, the previous target level associated with a market structure with the same direction (bullish/bearish) is deleted if it hasn't been reached.
Hold: Target levels are retained and continuously evaluated when a new MSS/MSB is formed.
The target level will be removed in both cases when the Maximum Target Duration condition is applied.
The above example shows the case when the Type setting is set to Switch , while in the example below, it is set to Hold .
🔶 DETAILS
🔹 Market Structure
Market structures are commonly classified as follows:
Market Structure Shift (MSS), also referred to as Change of Character (CHoCH)
Market Structure Break (MSB), also referred to as Break of Structure (BOS)
MSS indicates a shift in the market trend, confirming trend reversals. Conversely, MSB occurs once a trend is already determined, confirming new higher highs/lower lows.
🔹 Targets
A: Highest/lowest between the extremities of the MSS/MSB line
B: Price value of the MSS/MSB line
The distance between A and B is projected on the opposite side of the MSS/MSB line, adjusted with a percentage that can be set by the user. The above example used 100% of the distance between A and B.
The Target Percentage of MSS and MSB can be set separately for bullish or bearish market structures.
🔶 SETTINGS
Swings: Period used for the swing detection, with higher values returning longer-term Swing Levels.
Type: the Switch/Hold setting controls unattained target levels
Maximum Target Duration: removes the target lines when the amount of bars since the drawing of the target exceeds the limit and the target has not been reached
🔹 Market Structure Shift (MSS)
Bullish: Toggle, color setting, % Target
Bearish: Toggle, color setting, % Target
🔹 Market Structure Break (MSB)
Bullish: Toggle, color setting, % Target
Bearish: Toggle, color setting, % Target
Model
Returns Model by TenozenHey there! I've been diving into the book "Paul Wilmott on Quantitative Finance," and I stumbled upon this cool model for calculating and modeling returns. Basically, it helps us figure out how much a price has changed over a set number of periods—I like to use 20 periods as a default. Once we get that rate of change value, we crunch some numbers to find the standard deviation and mean using all the historical data we have. That's the foundation of this model.
Now, let's talk about how to use it. This model shows us how returns and price behavior are connected. When returns hang out in the +1 to +2 standard deviation range, it usually means returns are about to drop, and vice versa. Often, this leads to corresponding price moves. But here's the thing: sometimes prices don't do what we expect. Why? It's because there's another hidden factor at play—I like to call it "power."
This "power" isn't something we can see directly, but it's there. Basically, when returns are within that standard deviation range, the market faces resistance when trying to move in its preferred direction, whether bullish or bearish. The strength of this "power" determines if the market will snap back to the average or go for a wild ride. It can show up as small price wiggles, big price jumps, or lightning-fast moves. By understanding this "power," we can get a better handle on what the market might do next and avoid getting blindsided. In the meantime, I couldn't explain "power" yet, but In the future, when I've learned enough, I'd love to share the model with you guys!
So... I'm planning to explore and share more models from this book as I learn, even if those pesky math formulas can be tough to crack. I hope you find this indicator as helpful as I do, and if you've got any suggestions or feedback, please feel free to share! Ciao!
[TTI] MarketSmith & IBD Style Model Stock Quarters 📜 ––––HISTORY & CREDITS––––
The MarketSmith & IBD Style Model Stock Quarters another Utility indicator is an original creation by TintinTrading inspired by Investor's Business Daily and William O'Neil style of presenting information. While going through the Model Stocks that IBD has been publishing, I realized that I wanted to see the exam same Quarterly presentation on the time axis in order to compare William O'Neil notes better with my own notes from Tradingview. The script is simple and could help you if you study the CANSLIM methodology.
🦄 –––UNIQUENESS–––
The distinctiveness of this indicator lies in its ability to visually delineate stock quarters directly on the price chart. It serves as a handy tool for traders who adopt a quarterly review of stock performance, in line with MarketSmith and IBD's analysis frameworks.
🛠️ ––––WHAT IT DOES––––
Quarter Marking : Draws a black line at the beginning of each financial quarter (January, April, July, and October).
Quarter Labeling : Places a label at the close of the last month in a quarter, indicating the upcoming quarter with its abbreviation and the last two digits of the year.
💡 ––––HOW TO USE IT––––
👉Installation: Add the indicator to your TradingView chart by searching for " MarketSmith & IBD Style Model Stock Quarters" in the indicator library.
👉Add to New Pane and squash the Pane Length: I add the indicator to a new pane under the price and volume charts and squash the height of the pane so that it looks exactly like the MarketSmith visuals.
👉Visual Cues:
Look for the black lines marking the start of a new quarter.
Observe the labels indicating the upcoming quarter and year, positioned at the close of the last month in a quarter.
👉Interpretation: Use these quarterly markers to align your trading strategies with quarterly performance metrics or to conduct seasonal analysis.
👉Settings: The indicator does not require any user-defined settings, making it straightforward to use.
Normal Distribution CurveThis Normal Distribution Curve is designed to overlay a simple normal distribution curve on top of any TradingView indicator. This curve represents a probability distribution for a given dataset and can be used to gain insights into the likelihood of various data levels occurring within a specified range, providing traders and investors with a clear visualization of the distribution of values within a specific dataset. With the only inputs being the variable source and plot colour, I think this is by far the simplest and most intuitive iteration of any statistical analysis based indicator I've seen here!
Traders can quickly assess how data clusters around the mean in a bell curve and easily see the percentile frequency of the data; or perhaps with both and upper and lower peaks identify likely periods of upcoming volatility or mean reversion. Facilitating the identification of outliers was my main purpose when creating this tool, I believed fixed values for upper/lower bounds within most indicators are too static and do not dynamically fit the vastly different movements of all assets and timeframes - and being able to easily understand the spread of information simplifies the process of identifying key regions to take action.
The curve's tails, representing the extreme percentiles, can help identify outliers and potential areas of price reversal or trend acceleration. For example using the RSI which typically has static levels of 70 and 30, which will be breached considerably more on a less liquid or more volatile asset and therefore reduce the actionable effectiveness of the indicator, likewise for an asset with little to no directional volatility failing to ever reach this overbought/oversold areas. It makes considerably more sense to look for the top/bottom 5% or 10% levels of outlying data which are automatically calculated with this indicator, and may be a noticeable distance from the 70 and 30 values, as regions to be observing for your investing.
This normal distribution curve employs percentile linear interpolation to calculate the distribution. This interpolation technique considers the nearest data points and calculates the price values between them. This process ensures a smooth curve that accurately represents the probability distribution, even for percentiles not directly present in the original dataset; and applicable to any asset regardless of timeframe. The lookback period is set to a value of 5000 which should ensure ample data is taken into calculation and consideration without surpassing any TradingView constraints and limitations, for datasets smaller than this the indicator will adjust the length to just include all data. The labels providing the percentile and average levels can also be removed in the style tab if preferred.
Additionally, as an unplanned benefit is its applicability to the underlying price data as well as any derived indicators. Turning it into something comparable to a volume profile indicator but based on the time an assets price was within a specific range as opposed to the volume. This can therefore be used as a tool for identifying potential support and resistance zones, as well as areas that mark market inefficiencies as price rapidly accelerated through. This may then give a cleaner outlook as it eliminates the potential drawbacks of volume based profiles that maybe don't collate all exchange data or are misrepresented due to large unforeseen increases/decreases underlying capital inflows/outflows.
Thanks to @ALifeToMake, @Bjorgum, vgladkov on stackoverflow (and possibly some chatGPT!) for all the assistance in bringing this indicator to life. I really hope every user can find some use from this and help bring a unique and data driven perspective to their decision making. And make sure to please share any original implementaions of this tool too! If you've managed to apply this to the average price change once you've entered your position to better manage your trade management, or maybe overlaying on an implied volatility indicator to identify potential options arbitrage opportunities; let me know! And of course if anyone has any issues, questions, queries or requests please feel free to reach out! Thanks and enjoy.
Harmonic Sine Waves model plot Hey,
Here is another tool that I created. I could not find anything similar.
This script is creating a sine wave, based on the given length, amplitude, horizontal vertical offset.
After this it plots also nearest harmonics to the base sine wave and draws it on the chart.
At the last step it sums up the value for base sine wave with its harmonics.
This is a great way to experience how 4 basic sine waves, when summed up, are creating more complex chart.
This shows that the 'chaotic' chart can be built on just a few most important factors.
You do not have to "know every single fact" about the asset to make a proper forecast.
You just need those most important.
It is crucial though, to offset the chart in a correct way, so it is in phase with the asset that we work on.
FunctionBlackScholesLibrary "FunctionBlackScholes"
Some methods for the Black Scholes Options Model, which demonstrates several approaches to the valuation of a European call.
// reference:
// people.math.sc.edu
// people.math.sc.edu
asset_path(s0, mu, sigma, t1, n) Simulates the behavior of an asset price over time.
Parameters:
s0 : float, asset price at time 0.
mu : float, growth rate.
sigma : float, volatility.
t1 : float, time to expiry date.
n : int, time steps to expiry date.
Returns: option values at each equal timed step (0 -> t1)
binomial(s0, e, r, sigma, t1, m) Uses the binomial method for a European call.
Parameters:
s0 : float, asset price at time 0.
e : float, exercise price.
r : float, interest rate.
sigma : float, volatility.
t1 : float, time to expiry date.
m : int, time steps to expiry date.
Returns: option value at time 0.
bsf(s0, t0, e, r, sigma, t1) Evaluates the Black-Scholes formula for a European call.
Parameters:
s0 : float, asset price at time 0.
t0 : float, time at which the price is known.
e : float, exercise price.
r : float, interest rate.
sigma : float, volatility.
t1 : float, time to expiry date.
Returns: option value at time 0.
forward(e, r, sigma, t1, nx, nt, smax) Forward difference method to value a European call option.
Parameters:
e : float, exercise price.
r : float, interest rate.
sigma : float, volatility.
t1 : float, time to expiry date.
nx : int, number of space steps in interval (0, L).
nt : int, number of time steps.
smax : float, maximum value of S to consider.
Returns: option values for the european call, float array of size ((nx-1) * (nt+1)).
mc(s0, e, r, sigma, t1, m) Uses Monte Carlo valuation on a European call.
Parameters:
s0 : float, asset price at time 0.
e : float, exercise price.
r : float, interest rate.
sigma : float, volatility.
t1 : float, time to expiry date.
m : int, time steps to expiry date.
Returns: confidence interval for the estimated range of valuation.
vix_vx_regressionAn example of the linear regression library, showing the regression of VX futures on the VIX. The beta might help you weight VX futures when hedging SPX vega exposure. A VX future has point multiplier of 1000, whereas SPX options have a point multiplier of 100. Suppose the front month VX future has a beta of 0.6 and the front month SPX straddle has a vega of 8.5. Using these approximations, the VX future will underhedge the SPX straddle, since (0.6 * 1000) < (8.5 * 100). The position will have about 2.5 ($250) vega. Use the R^2 (coefficient of determination) to check how well the model fits the relationship between VX and VIX. The further from one this value, the less useful the model.
(Note that the mini, VXM futures also have a 100 point multiplier).
Ripple (XRP) Model PriceAn article titled Bitcoin Stock-to-Flow Model was published in March 2019 by "PlanB" with mathematical model used to calculate Bitcoin model price during the time. We know that Ripple has a strong correlation with Bitcoin. But does this correlation have a definite rule?
In this study, we examine the relationship between bitcoin's stock-to-flow ratio and the ripple(XRP) price.
The Halving and the stock-to-flow ratio
Stock-to-flow is defined as a relationship between production and current stock that is out there.
SF = stock / flow
The term "halving" as it relates to Bitcoin has to do with how many Bitcoin tokens are found in a newly created block. Back in 2009, when Bitcoin launched, each block contained 50 BTC, but this amount was set to be reduced by 50% every 210,000 blocks (about 4 years). Today, there have been three halving events, and a block now only contains 6.25 BTC. When the next halving occurs, a block will only contain 3.125 BTC. Halving events will continue until the reward for minors reaches 0 BTC.
With each halving, the stock-to-flow ratio increased and Bitcoin experienced a huge bull market that absolutely crushed its previous all-time high. But what exactly does this affect the price of Ripple?
Price Model
I have used Bitcoin's stock-to-flow ratio and Ripple's price data from April 1, 2014 to November 3, 2021 (Daily Close-Price) as the statistical population.
Then I used linear regression to determine the relationship between the natural logarithm of the Ripple price and the natural logarithm of the Bitcoin's stock-to-flow (BSF).
You can see the results in the image below:
Basic Equation : ln(Model Price) = 3.2977 * ln(BSF) - 12.13
The high R-Squared value (R2 = 0.83) indicates a large positive linear association.
Then I "winsorized" the statistical data to limit extreme values to reduce the effect of possibly spurious outliers (This process affected less than 4.5% of the total price data).
ln(Model Price) = 3.3297 * ln(BSF) - 12.214
If we raise the both sides of the equation to the power of e, we will have:
============================================
Final Equation:
■ Model Price = Exp(- 12.214) * BSF ^ 3.3297
Where BSF is Bitcoin's stock-to-flow
============================================
If we put current Bitcoin's stock-to-flow value (54.2) into this equation we get value of 2.95USD. This is the price which is indicated by the model.
There is a power law relationship between the market price and Bitcoin's stock-to-flow (BSF). Power laws are interesting because they reveal an underlying regularity in the properties of seemingly random complex systems.
I plotted XRP model price (black) over time on the chart.
Estimating the range of price movements
I also used several bands to estimate the range of price movements and used the residual standard deviation to determine the equation for those bands.
Residual STDEV = 0.82188
ln(First-Upper-Band) = 3.3297 * ln(BSF) - 12.214 + Residual STDEV =>
ln(First-Upper-Band) = 3.3297 * ln(BSF) – 11.392 =>
■ First-Upper-Band = Exp(-11.392) * BSF ^ 3.3297
In the same way:
■ First-Lower-Band = Exp(-13.036) * BSF ^ 3.3297
I also used twice the residual standard deviation to define two extra bands:
■ Second-Upper-Band = Exp(-10.570) * BSF ^ 3.3297
■ Second-Lower-Band = Exp(-13.858) * BSF ^ 3.3297
These bands can be used to determine overbought and oversold levels.
Estimating of the future price movements
Because we know that every four years the stock-to-flow ratio, or current circulation relative to new supply, doubles, this metric can be plotted into the future.
At the time of the next halving event, Bitcoins will be produced at a rate of 450 BTC / day. There will be around 19,900,000 coins in circulation by August 2025
It is estimated that during first year of Bitcoin (2009) Satoshi Nakamoto (Bitcoin creator) mined around 1 million Bitcoins and did not move them until today. It can be debated if those coins might be lost or Satoshi is just waiting still to sell them but the fact is that they are not moving at all ever since. We simply decrease stock amount for 1 million BTC so stock to flow value would be:
BSF = (19,900,000 – 1.000.000) / (450 * 365) =115.07
Thus, Bitcoin's stock-to-flow will increase to around 115 until AUG 2025. If we put this number in the equation:
Model Price = Exp(- 12.214) * 114 ^ 3.3297 = 36.06$
Ripple has a fixed supply rate. In AUG 2025, the total number of coins in circulation will be about 56,000,000,000. According to the equation, Ripple's market cap will reach $2 trillion.
Note that these studies have been conducted only to better understand price movements and are not a financial advice.
vol_bracketThis simple script shows an "N" standard deviation volatility bracket, anchored at the opening price of the current month, week, or quarter. This anchor is meant to coincide roughly with the expiration of options issued at the same interval. You can choose between a manually-entered IV or the hv30 volatility model.
Unlike my previous scripts, which all show the volatility bracket as a rolling figure, the anchor helps to visualize the volatility estimate in relation to price as it ranges over the (approximate) lifetime of a single, real contract.
[e2] Fourier series Model Of The MarketFourier series Model Of The Market
John F. Ehlers
TASC Jun 2019