Template For Custom FIR Filters - Make Your Moving AverageIntroduction
FIR filters (finite impulse response) are widely used in technical analysis, there is the simple or arithmetic moving average, the triangular, the weighted, the least squares...etc. A FIR filter is characterized by the fact that its impulse response (the output of a filter using an impulse as input) is finite, this mean that the impulse response won't have infinite outputs unlike IIR filters.
They are extremely simple to design to, even without the Fourier transform, this is why i post this template that will let you create custom filters from step responses. Don't hesitate to post your results.
How It Works
Originally you create your filters from the frequency response you want your filter to have, this is because the inverse Fourier transform of the frequency response is the filter impulse response.
After that step you use convolution (convolution is the sum of the product between the signal and the impulse response) and you will have your filter. But we don't have Fourier transforms in pine so how can we possibly make FIR filters from convolution ? Well here the thing, the impulse response is the derivative of the step response and the step response is the sum of the impulse response, this mean we can create filters from step responses.
Step response of a moving average.
Step responses are easy to design, you just need a function that start at 0 and end up at 1.
How To Use The Template
All the work is done for you, the only thing you need to do is to enter your function at line 5 :
f(x)=> your function
For example if you want your filter to have a step response equal to sqrt(x) just enter :
f(x)=> sqrt(x)
This will give the following filter output :
You can create custom step responses from online graphing tools like fooplot or wolfram alpha, i recommend fooplot.
You can also design your filter step response from the line 14/15/16, b will be your filter step response, just use a , for example b = pow(a,2) , then replace output in plot by b and use overlay false, you can also plot step , if you like your step response copy the content of b and paste after f(x) => .
Filter Characteristics
The impulse response determine how many of a certain signal you want in your filter, this is also called weighting, you can think of filter design as cooking where your ingredients are the the signal at different periods and the impulse response determine how many of an ingredient you must include in the recipe. The step response can also tell you about your filter characteristics, for example :
This one converge faster to the step function, this mean that the filter will have less lag.
However this one converge slower to the step function, this mean the filter might have more lag but could be smoother.
Be aware that you must find a good weighting balance, else you can have output equals to the signal or just a delayed version of the signal without smoothing.
Real Case
Lets design a sine weighted moving average (swma), this FIR filter use the first 180 degrees of a sine wave function as impulse response.
Impulse response of the swma.
We can design it from the step response without much problems, remember that the impulse response is the derivative of the step response, therefore the derivative of the step response is equal to the first 180 degrees of a sine wave, the derivative of the cosine function is a sine function, therefore :
f(x)=> .5*(1 - cos(x*pi))
And voila.
Designing A BandPass Filter
The bandpass filter like a low-pass and high pass filter, you can think of it as a smooth oscillator.
To design a bandpass filter your step response must be bell shaped, or starting at 0 and ending at 0, for example :
f(x)=>sin(x*pi) give :
Conclusion
Just use fooplot and experiment, you could get nice filters, i will try to post some using this template but it would be really nice to have other people use it. If you need further help pm me.
Thanks for reading !
Cerca negli script per "wave"
RSW2 - Realise Short Waves SmoothedEnglish:
Smoothed version of RSW, gives less signals.
Works better in short term graphs, like 15mins.
RSW Smoothed aims to give you daytrading and stoploss signals.
Usage:
If leaves green region upwards: long position(buy) or close short position
If enters green region downwards: close short position
If enter red region downward : close long position
If leaves red region downward:short position(sell) or close long position
Türkçe:
RSW indikatörümüzün düzleştirilmiş hali.
Kısa vadeli grafiklerde daha verimli çalışır , mesela 15 dk.lık
RSW Smoothed günlük al-sat-stop sinyalleri vermeyi amaçlar.
Kullanımı:
Yeşil bölgeyi yukarı keserek terkederse: long (al) veya short pozisyonu kapat
Yeşil bölgeye aşağı keserek girerse: short pozisyonu kapat
Kırmızı bölgeye aşağı keserek girerse : long pozisyonu kapat
Kırmızı bölgeyi aşağı keserek terkederse : short(sat) veya long pozisyonu kapat
Paid In FullThis script is best used with Wave Momentum Oscillator because it indicate whether the market is still choppy and uncertain before you enter a trade based on the Wave Momentum - only use this indicator if you are a WaveTrader.
IFT Stochastic + Trailing StopInverse fisher transform on stochastic strategy with trailing stop. Good work on flats with mid-wave length
Chart Mojo Neutral Unwound CloudPlots days high/low and the Chart Mojo neutral cloud, the zone between vwap and 50% range. A secondary gravity right behind the opening 1 min range. The gray crosses are the vwap the gold dots are 50% of developing range. The shaded area between vwap and 50% range is the Chart Mojo cloud...I think of it as traders from the open tend to unwind to it many times a day. More returns on a trend day but you will see urges toward it on trend days. Price tends to urge to it ahead of 10:30 session "1" and 1:15 Session 2. If you get used to watching it and its relationship to price and the opening 1 min range you should start to see tendencies as to when price unwinds toward it.. etc. Where price is in relation to the cloud and the clouds relationship to the opening 1 min range can reveal real time bias. You will being to see, upon observation how traders target the vwap and 50% with target tier of buys and sells etc. Often unwinds to the zones gravity. It takes force or a catalyst to break the gravity. I use it in conjuction with Time Zone theory and Wave and Pattern force...and look to leading correlating hi beta movers and internals like tick and new streaming highs-new straming lows to get jump on what you see on a big etf or index etc. If you intraday tendencies the neutral is very helpful.
Percentage OscillatorUsing momentum calculations on multiple time frames and adding everything together into 4 separate directions:
1- green: the strength and momentum in +45 to +90 degrees angle
2- blue: the strength and momentum in 0 to +45 degrees angle
3- orange: the strength and momentum in 0 to -45 degrees angle
4- red: the strength and momentum in -45 to -90 degrees angle
Single parameter to control the size of the largest moving window.
Uptrend is green with orange corrections
Downtrend is red with blue corrections
When downtrend turns into uptrend, blue becomes green
When uptrend turns into downtrend, orange becomes red
The natural cycle of the market is RED->BLUE->GREEN->ORANGE and so on, you will see the cycle repeats itself 3 times before a break up\down. The strength of the movement depends on the height and width of all the waves that created the 3 cycle movement (reminds Elliot in an oscillatory representation)
The script is provided as is, there are no trading strategies implied or recommended.
Feel free to PM with questions
Pseudo Polynomial ChannelIntroduction
Back when i started using pine i made a script called periodic channel who aimed to rescale an average correlated sine wave to the price...don't worked very well. So i tried to fix problems induced by the indicator without much success, i had to redo it from scratch while abandoning the idea of rescaling correlated smooth functions to the price, at that time i also received requests regarding polynomial channel, some plateformes included this indicator, this led me to the idea to estimate it in order to both respond to the periodic channel problems and the requests i received, i have tried many many things and recently i tweaked a linear extrapolation to have an approximation.
Linear Extrapolation To Pseudo Polynomial Regression
I could be wrong but a polynomial regression must use constant parameters in order to provide a really smooth output, at least constant for a set of time. The moving averages forms (Savitzky-Golay moving average) who smooth polynomials across a window to the data don't have such smoothness, so how to estimate a polynomial regression while having a parameter providing control over the smoothness, a response to this is by using a recursive linear extrapolation. I posted a linear extrapolation indicator long ago, i used the same formula while adding a function to morph the output and the input in the form of :
morph * output + (1-morph) * input
How can this provide an estimate of a polynomial regression ? Well i'm not even sure myself but if you use the output as input (morph = 1) for the linear extrapolation function you should get a rough estimate of a line, this is what i thought at first and it proved to be right
Based on this observation i thought that it would be possible to get polynomial results by lowering morph, and as expected it worked well but showed a periodic pattern, this is why i smooth k in line 10.
0.9 for morph work well, higher values create sometimes smoother results but damage heavily the estimation.
Parameters
Morph have been introduced earlier, it control the amount of output and input the linear extrapolation should process, lower values create rougher but more stables results, if you see that the estimation is going nuts lower morph or change length, also lower length if you increase morph .
High overshoot, morph to 0.8 can help have a better estimation at the cost of less smoothness.
Length control the indicator smoothing, this parameter differ heavily from other filters, therefore low values can create mid/long term smoothing, it can also depend on which market instrument you are applying it, so there are no fixed optimal length.
Mult control how spread the bands are, to do so mult multiply the cumulative mean error, you can change this error measurement by anything you want like standard deviation/atr/range but take into account that you may create a separate parameter to control the error instead of length . Mult can be a float and like length can have different optimal values depending on the market the indicator is applied to.
Flatten do exactly what is name imply, it flatten the overall output to have a better estimation, can be a float. The result is less smooth.
Flatten = 2
More Exemples
BTCUSD length = 25 and mult = 4
XPDUSD length = 25 and mult = 1
ALPHABET length = 6 and morph = 0.99
Conclusion
I tried to estimate a polynomial channel by using recursion in the linear extrapolation function. This build is way more stable than the periodic channel but its still a bit inaccurate in my opinion. I hope this code can still help someone build something really nice, if so share your results :)
I apologize for those expecting a legit polynomial channel build but i really don't know how to do that, as i said parameters for the regression must be constants, i hope it still fine :)
Thanks for reading !
Weis Wave Accumulation v1Nothing fancy here , the main script is from here so all credit to author MouraTrader1 , I just change very little and add alerts
change the tf to minute length of your desire to get better results, also can act as good filter for your purpose if you want to have a volume filter to your desire indicator . by its own it has its good and bad so work need to be done probably with other indicators to make it much better .
Tuka balance with rsi(Prototype)'Tuka' is Japanese called currency.
I made this indicator to see the strength of the currency.
※Use google translation※
■ Difference with other indicators.
・ We used RMA to find currency pairs with volatility. And by using the average foot I saw a gentle wave.
・Made it possible to select 2 standard currency from "EUR, USD, JPY, GBP, AUD" and 4 currencies as options "NZD, CHN, CAD, CHF".
・Added RSI to find weak currencies that are oversold.
・The meaning of kanji is
EUR:欧
USD:米
JPY:日
GBP:英
AUD:豪
NZD:新
CHN:中
CAD:加
CHF:瑞
■他のインジケーターとの違い。
・ボラティリティのある通貨ペアを見つけるのにRMAを使ってみた。且つ平均足を使う事でなだらかな波を見るようにした。
・基準通貨を5つ”EUR、USD、JPY、GBP、AUD”、オプションで4通貨”NZD、CHN、CAD、CHF”から2つを選択出来るようにした。
・RSIを追加することで、売られすぎの弱い通貨を見つけられるようにしました。
EUR:欧
USD:米
JPY:日
GBP:英
AUD:豪
NZD:新
CHN:中
CAD:加
CHF:瑞
Simple LinesIntroduction
Making lines is great in technical analysis since it can highlights principal movements and make the analysis of the price easier when using certain methodologies (Elliott Waves, patterns).
However most of the indicators making lines (Zig-Zag, simple linear regression) are non causal (repaint), this is the challenge i tried to overcome, making an indicator capable of making lines in a smart way (able to follow price without loosing a linear approach) and with the least lag possible, i inspired myself from the behaviour of the renko when using a small brick size. This indicator does not repaint .
The code is short and i hope, understandable for all of you, making lines is not a difficult task and its important to know that when a problem appear complex it does not mean that the code used to solve this problem must be complex. Lets see the indicator in details.
The indicator
The indicator have 4 parameters, the length parameter who control the length of lines, the emphasis parameter who control the stability and also the ability to make lines closer to the price (thus minimizing the sum of squares) , the mult parameter which is similar to emphasis and a point option that we will discuss later.
When emphasis and mult are both equal to 1 the indicator will sometimes draw a perfect line, however this line will try to follow the price and thus can create a noisy result.
This is where emphasis and mult will correct this behaviour. The emphasis parameter give a more periodic look as well as some control to the lines but can also destroy them.
This should not happen with mult , this parameter also give more predictability to the lines. Overall it correct the drawbacks of the parameters combinations mentioned earlier.
Its also possible to mix both the emphasis and mult parameter, but take into account that when both are equals the result consist of less reactive lengthy lines with low accuracy. Its better to only use one of them and let the other stay to 1.
Point Option
The indicator can sometimes have a weird look, appearing almost flat or just dont appearing at all. When such thing happen use the point option.
XPDUSD without point option.
with point option :
Time Frame Problem and Its Fix
When using higher time-frames the result of the indicator can appear different, in general the higher the time frame the lengthier are the lines. In order to fix this you can use decimals in the length parameter
length and mult both equal to 5.5, emphasis cant use decimals.
Conclusion
I have highlighted a simple way to make use of the small renko box size method in order to return reactive lines without making the indicator repaint. However Its ability to be close to the price as well as being always super reactive is not a guarantee.
For any suggestion/help feel free to pm me, i would be happy to help you :)
EW CountHelper HiLo/Volume-based; with predict-tendencyHere is my Elliott wave count assistant. It is volume based and remarkable signifant to me,
how well volume changes can even predict the next swing. (If you use it, you will see that is a little faster
and oftenly more accentuated than the original price swing.)
Standard use : Lean back from the screne to see the whole picture more likely than details.
The beginning of a green cluster is the begining of a new wave one, the end is the end of wave 5 . Red is correcting abc. (Upside down valid in downtrends.)
Advanced use : You will see that most of stocks have their own bullsih support, somewhere below zero.
Mark it with an horizontal line as an additional warner for reversals.
Btw: Have a look at the last "upswing" of SPLK in my example (Start March, 8th, 2019)
My Indicator says that is still correcting - ergo a b wave (probably of a zigzag, so further decline to expect.)
Have fun and help with it!
Yoxxx
EW CountHelper HiLo/Volume-based; with predict-tendencyHere is my Elliott wave count assistant. It is volume based and remarkable signifant to me,
how well volume changes can even predict the next swing. (If you use it, you will see that is a little faster
and oftenly more accentuated than the original price swing.)
Standard use : Lean back from the screne to see the whole picture more likely than details.
The beginning of a green cluster is the begining of a new wave one, the end is the end of wave 5 . Red is correcting abc. (Upside down valid in downtrends.)
Advanced use : You will see that most of stocks have their own bullsih support, somewhere below zero.
Mark it with an horizontal line as an additional warner for reversals .
Btw: Have a look at the last "upswing" of SPLK in my example (Start March, 8th, 2019)
My Indicator says that is still correcting - ergo a b wave (probably of a zigzag, so further decline to expect.)
Have fun and help with it!
Yoxxx
rsi_with_stochrsi_[j15] v3This is version 3 RSI and StochRSI are improved by visualizing the cross-trend wave on the indicator, as well as by highlighting the colors of the bands and take into account the joint intersection of RSI and StochRSI at different settings. Enjoy using it!
Pivots High/Low [Simpelyfe]These are interconnected pivot highs and lows to help you determine the direction and magnitude of the next impulse. A hard pivot finishing off C or E of a corrective wave means there's a higher probability for price to reverse thereafter.
Cheers,
Simpelyfe
Cosine, In-Phase & Quadrature IFM [Ehlers]Yet another method for determining the cycle of a market: this time, you have access to the two fastest and most accurate methods
as well as the option to average these methods together.
The controls are pretty straight forward:
Source lets you select the price data to perform calculations on (close, open, etc..)
Max Period is simply the cap for the algorithm when it's checking the validity of Periods.
-> If you notice your plots have a flat top, then increase this value to accept a wider range of Periods.
-> This setting has a min. value of 8 to reduce noise and a max of 100 to ignore waves from higher time frames.
Average? simply averages the two methods of calculation.
-> You may want to do this if you notice the two plots diverging a lot.
-> Cosine IFM tends to favor shorter periods; I-Q IFM tends to favor longer.
Cheers,
- DasanC
Adaptive Bandpass Filter [Ehlers]This is my latest bandpass filter - used to determine if a security is in a trend or cycle.
Now with an adaptive period setting! I use Ehlers in-phase & quadrature dominant cycle measurement (IQ IFM) method to set the period dynamically.
This method favors longer periods which tend to produce smoother, albeit laggier bandpass oscillator plots. From my quick tests, I tend to have lag between 4 and 8 bars, depending on the Timeframe.
The lower timeframes tend to have more noise and thus produce more interfering frequencies that may cause lag.
>Settings
Source: Select the data source to perform calc's on (close, open, etc...)
Period: Select the period to tune. Periods outside of this value will be attenuated (reduced)
Adaptive: Enable to have the I-Q IFM set the period for you (disables Period setting)
Bandpass Tolerance: Allow periods that are plus/minus the chosen period to pass.
Cycle Tolerance: Sensitivity of cycle mode. Lower values consider trends more frequent, higher values consider cycles more frequent.
Bandpass tolerance example: for instance, if this setting is 0.1 (10%) and Period is set to 20, then waves with a period of 18 - 22 will pass.
>How to read
Red line is the bandpass output, showing a lagged version of the dominant cycle representing the
Black lines are the upper and lower bounds for a cycle
Green Background indicates an uptrend
Red background indicates a downtrend
Godmode 4.0.0 [Oscillator]First off, a huge thank you to the following people:
LEGION:
LazyBear: www.tradingview.com
xSilas: www.tradingview.com
Ni6HTH4awK: www.tradingview.com
sco77m4r7and:
SNOW_CITY: www.tradingview.com
oh92: www.tradingview.com
alexgrover: www.tradingview.com
cI8DH: www.tradingview.com
DonovanWall: www.tradingview.com
Since I've been on TradingView I've become somewhat enthralled by Godmode and the collective work that goes in to it, so I decided to publish my own iteration, building off the ideas already present. (This is a great way to get familiar with Pine by the way, just in case there are any beginners reading this)
Changes
The first change I made was to allow the user to select whatever tickerid they wanted as a benchmark. If trading XBTUSD on BitMEX for example, the indicator will react to exchange-specific activity, which means it will respond to all the little whipsaws, whipsaws that can be especially present on a futures exchange. By typing CRYPTOCAP:BTC or CRYPTOCAP:TOTAL we endeavor to remove noise. It can also signal earlier. Less noise and less lag. Another idea would be to choose a benchmark that has a strong inverse relationship with the asset you're trading: try CRYPTOCAP:USDT as the benchmark against BTC to see what I mean.
I also added the ability to smooth the plot, yet again removing noise but adding considerable lag.
The linear regression of the wave-trend is calculated in place of the EMA. This is plotted as columns with the midline (50) as the base. This is just calculating the slope of the wave-trend and can signal a weakening trend before a reversal takes place.
Using cI8DH's True RSI script () as inspiration, I added a function for calculating the True TSI in an attempt to remove any bullish bias. Funnily enough, when I tried to do the same with the RSI I had some problems. I'll try to resolve this in the coming weeks.
Made slight changes to the aesthetics. Tried to bring the two main plots alive by making their bold, opaque colors stand off the subtle tones in the background.
To Do List
1. I would like to sort out the issue with the True RSI.
2. When the plots are smoothed, there's an issue with the green 'Caution!' dots appearing in the lower half of the indicator.
3. I'd like to adjust the code so that if the 'Benchmark' box is empty, that it will automatically register the current tickerid as the 'Benchmark'.
If anyone has any suggestions on other fixes or how to apply the fixes mentioned by me, please don't hesitate to reach out to me here or through other media platforms.
Want to Learn?
If you'd like the opportunity to learn Pine but you have difficulty finding resources to guide you, take a look at this rudimentary list: docs.google.com
The list will be updated in the future as more people share the resources that have helped, or continue to help, them. Follow me on Twitter to keep up-to-date with the growing list of resources.
Suggestions or Questions?
Don't even kinda hesitate to forward them to me. My (metaphorical) door is always open.
BITMEX:XBTUSD
CRYPTOCAP:BTC
CRYPTOCAP:TOTAL
CRYPTOCAP:USDT.D
Bandpass Cycle Indicator [Ehlers]This indicator is NOT used for entry and exit conditions when trading. Instead, it's purpose is to tell you what the state of the market is: trending or cyclical.
>WHO IS THIS FOR?
This is especially useful for strategies that use scalping or martingale betting to turn a profit. You don't want to be caught in a bullish trend with several open short orders. Algo traders welcome.
>HOW DOES IT WORK?
I'm glad you asked. It's based on Ehlers' work regarding signal filtering. Essentially, it uses a bandpass filter to reduce noise that is inherent in the market and display the underlying frequency.
First, we get rid of the high-frequency noise - think jitters, long wicks, etc... price action that usually effects EMAs and other MAs. We don't want any of that.
Next, we get rid of low-frequency noise - this is a little more difficult to picture, but we're essentially ignoring cycles (Elliot waves) from other longer time frames. We don't care if the Daily bars are just about to reverse if it doesn't affect our scalping strategy.
Finally, we find the root mean square (RMS) of the high and low points of our newly created signal (red) and plot them (black). These will act as triggers to tell us if a market is in cycle or trending.
>HOW DO YOU READ IT?
Background colors:
-Blue is cycle - you're safe.
-Red is trending down
-Green is trending up
Crossovers:
-Red above Upper Black: Uptrend
-Red below Lower Black: Downtrend
-Red in the middle: Cycle
>IS IT PREDICTIVE?
Momentum tends to pick up quickly and decline quickly, so if you'll often see a small Red or Green strip before a large price movement.
After long periods of cyclic movement (or consolidation), there isn't much momentum in the system, so any small price action will be considered a trend -> these small movements are picked up by other human traders and bots. Trading volume increases more and more until you have a swing in one direction.
So yes, it can be predictive due to the nature of signals and oscillation. Maybe not necessarily predictive of which direction price will go, but when volatility is about to increase.
Low Latency Trendline[Geo]Low latency trendline is a better and faster indicator than MAs.
It lowes high frequency wave(noise) and echoes low frequency wave(main move trend).
You can find out trend faster and have more confidence to dicide than MA indicators.
Take your own risk to use this Indicator.
PS:
I found RMTA() to help coding.
Tradingview has a good recursive function method. And RMTA has a good licence:MIT licence. Thanks to you, Alex.
Logarithmic Fibonacci RetraceThis script will allow you to use Logarithmic (instead of linear) Fibonacci retrace.
Please see excellent write up here: www.elliottwavetrader.net
explaining why logarithmic is preferred, especially over large price movement and long timeframes.
All TradingView fib tools use linear math, and will show incorrect long-term levels because of this.
HOW TO USE:
* Enter your points for Wave 0 and 1. Example: 1810.10 and 2872.87 in the SPX chart shown.
* Turn on "show lines" and "show labels". These are OFF by default because the chart will usually get warped
if you display the lines before entering the actual values you want.
* Change the "label offset" if the fib labels are too close or too far from the chart.
Please be aware that this is considered an "INDICATOR" script and so will not save the values separately
for each chart. You will need to enter new values each time you change to a different symbol.
Logarithmic Fibonacci ExtensionThis script will allow you to use Logarithmic (instead of linear) Fibonacci extensions.
Please see excellent write up here: www.elliottwavetrader.net
explaining why logarithmic is preferred, especially over large price movement and long timeframes.
All TradingView fib tools use linear math, and will show incorrect long-term levels because of this.
HOW TO USE:
* Enter your points for Wave 0, 1, and 2. Example: 666.79, 1219.80, 1010.91 in the SPX chart shown.
* Turn on "show lines" and "show labels". These are OFF by default because the chart will usually get warped
if you display the lines before entering the actual values you want.
* Change the "label offset" if the fib labels are too close or too far from the chart.
* Select up to 2.000, 3.000, and 4.000 to display higher-power fibs.
Please be aware that this is considered an "INDICATOR" script and so will not save the values separately
for each chart. You will need to enter new values each time you change to a different symbol.
Adaptive Bandpass Trigger Oscillator Ver 3This is an improvement of the Adaptive Bandpass Trigger Oscillator. It adds an option for a multiplier to the dominant cycle to filter out smaller swings.
Feel free to message me if you would like development work or would just like to donate ; )
This is based off of Ehlers' Bandpass Filter system (link below slides 15-17). I then used Ehlers' methods for finding the dominant cycle to automatically input the dominant cycle to the length. Essentially Ehlers runs a band pass with a given period to detrend the price data and highlight a cycle with the given frequency(length). This represents the In phase cycle. Ehlers then creates the trigger line by taking the one bar momentum of the In Phase line, multiplying by 2Pi and then using this to create a 60 degree leading signal. The triggers are crossovers of the In Phase and Lead lines. You can also use conservative signals by waiting for the In Phase line to trend in the direction of the trigger crossover as well.
Delta represents how much to influence the oscillator by the price (Delta 0 is a perfect wave)
Alpha represents how quickly to adapt between the dominant cycle changes in the price.
Thanks to LazyBear for implementing Ehlers' original adaptive code, which I used for this system
Thanks to HPotter for the BandPass Filter code, which I used as a base for implementing the rest of the system