Fourier Extrapolator of Price w/ Projection Forecast [Loxx]Due to popular demand, I'm pusblishing Fourier Extrapolator of Price w/ Projection Forecast.. As stated in it's twin indicator, this one is also multi-harmonic (or multi-tone) trigonometric model of a price series xi, i=1..n, is given by:
xi = m + Sum( a*Cos(w*i) + b*Sin(w*i), h=1..H )
Where:
xi - past price at i-th bar, total n past prices;
m - bias;
a and b - scaling coefficients of harmonics;
w - frequency of a harmonic ;
h - harmonic number;
H - total number of fitted harmonics.
Fitting this model means finding m, a, b, and w that make the modeled values to be close to real values. Finding the harmonic frequencies w is the most difficult part of fitting a trigonometric model. In the case of a Fourier series, these frequencies are set at 2*pi*h/n. But, the Fourier series extrapolation means simply repeating the n past prices into the future.
This indicator uses the Quinn-Fernandes algorithm to find the harmonic frequencies. It fits harmonics of the trigonometric series one by one until the specified total number of harmonics H is reached. After fitting a new harmonic , the coded algorithm computes the residue between the updated model and the real values and fits a new harmonic to the residue.
see here: A Fast Efficient Technique for the Estimation of Frequency , B. G. Quinn and J. M. Fernandes, Biometrika, Vol. 78, No. 3 (Sep., 1991), pp . 489-497 (9 pages) Published By: Oxford University Press
The indicator has the following input parameters:
src - input source
npast - number of past bars, to which trigonometric series is fitted;
Nfut - number of predicted future bars;
nharm - total number of harmonics in model;
frqtol - tolerance of frequency calculations.
The indicator plots two curves: the green/red curve indicates modeled past values and the yellow/fuchsia curve indicates the modeled future values.
The purpose of this indicator is to showcase the Fourier Extrapolator method to be used in future indicators.
Harmonic Patterns
Fourier Extrapolator of Price [Loxx]Fourier Extrapolator of Price is a multi-harmonic (or multi-tone) trigonometric model of a price series xi, i=1..n, is given by:
xi = m + Sum( a *Cos(w *i) + b *Sin(w *i), h=1..H )
Where:
xi - past price at i-th bar, total n past prices;
m - bias;
a and b - scaling coefficients of harmonics;
w - frequency of a harmonic;
h - harmonic number;
H - total number of fitted harmonics.
Fitting this model means finding m, a , b , and w that make the modeled values to be close to real values. Finding the harmonic frequencies w is the most difficult part of fitting a trigonometric model. In the case of a Fourier series, these frequencies are set at 2*pi*h/n. But, the Fourier series extrapolation means simply repeating the n past prices into the future.
This indicator uses the Quinn-Fernandes algorithm to find the harmonic frequencies. It fits harmonics of the trigonometric series one by one until the specified total number of harmonics H is reached. After fitting a new harmonic, the coded algorithm computes the residue between the updated model and the real values and fits a new harmonic to the residue.
see here: A Fast Efficient Technique for the Estimation of Frequency , B. G. Quinn and J. M. Fernandes, Biometrika, Vol. 78, No. 3 (Sep., 1991), pp. 489-497 (9 pages) Published By: Oxford University Press
The indicator has the following input parameters:
src - input source
npast - number of past bars, to which trigonometric series is fitted;
nharm - total number of harmonics in model;
frqtol - tolerance of frequency calculations.
The indicator plots the modeled past values
The purpose of this indicator is to showcase the Fourier Extrapolator method to be used in future indicators. While this method can also prediction future price movements, for our purpose here we will avoid doing.
Regression Channel Alternative MTF█ OVERVIEW
This indicator displays 3 timeframes of parallel channel using linear regression calculation to assist manual drawing of chart patterns.
This indicator is not true Multi Timeframe (MTF) but considered as Alternative MTF which calculate 100 bars for Primary MTF, can be refer from provided line helper.
The timeframe scenarios are defined based on Position, Swing and Intraday Trader.
█ INSPIRATIONS
These timeframe scenarios are defined based on Harmonic Trading : Volume Three written by Scott M Carney.
By applying channel on each timeframe, MW or ABCD patterns can be easily identified manually.
This can also be applied on other chart patterns.
█ CREDITS
Scott M Carney, Harmonic Trading : Volume Three (Reaction vs. Reversal)
█ TIMEFRAME EXPLAINED
Higher / Distal : The (next) longer or larger comparative timeframe after primary pattern has been identified.
Primary / Clear : Timeframe that possess the clearest pattern structure.
Lower / Proximate : The (next) shorter timeframe after primary pattern has been identified.
Lowest : Check primary timeframe as main reference.
█ EXAMPLE OF USAGE / EXPLAINATION
Deep FinderThis indicator shows you the most convenient buying times. It helps you lower your average and earn high profits by purchasing incrementally.
HarmonicCalculation█ OVERVIEW
This library is complementary for XABCD Harmonic Pattern Custom Range Interactive
PriceDiff()
: Price Difference
Parameters:
: : price_1, price_2
Returns: : PriceDiff
TimeDiff()
: Time Difference
Parameters:
: : time_1, time_2
Returns: : TimeDiff
ReturnIndexOf3Arrays()
: Return Index Of 3 Arrays
Parameters:
: : id1, id2, id3, _int
Returns: : ReturnIndexOf3Arrays
AbsoluteRange()
: Price Difference
Parameters:
: : price, y, point
Returns: : AbsoluteRange
PriceAverage()
: To calculate average of 2 prices
Parameters:
: : price_1, price_2
Returns: : PriceAverage
TimeAverage()
: To calculate average of 2 times
Parameters:
: : time_1, time_2
Returns: : TimeAverage
StringBool()
: To show ratio in 3 decimals format
Parameters:
: : _value, _bool, _text
Returns: : StringBool
PricePercent()
: To show Price in percent format
Parameters:
: : _price, PriceRef, str_dir
Returns: : PricePercent
BoolCurrency()
: To show syminfo.currency
Parameters:
: : _bool
Returns: : BoolCurrency
RatioText()
: To show RatioText in 3 decimals format
Parameters:
: : _value, _text
Returns: : RatioText
RangeText()
: To display RangeText in Harmonic Range Format
Parameters:
: : _id1, _id2, _int, _text
Returns: : RangeText
PriceCurrency()
: To show Currency in Price Format
Parameters:
: : _bool, _value
Returns: : PriceCurrency
HarmonicDB█ OVERVIEW
This library was to showcase database for specifications of Harmonic Patterns using arrays.
█ CREDITS
Scott M Carney, author of Harmonic Trading : Volume Three
animal_db(x)
TODO: export animal_db
Parameters:
x : TODO: float value is set to default if not necessary
Returns: TODO:
Harmonic Table Combo Point B█ OVERVIEW
This indicator was intended as educational purpose only and alternative way to show value in table as shown in Harmonic Pattern Possibility Table .
█ CREDITS
Credit to Scott M Carney, Harmonic Trading Volume 3: Reaction vs. Reversal.
█ USAGE EXAMPLE
Wolfe Scanner (Multi - zigzag) [HeWhoMustNotBeNamed]Before getting into the script, I would like to explain bit of history around this project. Wolfe was in the back of my mind for some time and I had several attempts so far.
🎯Initial Attempt
When I first developed harmonic patterns, I got many requests from users to develop script to automatically detect Wolfe formation. I thought it would be easy and started boasting everywhere that I am going to attempt this next. However I miserably failed that time and started realising it is not as simple as I thought it would be. I started with Wolfe in mind. But, ran into issues with loops. Soon figured out that finding and drawing wedge is more trickier. I decided will explore trendline first so that it can help find wedge better. Soon, the project turned into something else and resulted in Auto-TrendLines-HeWhoMustNotBeNamed and Wolfe left forgotten.
🎯Using predefined ratios
Wolfe also has predefined fib ratios which we can use to calculate the formation. But, upon initial development, it did not convince me that it matches visual inspection of Wolfe all the time. Hence, I decided to fall back on finding wedge first.
🎯 Further exploration in finding wedge
This attempt was not too bad. I did not try to jump into Wolfe and nor I bragged anywhere about attempting anything of this sort. My target this time was to find how to derive wedge. I knew then that if I manage to calculate wedge in efficient way, it can help further in finding Wolfe. While doing that, ended up deriving Wedge-and-Flag-Finder-Multi-zigzag - which is not a bad outcome. I got few reminders on Wolfe after this both in comments and in PM.
🎯You never fail until you stop trying!!
After 2 back to back hectic 50hr work weeks + other commitments, I thought I will spend some time on this. Took less than half weekend and here we are. I was surprised how much little time it took in this attempt. But, the plan was running in my subconscious for several weeks or even months. Last two days were just putting these plans into an action.
Now, let's discuss about the script.
🎲 Wolfe Concept
Wolfe concept is simple. Whenever a wedge is formed, draw a line joining pivot 1 and 4 as shown in the chart below:
Converging trendline forms the stop loss whereas line joining pivots 1 and 4 form the profit taking points.
🎲 Settings
Settings are pretty straightforward. Explained in the chart below.
Harmonic Pattern Possibility Table█ OVERVIEW
This indicator was intended as educational purpose only based on Harmonic Pattern Table (Source Code) and Ratio For Harmonic Points to show Harmonic Pattern Possibility.
█ INSPIRATION
This indicator was build upon realizing there are some overlap for B = XA among Alternate Bat, Bat, Crab and Gartley.
Hence, the values split up to showcase the possibility of non overlap ratio.
█ USAGE
Possible pattern, priority pattern and selected pattern may differs based value input.
Therefore C = AB, D = BC, D = XA and Stop Loss will change based value input and also selected pattern.
█ CREDITS
Credit to Scott M Carney, Harmonic Trading Volume 3: Reaction vs. Reversal.
Crab Range FinderFinds the "crab range" of current price action.
///////
The lines corresponds are follows:
Green line represents the average high price
Orange line represents the median price
Yellow line represents the average low price
///////
By default, the last 5 bars are used when calculating the price lines, this value can be changed in settings as needed to tune for accuracy.
Ratio For Harmonic Points█ OVERVIEW
This indicator was intended as educational purpose only based on Harmonic Pattern Table (Source Code) to show indication of ratio for each Harmonic points from Point B until Stop Loss.
█ CREDITS
Credit to Scott M Carney, Harmonic Trading Volume 3: Reaction vs. Reversal.
█ USAGE EXAMPLE
Wedge and Flag Finder (Multi - zigzag)Here is a small attempt to automatically identify wedges and flags.
Tradingview standard wedge checks for only 4 pivots. In this version, I have considered 5 pivots instead - which can help reduce noise as 4 pivots forming wedge can be quite common. In future, will also try to add more pivots in pattern recognition to make the signal more accurate.
If wedge comes with a tail, then it is marked as flag :)
Settings are quite simple and they are as shown below
CyclesTime based indicator attempting to show changes in a cycle based on the different time elapsed between new highs and new lows in a given time period. Useful when combined with elliott wave price structure. A drop above/below 0 suggests a wave 4 whilst new highs/lows of the indicator suggest whether a bullish or bearish trend is in place. You can change the time cycle as you like. Any Q's please post, i'll be happy to answer them. (If I can)
Manual Harmonic Projections - With interactive inputsThis is another script involving interactive inputs. This is similar to Manual-Harmonic-Patterns-With-interactive-inputs . But, instead of taking XABCD and verifying if it confirms to any pattern, here we only take XABC and project all PRZs.
Example, upon adding the script to chart, it will prompt to select 4 points on chart by clicking on it. if we select X, A, B, C as shown in the chart below, we can see the projection of multiple PRZs. Mid of nearest PRZ is considered as D and rest of the pattern is drawn based on this. However, the pattern can have multiple PRZs. All overlapping PRZs are combined together and shown as one along with merged pattern labels. But, if there is gap between PRZs, they are shown separately.
If no projections found, then patterns and projections are not drawn. However, you can still see XABC lines on the chart.
Manual Harmonic Patterns - With interactive inputsThis script is a drawing tool which allows users to draw XABCD on the chart and script will tell whether there is any harmonic patterns on the drawings made. The script is based on interactive inputs and requires users to chose XABCD points.
Please note
This is not a scanner and it will not scan historical bars for harmonic patterns. This needs to be used rather as drawing tool instead.
Script will not check if selected pivots are correct. It assumes users to know how to select the right XABCD based on pivot high/lows. Bullish pattern will have X, B and D as pivot lows and A,C as pivot highs. Similarly bearish patterns will have X, B, D as pivot highs and A, C as pivot lows.
Script will not check for overflow conditions. For example, if price crosses, XB or BD line, then pattern is considered to be invalid. But, this check cannot be made in this script and we require users to be aware of this condition and select input accordingly.
Order of inputs should be in ascending order. X pivot should come before A and then, B, C, D and F. This again is users responsibility to select pivots in right order.
What happens after selecting XABCD?
If selected pattern is valid harmonic pattern, it will
Draw XABCD lines and labels
Fill harmonic triangles
Show PRZ box which shoes the name of valid patterns.
If it is not valid harmonic pattern, then users will see blank XABCD line without any PRZ or filled harmonic triangles.
Example:
1. When it is valid pattern
2. When it is not valid pattern
Harmonic Pattern Educational Volume 2 (Source Code)This indicator was intended as educational purpose only for Harmonic Patterns using XABCD Pattern Tool.
This indicator was build upon Harmonic Trading : Volume Two, which was continuation from Harmonic Trading : Volume One and The Harmonic Trader, written by Scott M Carney.
Explaination was similar to previous build, build 0 and build 1 .
Volume 2 introduce Harmonic Ratio Progression, which result new patterns such as 5-0 and Alternate Bat.
Indikator ini bertujuan sebagai pendidikan sahaja untuk Harmonic Pattern menggunakan XABCD Pattern Tool.
Indikator ini dibina berdasarkan buku Harmonic Trading : Volume Two, juga sambungan daripada Harmonic Trading : Volume One and The Harmonic Trader, ditulis oleh Scott M Carney.
Penerangan yang sama berdasarkan binaan lepas, build 0 and build 1 .
Volume 2 memperkenalkan Harmonic Ratio Progression, membolehkan pattern baru seperti 5-0 dan Alternate Bat.
Indicator features :
1. List XAB=CD patterns including ratio and reference page.
2. For desktop display only, not for mobile.
Kemampuan indikator :
1. Senarai XAB=CD pattern termasuk ratio and rujukan muka surat.
2. Untuk paparan desktop sahaja, bukan untuk mobile.
FAQ
1. Credits / Kredit
Scott M Carney, Harmonic Trading : Volume One
2. Pattern and Chapter involved / Pattern dan Bab terlibat
Bullish 5-0 - Page 79
Bearish 5-0 - Page 88
Bullish Alternate Bat - Page 103
Bearish Alternate Bat - Page 106
3. Code Usage / Penggunaan Kod
Free to use for personal usage but credits are most welcomed especially for credits to Scott M Carney.
Bebas untuk kegunaan peribadi tetapi kredit adalah amat dialu-alukan terutamanya kredit kepada Scott M Carney.
5-0
Alternate Bat
Multi Level ZigZag Harmonic PatternsLets make things bit complicated.
Main difference between this script and the earlier Multi Zigzag Harmonic Pattern is the calculation logic of Zigzag 2, 3 and 4
In the earlier script, all zigzags were plain and were calculated on the basis of different lengths. (Such as 5, 10, 15, 20). These were derived on the basis of Multi Zigzag indicator
In this script, Zigzag 2, 3 and 4 are calculated in slightly different way. They are calculated on the basis of previous zigzag. This means, Zigzag 1 will be the input for Zigzag2 calculation and Zigzag 2 will be the input for Zigzag3 and so on. This is demonstrated in the script - Multi Level Zigzag
One important parameter which is specific to this script is: UseZigZagChain
If checked:
Zigzag2 is formed based on Zigzag1
Zigzag3 is formed based on Zigzag2
Zigzag4 is formed based on Zigzag3
This can lead to patterns covering huge number of candles as this chaining causes exponential effect in each levels. (Effective length grows exponentially in each level)
If unchecked:
Zigzag2 is formed based on Zigzag1 (Same as when checked)
Zigzag3 is formed based on Zigzag1. But, length is set to zigzag2Length + zigzag3Length
Zigzag4 is formed based on Zigzag1. But, length is set to zigzag2Length + zigzag3Length + zigzag4Length
This reduces exponential increase of zigzag lengths over next levels.
Logical ratios of patterns are coded as below:
Notations:
Lines XABCD forms the pattern in all cases. (OXABCD in case of Three drives )
abc = BC retacement of AB, xab = AB retracement of XA and so on
ABCD Classic
0.618 <= abc <= 0.786
1.272 <= bcd <= 1.618
AB=CD
Price difference between AB and CD are equal
Time difference between AB and CD are equal
ABCD Extension
0.618 <= abc <= 0.786
1.272 <= AD/ BC (price) <= 1.618
Gartley
xab = 0.618
0.382 <= abc <= 0.886
1.272 <= bcd <= 1.618 OR xad = 0.786
Crab
0.382 <= xab <= 0.618
0.382 <= abc <= 0.886
2.24 <= bcd <= 3.618 OR xad = 1.618
Deep Crab
xab = 0.886
0.382 <= abc <= 0.886
2.0 <= bcd <= 3.618 OR xad = 1.618
Bat
0.382 <= xab <= 0.50
0.382 <= abc <= 0.886
1.618 <= bcd <= 2.618 OR xad = 0.886
Butterfly
xab = 0.786
0.382 <= abc <= 0.886
1.618 <= bcd <= 2.618 OR 1.272 <= xad <= 2.618
Shark
xab = 0.786
1.13 <= abc <= 1.618
1.618 <= bcd <= 2.24 OR 0.886 <= xad <= 1.13
Cypher
0.382 <= xab <= 0.618
1.13 <= abc <= 1.414
1.272 <= bcd <= 2.0 OR xad = 0.786
Three Drives
oxa = 0.618
1.27 <= xab <= 1.618
abc = 0.618
1.27 <= bcd <= 1.618
5-0
1.13 <= xab <= 1.618
1.618 <= abc <= 2.24
bcd = 0.5
Double Bottom
Last two pivot High Lows make W shape
Last Pivot Low is higher than previous Last Pivot Low.
Last Pivot High is lower than previous last Pivot High.
Price has not gone below Last Pivot Low
Price breaks out of last Pivot High to complete W shape
Double Top
Last two pivot High Lows make M shape
Last Pivot Low is higher than previous Last Pivot Low.
Last Pivot High is lower than previous last Pivot High.
Price has not gone above Last Pivot High
Price breaks out of last Pivot Low to complete M shape
Multi ZigZag Harmonic PatternsCombining Multizigzag with harmonic patterns - this script generates harmonic patterns based on multiple deapth zigzags.
Input parameter allows to chose which Zigzag to be included in pattern identification and set different length, line color, width and style for each Zigzag combinations.
Pattern rules are as below:
Gartley
xab = 0.618
0.382 <= abc <= 0.886
1.272 <= bcd <= 1.618 OR xad = 0.786
Crab
0.382 <= xab <= 0.618
0.382 <= abc <= 0.886
2.24 <= bcd <= 3.618 OR xad = 1.618
Deep Crab
xab = 0.886
0.382 <= abc <= 0.886
2.0 <= bcd <= 3.618 OR xad = 1.618
Bat
0.382 <= xab <= 0.50
0.382 <= abc <= 0.886
1.618 <= bcd <= 2.618 OR xad = 0.886
Butterfly
xab = 0.786
0.382 <= abc <= 0.886
1.618 <= bcd <= 2.618 OR 1.272 <= xad <= 2.618
Shark
xab = 0.786
1.13 <= abc <= 1.618
1.618 <= bcd <= 2.24 OR 0.886 <= xad <= 1.13
Cypher
0.382 <= xab <= 0.618
1.13 <= abc <= 1.414
1.272 <= bcd <= 2.0 OR xad = 0.786
Three Drives
oxa = 0.618
1.27 <= xab <= 1.618
abc = 0.618
1.27 <= bcd <= 1.618
5-0
1.13 <= xab <= 1.618
1.618 <= abc <= 2.24
bcd = 0.5
Related scripts are present here:
Auto Harmonic Patterns - Open SourceI may not be able to spend much time on the harmonic patterns and realized that there are not much open source scripts on them either. Hence, decided to release open source version which can be used by other developers for reference and build things on top of it.
Original script is protected and can be found here:
Logical ratios of patterns are coded as below:
Notations:
Lines XABCD forms the pattern in all cases. (OXABCD in case of Three drives )
abc = BC retacement of AB, xab = AB retracement of XA and so on
ABCD Classic
0.618 <= abc <= 0.786
1.272 <= bcd <= 1.618
AB=CD
Price difference between AB and CD are equal
Time difference between AB and CD are equal
ABCD Extension
0.618 <= abc <= 0.786
1.272 <= AD/ BC (price) <= 1.618
Gartley
xab = 0.618
0.382 <= abc <= 0.886
1.272 <= bcd <= 1.618 OR xad = 0.786
Crab
0.382 <= xab <= 0.618
0.382 <= abc <= 0.886
2.24 <= bcd <= 3.618 OR xad = 1.618
Deep Crab
xab = 0.886
0.382 <= abc <= 0.886
2.0 <= bcd <= 3.618 OR xad = 1.618
Bat
0.382 <= xab <= 0.50
0.382 <= abc <= 0.886
1.618 <= bcd <= 2.618 OR xad = 0.886
Butterfly
xab = 0.786
0.382 <= abc <= 0.886
1.618 <= bcd <= 2.618 OR 1.272 <= xad <= 2.618
Shark
xab = 0.786
1.13 <= abc <= 1.618
1.618 <= bcd <= 2.24 OR 0.886 <= xad <= 1.13
Cypher
0.382 <= xab <= 0.618
1.13 <= abc <= 1.414
1.272 <= bcd <= 2.0 OR xad = 0.786
Three Drives
oxa = 0.618
1.27 <= xab <= 1.618
abc = 0.618
1.27 <= bcd <= 1.618
5-0
1.13 <= xab <= 1.618
1.618 <= abc <= 2.24
bcd = 0.5
This script contains everything which original script has apart from stats. Use the original script if you are not developer looking for code reference and prefer having stats table.
I have also developed a strategy based on harmonic patterns which can be found here:
Harmonic IndicatorThis indicator finds all of the gartley and cypher patterns on anychart and personally I have been using them profitably with BTC, ETH, and LTC. It includes entry points for both patterns but not TP levels, that is up to you to do research on. In version 2 I am working on this, if any of you can help me with that, it would be appreciated. Goodluck!
Harmonic Pitchfork IndicatorsThis indicator provides 2 separate exponential moving averages and Quarters Theory Lines on 50 pip intervals above and below current price. Useful for trading the harmonic pitchfork strategy.
Harmonic MADsNo, it's not a new saturation plugin for your fruity loops.
...
These are Mean Average Deviations calculated from Harmonic Mean.
...
In my previous research I tried to develop "Harmonic Average Deviations", since applying stdevs on Harmonic Mean calculated from reciprocals ain't make sense. Din't work out, prolly cuz by definition stdevs doesn't like negatives. So in the end I ended up using Mean Average Deviations, and turned out it works great. Generally market data doesn't distribute normally, so t's a great tool, now weird kurtosis won't be a problem.
[R&D] Harmonic deviationsI'm publishing it for research purposes & welcome any ideas and/or explanations whether it's actually possible or nah to do what I'm doing right now.
...
Idea is simple - if we can do Harmonic Mean, can we do Harmonic Standard Deviations? It should be the same logic, the only difference is instead of actual datapoints we gotta use reciprocals.
In reality I've found smth really curios, it's possible to get these Harmonic Standard Deviations, however, somewhy, depends on your timeframe, u gotta do final sqrt different amount of times. And looks like... the market reacts to these levels.
That's why in the script settings there is a menu where you can choose how many times to perform sqrt operation.
Pls check it out, play with it, see maybe you'll see smth interesting.