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.
Phase
Poly Cycle [Loxx]This is an example of what can be done by combining Legendre polynomials and analytic signals. I get a way of determining a smooth period and relative adaptive strength indicator without adding time lag.
This indicator displays the following:
The Least Squares fit of a polynomial to a DC subtracted time series - a best fit to a cycle.
The normalized analytic signal of the cycle (signal and quadrature).
The Phase shift of the analytic signal per bar.
The Period and HalfPeriod lengths, in bars of the current cycle.
A relative strength indicator of the time series over the cycle length. That is, adaptive relative strength over the cycle length.
The Relative Strength Indicator, is adaptive to the time series, and it can be smoothed by increasing the length of decreasing the number of degrees of freedom.
Other adaptive indicators based upon the period and can be similarly constructed.
There is some new math here, so I have broken the story up into 5 Parts:
Part 1:
Any time series can be decomposed into a orthogonal set of polynomials .
This is just math and here are some good references:
Legendre polynomials - Wikipedia, the free encyclopedia
Peter Seffen, "On Digital Smoothing Filters: A Brief Review of Closed Form Solutions and Two New Filter Approaches", Circuits Systems Signal Process, Vol. 5, No 2, 1986
I gave some thought to what should be done with this and came to the conclusion that they can be used for basic smoothing of time series. For the analysis below, I decompose a time series into a low number of degrees of freedom and discard the zero mode to introduce smoothing.
That is:
time series => c_1 t + c_2 t^2 ... c_Max t^Max
This is the cycle. By construction, the cycle does not have a zero mode and more physically, I am defining the "Trend" to be the zero mode.
The data for the cycle and the fit of the cycle can be viewed by setting
ShowDataAndFit = TRUE;
There, you will see the fit of the last bar as well as the time series of the leading edge of the fits. If you don't know what I mean by the "leading edge", please see some of the postings in . The leading edges are in grayscale, and the fit of the last bar is in color.
I have chosen Length = 17 and Degree = 4 as the default. I am simply making sure by eye that the fit is reasonably good and degree 4 is the lowest polynomial that can represent a sine-like wave, and 17 is the smallest length that lets me calculate the Phase Shift (Part 3 below) using the Hilbert Transform of width=7 (Part 2 below).
Depending upon the fit you make, you will capture different cycles in the data. A fit that is too "smooth" will not see the smaller cycles, and a fit that is too "choppy" will not see the longer ones. The idea is to use the fit to try to suppress the smaller noise cycles while keeping larger signal cycles.
Part 2:
Every time series has an Analytic Signal, defined by applying the Hilbert Transform to it. You can think of the original time series as amplitude * cosine(theta) and the transformed series, called the quadrature, can be thought of as amplitude * sine(theta). By taking the ratio, you can get the angle theta, and this is exactly what was done by John Ehlers in . It lets you get a frequency out of the time series under consideration.
Amazon.com: Rocket Science for Traders: Digital Signal Processing Applications (9780471405672): John F. Ehlers: Books
It helps to have more references to understand this. There is a nice article on Wikipedia on it.
Read the part about the discrete Hilbert Transform:
en.wikipedia.org
If you really want to understand how to go from continuous to discrete, look up this article written by Richard Lyons:
www.dspguru.com
In the indicator below, I am calculating the normalized analytic signal, which can be written as:
s + i h where i is the imagery number, and s^2 + h^2 = 1;
s= signal = cosine(theta)
h = Hilbert transformed signal = quadrature = sine(theta)
The angle is therefore given by theta = arctan(h/s);
The analytic signal leading edge and the fit of the last bar of the cycle can be viewed by setting
ShowAnalyticSignal = TRUE;
The leading edges are in grayscale fit to the last bar is in color. Light (yellow) is the s term, and Dark (orange) is the quadrature (hilbert transform). Note that for every bar, s^2 + h^2 = 1 , by construction.
I am using a width = 7 Hilbert transform, just like Ehlers. (But you can adjust it if you want.) This transform has a 7 bar lag. I have put the lag into the plot statements, so the cycle info should be quite good at displaying minima and maxima (extrema).
Part 3:
The Phase shift is the amount of phase change from bar to bar.
It is a discrete unitary transformation that takes s + i h to s + i h
explicitly, T = (s+ih)*(s -ih ) , since s *s + h *h = 1.
writing it out, we find that T = T1 + iT2
where T1 = s*s + h*h and T2 = s*h -h*s
and the phase shift is given by PhaseShift = arctan(T2/T1);
Alas, I have no reference for this, all I doing is finding the rotation what takes the analytic signal at bar to the analytic signal at bar . T is the transfer matrix.
Of interest is the PhaseShift from the closest two bars to the present, given by the bar and bar since I am using a width=7 Hilbert transform, bar is the earliest bar with an analytic signal.
I store the phase shift from bar to bar as a time series called PhaseShift. It basically gives you the (7-bar delayed) leading edge the amount of phase angle change in the series.
You can see it by setting
ShowPhaseShift=TRUE
The green points are positive phase shifts and red points are negative phase shifts.
On most charts, I have looked at, the indicator is mostly green, but occasionally, the stock "retrogrades" and red appears. This happens when the cycle is "broken" and the cycle length starts to expand as a trend occurs.
Part 4:
The Period:
The Period is the number of bars required to generate a sum of PhaseShifts equal to 360 degrees.
The Half-period is the number of bars required to generate a sum of phase shifts equal to 180 degrees. It is usually not equal to 1/2 of the period.
You can see the Period and Half-period by setting
ShowPeriod=TRUE
The code is very simple here:
Value1=0;
Value2=0;
while Value1 < bar_index and math.abs(Value2) < 360 begin
Value2 = Value2 + PhaseShift ;
Value1 = Value1 + 1;
end;
Period = Value1;
The period is sensitive to the input length and degree values but not overly so. Any insight on this would be appreciated.
Part 5:
The Relative Strength indicator:
The Relative Strength is just the current value of the series minus the minimum over the last cycle divided by the maximum - minimum over the last cycle, normalized between +1 and -1.
RelativeStrength = -1 + 2*(Series-Min)/(Max-Min);
It therefore tells you where the current bar is relative to the cycle. If you want to smooth the indicator, then extend the period and/or reduce the polynomial degree.
In code:
NewLength = floor(Period + HilbertWidth+1);
Max = highest(Series,NewLength);
Min = lowest(Series,NewLength);
if Max>Min then
Note that the variable NewLength includes the lag that comes from the Hilbert transform, (HilbertWidth=7 by default).
Conclusion:
This is an example of what can be done by combining Legendre polynomials and analytic signals to determine a smooth period without adding time lag.
________________________________
Changes in this one : instead of using true/false options for every single way to display, use Type parameter as following :
1. The Least Squares fit of a polynomial to a DC subtracted time series - a best fit to a cycle.
2. The normalized analytic signal of the cycle (signal and quadrature).
3. The Phase shift of the analytic signal per bar.
4. The Period and HalfPeriod lengths, in bars of the current cycle.
5. A relative strength indicator of the time series over the cycle length. That is, adaptive relative strength over the cycle length.
Ehlers Instantaneous Phase Dominant Cycle [CC]The Instantaneous Phase Dominant Cycle was created by John Ehlers (Stocks & Commodities V. 18:3 (16-27)) and this is one of many similar indicators that I will be publishing from Ehlers in the next few months that calculate the current dominant cycle period. The cycle period can be used in multiple ways but generally this means that if the stock is currently at a low then the current cycle period will tell you when the next lowest low will get hit or vice versa. This is also useful for using this cycle period as an input for other indicators to provide a very good adaptive length. Let me know how you wind up using these indicators in your daily trading. I have included the same buy and sell signals from my recent Hilbert Transform and so buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
Phase CalculationPhase Calculation was authored by John F. Elders in the Stocks and Commodities Magazine 11/1996
This indicator will tell you if the stock is in a uptrend or downtrend. A phase number with a low number means it is in a uptrend and a phase number with a high number means it is in a downtrend.
Let me know if you want to see me write code for different indicators!
Moon Phase This Script is calculating the Moon Phase IE full moon and new moon. In the past most of the time during these times the price action does a nice size move either up or down depending on the current trend that we are in. the New Moon and Full Moon are indicated by color and a moon printed on the chart.
(16) DRAGON-X VS-148The Dragon is an experimental indicator that is currently still under development. I called this indicator the Dragon because, not unlike the movie and book; “How to train your Dragon”, you must adjust or dial in this indicator (train it) to get good entry/exit signals out of it, for each individual equity you want to examine. That is not nearly as convenient as all of my other indicators, but the extra work can be worth the effort. The benefits of this indicator are its responsive nature and it forecasting ability. In the inputs the algorithm allows you to select a forecasting option. Forecasting in this instance merely means shifting the resulting indicator projections forward by altering the algorithm to be looser. It can fairly accurately forecast 1 to 3 bars forward. The more forward you set the adjustment the less accurate it becomes. John Ehlers was the first person to transform Dr. Voss’s algorithm into an equity trading indicatory. His observations about forecasting are important. While the Voss filter “can’t it really look into the future, it can provide signals in advance of signals used by other traders – and that may be enough to create a successful trading edge.”
As the image below demonstrates the Dragon does indeed get you into and our of trades in advance of even our best indicator, Genie-Cycles, shown below the Dragon.
The second issue regarding this indicator is, it’s not easy to understand the rational behind it. The Dragon filter is a direct derivative of the Voss Predictive Filter. Dr. Voss describes this filter as “A filter for universal real-time prediction of band-limited signals” This algorithm was developed to provide greater resolution and insight into a wide class of signals generated by deterministic or stochastic systems. It attempts to remove group and phase delays from the Weighted Moving Average output. One of Dr. Voss’s fields of endeavor is working to make MRI images clearer. This is done by extracting the first harmonic of the output using a bandpass filter and then applying a "negative-delay" formula to it. Forecasting financial time series is regarded as one of the most challenging applications of time series prediction due to their dynamic nature.
We have more information on our website describing this indicator as well as three links to reference articles that describe the scientific concept underpinning this indicator.
In the image below, the Dragon Indicator is plotted below the price chart so you can see the correlation between the two. If you examine the last two entry signals you can clearly see that the Dragon flags an entry position very early in the turning point transition shift. Actually, at points in the chart that do not in any way look like the end of the last down leg of the cycle. This get you into a trade before most of the rest of the other market competitors.
We consider the Dragon to still be under development. It requires a narrow band width of input data, for the output to generate reliably accurate signals. Market data has unlimited bandwidth.
Our future development of this indicator will take two center of gravity filters and first narrow that resulting bandwidth by utilizing a pass band filter. We will than use this data as an input to the Voss algorithm. We will advise all of our user when this updated version is available. Currentely this experimental version is only available to our unlimited members.
Access this Genie indicator for your Tradingview account, through our web site. (Links Below) This will provide you with additional educational information and reference articles, videos, input and setting options and trading strategies this indicator excels in.
CryptoField - TREND Mode indicatorThe CryptoField TREND Mode indicator identifies the trend direction (uptrend or downtrend) and the mode (trending or sideways) of the market.
Uptrend when green
Downtrend when red
Sideways when orange
Trending when green or red
Basically the indicator works like a double moving average, but the algorithm reacts faster on movements and it tolerates "noisy"/volatile markets better which makes it more effective on crypto markets.
It can be applied to strategies or other indicators as a trend direction or market mode filter.
Bullish/Bearish PhasesHello traders!
This indicator shows you bullish or bearish dominance during the specified period and is based on the volume calculations. Why? Volume acts as an excellent confirmation tool of the price movements and is used to determine if an instrument is gaining or losing momentum.
Bullish/Bearish Phases can be used to find out divergences with the price. It will work on ANY instrument that has available volume data.
NOTE : The blue circles appear on the local peaks.
I attached some screenshots to show you how it works with other instruments.
How to get access
Buy for only 149$ to get lifetime access to this indicator.
Like and follow for more cool indicators!
Happy Trading!
MESA Phase [SHK]MESA Phase (By John Ehlers) is a cyclic indicator that predicts market short-term and mid-term movements. It would give you clear divergence signals or you can use it as a price reversal detection indicator.
Please share us any tricks or new useful methods that you determined by using this indicator.
Phase Change IndexPhase Change Index script.
This indicator was developed and described by M. H. Pee (Stocks & Commodities V.22:5 (28-37): Phase Change Index).
Other indicators of M. H. Pee:
Ehlers MESA Adaptive Moving Averages (MAMA & FAMA)Ehlers MESA Adaptive Moving Averages (MAMA & FAMA) script.
These indicators was originally developed by John F. Ehlers (Stocks & Commodities V. 19:10: MESA Adaptive Moving Averages).