Linear and Logarithmic Fibonacci Levels and (Price&Time) FansIntroduction
The Fibonacci Retracement tool is a go-to for traders looking to spot potential support and resistance levels. By measuring the distance between swing highs and lows, you can apply Fibonacci ratios like 0.236, 0.382, and 0.618 to predict key market levels.
Traditionally, these levels are set by dividing this distance into equal parts—known as Linear Levels. A more refined approach, Logarithmic Price and Time Levels, divides the distance into proportionally equal segments. Plus, this indicator now includes Fibonacci fans, adding another layer of analysis by projecting potential price levels using trendlines based on Fibonacci ratios.
This tool makes it easier to identify both Linear and Logarithmic levels while also leveraging Fibonacci fans for a more complete market view.
Applications
Logarithmic Levels and Fibonacci fans are ideal for volatile markets. In crypto, they’re especially effective for BTCUSDT (check out the wick from January 23, 2024). They also help spot accumulation and distribution patterns in high-volume altcoins like FETUSDT . In traditional markets, they’re useful for tracking stocks like TSLA and NVDA with extreme price swings, as well as indices in inflation-affected markets like XU100 , or recession-hit currency pairs like JPYUSD .
How to Use
This indicator is intuitive and similar to TradingView’s Fibonacci Tool. Select your reference levels (Level 1 and Level 0), then tweak the settings to customize your analysis, including adding Fibonacci fans for extra insights.
Why It’s Different
Unlike TradingView’s tool, which forces you to switch to a logarithmic scale (messing with other indicators and trend lines), this indicator lets you view both Linear and Logarithmic levels—and Fibonacci fans on Price and Time Series—without changing your chart’s scale. The original Fibonacci Code was derived from zekicanozkanli, modified and upgraded to plot fib front and back fans as well. Due to TV Max Plot restrictions I need to publish just Front and Back and Front Fibs separately.
Timeseriesanalysis
TimeSeriesClassificationActivationFunctionsLibrary "TimeSeriesClassificationActivationFunctions"
Provides some activation functions useful in time series classification.
___
reference:
github.com
method scale(dist, weights)
Activate values by a normalized scale.
Namespace types: map
Parameters:
dist (map) : Source distribution map.
weights (map) : Weights distribution map.
Returns: Normalized distribution map.
method softmax(dist, weights)
Activate values with a softmax algorithm.
Namespace types: map
Parameters:
dist (map) : Source distribution map.
weights (map) : Weights distribution map.
Returns: Normalized distribution map.
method argmax(dist, weights)
Activate values with a argmax algorithm.
Namespace types: map
Parameters:
dist (map) : Source distribution map.
weights (map) : Weights distribution map.
Returns: first key of argmax value of the transformed distribution.
Absolute Momentum (Time Series Momentum)Absolute momentum , also known as time series momentum , focuses on the trend of an asset's own past performance to predict its future performance. It involves analyzing an asset's own historical performance, rather than comparing it to other assets.
The strategy determines whether an asset's price is exhibiting an upward (positive momentum) or downward (negative momentum) trend by assessing the asset's return over a given period (standard look-back period: 12 months or approximately 250 trading days). Some studies recommend calculating momentum by deducting the corresponding Treasury bill rate from the measured performance.
Absolute Momentum Indicator
The Absolute Momentum Indicator displays the rolling 12-month performance (measured over 250 trading days) and plots it against a horizontal line representing 0%. If the indicator crosses above this line, it signifies positive absolute momentum, and conversely, crossing below indicates negative momentum. An additional, optional look-back period input field can be accessed through the settings.
Hint: This indicator is a simplified version, as some academic approaches measure absolute momentum by subtracting risk-free rates from the 12-month performance. However, even with higher rates, the values will still remain close to the 0% line.
Benefits of Absolute Momentum
Absolute momentum, which should not be confused with relative momentum or the momentum indicator, serves as a timing instrument for both individual assets and entire markets.
Gary Antonacci , a key contributor to the absolute momentum strategy (find study below), emphasizes its effectiveness in multi-asset portfolios and its importance in long-only investing. This is particularly evident in a) reducing downside volatility and b) mitigating behavioral biases.
Moskowitz, Ooi, and Pedersen document significant 'time series momentum' across various asset classes, including equity index, currency, commodity, and bond futures, in 58 liquid instruments (find study below). There's a notable persistence in returns ranging from one to 12 months, which tends to partially reverse over longer periods. This pattern aligns with sentiment theories suggesting initial under-reaction followed by delayed over-reaction.
Despite its surprising ease of implementation, the academic community has successfully measured the effects of absolute momentum across decades and in every major asset class, including stocks, bonds, commodities, and foreign exchange (FX).
Strategies for Implementing Absolute Momentum:
To Buy a Stock:
Select a Look-Back Period: Choose a historical period to analyze the stock's performance. A common period is 12 months, but this can vary based on your investment strategy.
Calculate Excess Return: Determine the stock's excess return over this period. You can also assume a risk-free rate of "0" to simplify the process.
Evaluate Momentum:
If the excess return is positive, it indicates positive absolute momentum. This suggests the stock is in an upward trend and could be a good buying opportunity.
If the excess return is negative, it suggests negative momentum, and you might want to delay buying.
Consider further conditions: Align your decision with broader market trends, economic indicators, or fundamental analysis, for additional context.
To Sell a Stock You Own:
Regularly Monitor Performance: Use the same look-back period as for buying (e.g., 12 months) to regularly assess the stock's performance.
Check for Negative Momentum: Calculate the excess return for the look-back period. Again, you can assume a risk-free rate of "0" to simplify the process. If the stock shows negative momentum, it might be time to consider selling.
Consider further conditions:Align your decision with broader market trends, economic indicators, or fundamental analysis, for additional context.
Important note: Note: Entering a position (i.e., buying) based on positive absolute momentum doesn't necessarily mean you must sell it if it later exhibits negative absolute momentum. You can initiate a position using positive absolute momentum as an entry indicator and then continue holding it based on other criteria, such as fundamental analysis.
General Tips:
Reassessment Frequency: Decide how often you will reassess the momentum (monthly, quarterly, etc.).
Remember, while absolute momentum provides a systematic approach, it's recommendable to consider it as part of a broader investment strategy that includes diversification, risk management, fundamental analysis, etc.
Relevant Capital Market Studies:
Antonacci, Gary. "Absolute momentum: A simple rule-based strategy and universal trend-following overlay." Available at SSRN 2244633 (2013)
Moskowitz, Tobias J., Yao Hua Ooi, and Lasse Heje Pedersen. "Time series momentum." Journal of financial economics 104.2 (2012): 228-250
Autoregressive Covariance Oscillator by TenozenWell to be honest I don't know what to name this indicator lol. But anyway, here is my another original work! Gonna give some background of why I create this indicator, it's all pretty much a coincidence when I'm learning about time series analysis.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Well, the formula of Auto-covariance is:
E{(X(t)-(t) * (X(t-s)-(t-s))}= Y_s
But I don't multiply both values but rather subtract them:
E{(X(t)-(t) - (X(t-s)-(t-s))}= Y_s?
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
For arm_vald, the equation is as follows:
arm_vald = val_mu + mu_plus_lsm + et
val_mu --> mean of time series
mu_plus_lsm --> val_mu + LSM
et --> error term
As you can see, val_mu^2. I did this so the oscillator is much smoother.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
After I get the value, I normalize them:
aco = Y_s? / arm_vald
So by this calculation, I get something like an oscillator!
(more details in the code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
So how to use this indicator? It's so easy! If the value is above 0, we gonna expect a bullish response, if the value is below 0, we gonna expect a bearish response; that simple. Be aware that you should wait for the price to be closed before executing a trade.
Well, try it out! So far this is the most powerful indicator that I've created, hope it's useful. Ciao.
(more updates for the indicator if needed)
Autocorrelation PlotA tool to plot auto correlation of time series, this is useful in identifying periodicity in a time series or signal.
Due to the limits of Pine Script you'll need to add it multiple times if you want autocorrelation beyond 55 periods. I have added it 4 times here for 220 periods.
For more information on Autocorrelation see: en.wikipedia.org
Note: There are 1 bar gaps every 55 because I wanted the labels to remain every 5, but you don't have to have gaps....
Alpha-Sutte ModelThe Alpha-Sutte model is an ongoing project run by Ansari Saleh Ahmar, a lecturer and researcher at Universitas Negeri Makassar in Indonesia, that attempts to make forecasts for time series like how Arima and Holt-Winters models do. Currently Ahmar and his team have conducted research and published papers comparing the efficacy of the Alpha-Sutte and other models, such as Arima and Holt-Winters, on topics ranging from forecasting Turkey's CPI data, Bitcoin prices, Apple's stock prices, primary energy supply of Indonesia, to infant mortality rates in China.
The Alpha-Sutte model in comparison to the other two models listed above shows promise in providing a more accurate forecast, and the project has been able to receive some of its funding from organizations such as the US Agency for International Development, which is a part of the US Federal Government, so maybe the project has some actual merit.
How it works:
In this model there are four values presented at the top of the window.
1) The first value in blue is the value of the Alpha-Sutte model whose purpose is to forecast the price of the current bar.
2) The second value in yellow is an adaptive version of the Alpha-Sutte model that I made. The purpose of the adaptive Alpha-Sutte model is to expand upon the Alpha-Sutte by allowing new information to be introduced, causing the value to change during the current period, hence the adaptiveness of it.
3) The third value in aqua is the moving average of the low% Sutte line which is a predictive line that is based off of the close and low of the current and previous periods.
4) The fourth value in red is the moving average of the high% Sutte line which is a predictive line that is based off of the close and high of the current and previous periods.
Trend signals:
If low% Sutte (aqua value/line) is greater than high% Sutte (red value/line) then this is a buy signal.
If high% Sutte (red value/line) is greater than low% Sutte (aqua value/line) then this is a sell signal.
Caveat:
Even though this model's purpose is to forecast the future, will it be able to predict periods of large movements? No, of course not, but it will adjust quickly to try to make more accurate forecasts for the next period. This was also a reason why I made an adaptive version of this model to try to reduce some of the discrepancies between the Alpha Sutte and price when there is a large unexpected move.
*WARNING before using this I would highly recommend that you look up "Sutte Indicator" online and read some of the papers about this model before you use this , even though this model has shown merit when compared to Arima and Holt-Winter models this is still an ongoing project.*
Hopefully this project will actually come to something in the near future as the calculation for this time series predictive model is much easier to calculate and program in pine editor than something like an Arima model.
*Also, if you know how to use R language there is a package for the "Alpha-Sutte model".*