Moving Average MultitoolI made this script as a personal tool while backtesting multiple moving averages. It allows you to easily access and switch between different types of moving averages, without having to continuously add and remove different moving averages from your chart.
It also has the option to show the a 14 period average distance between the closing price of an asset and the selected moving average, as a multiple of ATR. This number can be shown by enabling the "Show ATR Between MA and Close" setting. The intention of this value is to quantify and compare the speed of different moving averages across any instrument and any timeframe. The higher the value, the slower the moving average. The lower the value, the faster the moving average.
Jurik
Jurik MacD & Leader NCMhey everyone,
While there are some Invite-Only Jurik MacDs, there are no free/open ones, so I thought I'd create one and publish it. It has most of the bells and whistles you'd want (I hope!).
You can see one with the bells and whistles all turned on in the first, and a 'quieter' one in the second.
//-----------------////-----------------////-----------------//
Why Jurik?
The Jurik MA is a quicker and smoother Exponential MA, and the best of all MAs, according to Jurik Research (lol). To be fair. I have found it to be excellent, and that is why I'm publishing this.
Power can be changed, recommended from 1-4: increasing it pulls it closer to the current price (almost like reducing the period), and decreasing: vice versa.
Phase increases the inertia of the line, how quickly it will respect price changes. It is usual to have less inertia on the fast JMA, and more on the slower (but remember the MACD line is the FastJMA minus the SlowJMA, so you may find adjusting power and phase on Signal line more effective). Search online for JurikRes (or Jurik Research) for more detailed information about the Jurik.
In the coding I have included a list of four different ways to set up the JMAs: however, you should probably tune this to your preferred asset (as with almost all indicators). If you find a good setup, please let me know!
You could trade with a MacD a number of ways. Entries could be:
- MacD crossing the zero line
- MacD crossing over the Signal line
- Histogram crossing above zero line.
Vice versa for exits. If this isn't enough, please google 'trading with a MacD'.
No indicator is perfect for trading, and that includes this one! Don't trade unless you know what you're doing.
//-----------------////-----------------////-----------------//
Please let me know if I can improve this script, or you have any other feedback. I can post code for colour palette as well if that is something anyone is keen on.
//-----------------////-----------------////-----------------//
Thanks to the many excellent coders that publish freely their code. I have learned so much from this community, and this code is based on the work of others (Chris Moody and everget).
Shout out to StevieMagg as well, who has helped me develop (and didn't want to charge me!). The Pine Script Community on Discord has been brilliant - lots of knowledge, ideas, support - thanks guys.
If you are new and interested in pine coding, I suggest you check out some of the masters (in no order):
ChrisMoody
Everget
RedKTrader
LonesomeDove
LazyBear
KivancOzbilgic
and more that I am missing. It is not necessarily the popular scripts that are the best.
//-----------------////-----------------////-----------------//
Kind regards,
Nelson
Jurik Bands//A follow up for my JMA script. This script is inspired by (and dedicated to) closure of sales (today, Oct 20 '21) of the famous Jurik Research.
...
Jurik Research, the real people who been doing real things by using the real instruments, while many others been reading books "How to become a billionaire in 2 days", watching 5687 hours videos of how to use RSI , and studying+applying machine learning to everything cuz suddenly it became trendy xD
...
In my JMA script I've said that JMA takes into account volatility. But how exactly? In fact, it's based on smth called Jurik Bands. Thing is they can be/should be used as an independent instrument. I won't lie, I've developed smth very similar myself for mean-reverting purposes, but we ain't gonna talk about this now (my stuff is much simpler, saying bye-bye to entropy).
...
The code is on purpose in Pine4, because lmao I'm not gonna call my stuff "Indicators", they don't "Indicate" anything. And it's on purpose doesn't follow any "coding conventions" made by geeks to make their stuff look more important. My conventions are simple: less code as possible and as simple as possible so we can actually do business based on these instruments.
...
Live Long And Prosper
Jurik Moving Average//Sup TV. This script is inspired by (and dedicated to) closure of sales (today, Oct 20 '21) of the famous Jurik Research.
...
Jurik Research, the real people who been doing real things by using the real instruments, while many others been reading books "How to become a billionaire in 2 days", watching 5687 hours videos of how to use RSI, and studying+applying machine learning to everything cuz suddenly it became trendy xD
...
This is my remake of the original Jurik Moving Average (JMA) based on all the info I managed to get my hands on, some stuff is dated back to 2008 or smth.
The whole point of this filter, the point missed by other attempts of its remakes even posted there on TV, is that it takes into account volatility and adjusts its speed based on it.
Think about it as an EMA, where the alpha parameter is dynamic.
Now, by all means I'm not claiming that's this is the perfect replica of the original algo. I've tested it a lot, looks like it's working legit...
But we all can see together whether it's legit or nah, besides, the official sales are closed since today, you feel me?
...
@everget, does it differs from yours closed one?
...
Live Long And Prosper
Berzerker IndexSome pairs have their own distinct behavior. That includes volatility, news reactiveness, trend x chop day discrepancy, and other qualities.
At first, I tried to measure this with the Choppiness Index, but it looks pretty much alike when you compare symbols like EURNZD and GBPCAD, but my testing shows some major behavioral differences between the two. Hence, I decided to build my own measurement which I later decided to call Berzerker Index.
• The calculation takes the previous value and adds 1, 3, 7, or 15 depending on how many standard deviations the price beats.
• Deviations use Jurik Moving Average as a central line. If there is no new penetration, the total value will not be increased.
• At the end of the value update, the result will decay whether it is changed or not. The readings decay significantly faster if the price is between the bands.
• The beginning of the calculation is the beginning of the chart. There isn't any period for the calculation.
As you can see, from the beginning of the year, the maximum readings on EURNZD are 49.8 and 73.6 for GBPCAD. This is what I wanted to achieve - find some way to clearly differentiate the pairs. Later, I went on EURUSD to confirm the results. EURUSD should be a calmer pair and it shows 33.5 which supports the theory.
The symbols with small bars and explosions on events and bank meetings will reach high values, whereas those that are more predictable with less extreme movements will be found below 45.
Lastly, you may identify long periods of continuous descend on the indicator as setting up for a large explosion. This is not the original idea but could work nevertheless.
Of course, I will further update this indicator if I get improvement ideas...
FAQ:
► Does this repaint?
• No.
► Where is the buy signal?
• There isn't one. The purpose is to study repeated behavioral patterns of different symbols, not to drink from the holy grail.
► Why is it called the 'Berzerker' Index?
• I don't know.
I used @everget's version of Jurik's Moving Average with his consent.
What do ya thing?
888 BOT #alerts█ 888 BOT #alerts (open source)
This is an Expert Advisor 'EA' or Automated trading script for ‘longs’ and ‘shorts’, which uses only a Take Profit or, in the worst case, a Stop Loss to close the trade.
It's a much improved version of the previous ‘Repanocha’. It doesn`t use 'Trailing Stop' or 'security ()' functions (although using a security function doesn`t mean that the script repaints) and all signals are confirmed, therefore the script doesn`t repaint in alert mode and is accurate in backtest mode.
Apart from the previous indicators, some more and other functions have been added for Stop-Loss, re-entry and leverage.
It uses 8 indicators, (many of you already know what they are, but in case there is someone new), these are the following:
1. Jurik Moving Average
It's a moving average created by Mark Jurik for professionals which eliminates the 'lag' or delay of the signal. It's better than other moving averages like EMA , DEMA , AMA or T3.
There are two ways to decrease noise using JMA . Increasing the 'LENGTH' parameter will cause JMA to move more slowly and therefore reduce noise at the expense of adding 'lag'
The 'JMA LENGTH', 'PHASE' and 'POWER' parameters offer a way to select the optimal balance between 'lag' and over boost.
Green: Bullish , Red: Bearish .
2. Range filter
Created by Donovan Wall, its function is to filter or eliminate noise and to better determine the price trend in the short term.
First, a uniform average price range 'SAMPLING PERIOD' is calculated for the filter base and multiplied by a specific quantity 'RANGE MULTIPLIER'.
The filter is then calculated by adjusting price movements that do not exceed the specified range.
Finally, the target ranges are plotted to show the prices that will trigger the filter movement.
Green: Bullish , Red: Bearish .
3. Average Directional Index ( ADX Classic) and ( ADX Masanakamura)
It's an indicator designed by Welles Wilder to measure the strength and direction of the market trend. The price movement is strong when the ADX has a positive slope and is above a certain minimum level 'ADX THRESHOLD' and for a given period 'ADX LENGTH'.
The green color of the bars indicates that the trend is bullish and that the ADX is above the level established by the threshold.
The red color of the bars indicates that the trend is down and that the ADX is above the threshold level.
The orange color of the bars indicates that the price is not strong and will surely lateralize.
You can choose between the classic option and the one created by a certain 'Masanakamura'. The main difference between the two is that in the first it uses RMA () and in the second SMA () in its calculation.
4. Parabolic SAR
This indicator, also created by Welles Wilder, places points that help define a trend. The Parabolic SAR can follow the price above or below, the peculiarity that it offers is that when the price touches the indicator, it jumps to the other side of the price (if the Parabolic SAR was below the price it jumps up and vice versa) to a distance predetermined by the indicator. At this time the indicator continues to follow the price, reducing the distance with each candle until it is finally touched again by the price and the process starts again. This procedure explains the name of the indicator: the Parabolic SAR follows the price generating a characteristic parabolic shape, when the price touches it, stops and turns ( SAR is the acronym for 'stop and reverse'), giving rise to a new cycle. When the points are below the price, the trend is up, while the points above the price indicate a downward trend.
5. RSI with Volume
This indicator was created by LazyBear from the popular RSI .
The RSI is an oscillator-type indicator used in technical analysis and also created by Welles Wilder that shows the strength of the price by comparing individual movements up or down in successive closing prices.
LazyBear added a volume parameter that makes it more accurate to the market movement.
A good way to use RSI is by considering the 50 'RSI CENTER LINE' centerline. When the oscillator is above, the trend is bullish and when it is below, the trend is bearish .
6. Moving Average Convergence Divergence ( MACD ) and ( MAC-Z )
It was created by Gerald Appel. Subsequently, the histogram was added to anticipate the crossing of MA. Broadly speaking, we can say that the MACD is an oscillator consisting of two moving averages that rotate around the zero line. The MACD line is the difference between a short moving average 'MACD FAST MA LENGTH' and a long moving average 'MACD SLOW MA LENGTH'. It's an indicator that allows us to have a reference on the trend of the asset on which it is operating, thus generating market entry and exit signals.
We can talk about a bull market when the MACD histogram is above the zero line, along with the signal line, while we are talking about a bear market when the MACD histogram is below the zero line.
There is the option of using the MAC-Z indicator created by LazyBear, which according to its author is more effective, by using the parameter VWAP ( volume weighted average price ) 'Z-VWAP LENGTH' together with a standard deviation 'STDEV LENGTH' in its calculation.
7. Volume Condition
Volume indicates the number of participants in this war between bulls and bears, the more volume the more likely the price will move in favor of the trend. A low trading volume indicates a lower number of participants and interest in the instrument in question. Low volumes may reveal weakness behind a price movement.
With this condition, those signals whose volume is less than the volume SMA for a period 'SMA VOLUME LENGTH' multiplied by a factor 'VOLUME FACTOR' are filtered. In addition, it determines the leverage used, the more volume , the more participants, the more probability that the price will move in our favor, that is, we can use more leverage. The leverage in this script is determined by how many times the volume is above the SMA line.
The maximum leverage is 8.
8. Bollinger Bands
This indicator was created by John Bollinger and consists of three bands that are drawn superimposed on the price evolution graph.
The central band is a moving average, normally a simple moving average calculated with 20 periods is used. ('BB LENGTH' Number of periods of the moving average)
The upper band is calculated by adding the value of the simple moving average X times the standard deviation of the moving average. ('BB MULTIPLIER' Number of times the standard deviation of the moving average)
The lower band is calculated by subtracting the simple moving average X times the standard deviation of the moving average.
the band between the upper and lower bands contains, statistically, almost 90% of the possible price variations, which means that any movement of the price outside the bands has special relevance.
In practical terms, Bollinger bands behave as if they were an elastic band so that, if the price touches them, it has a high probability of bouncing.
Sometimes, after the entry order is filled, the price is returned to the opposite side. If price touch the Bollinger band in the same previous conditions, another order is filled in the same direction of the position to improve the average entry price, (% MINIMUM BETTER PRICE ': Minimum price for the re-entry to be executed and that is better than the price of the previous position in a given %) in this way we give the trade a chance that the Take Profit is executed before. The downside is that the position is doubled in size. 'ACTIVATE DIVIDE TP': Divide the size of the TP in half. More probability of the trade closing but less profit.
█ STOP LOSS and RISK MANAGEMENT.
A good risk management is what can make your equity go up or be liquidated.
The % risk is the percentage of our capital that we are willing to lose by operation. This is recommended to be between 1-5%.
% Risk: (% Stop Loss x % Equity per trade x Leverage) / 100
First the strategy is calculated with Stop Loss, then the risk per operation is determined and from there, the amount per operation is calculated and not vice versa.
In this script you can use a normal Stop Loss or one according to the ATR. Also activate the option to trigger it earlier if the risk percentage is reached. '% RISK ALLOWED' wich is calculated according with: '%EQUITY ON EACH ENTRY'. Only works with Stop Loss on 'NORMAL' or 'BOTH' mode.
'STOP LOSS CONFIRMED': The Stop Loss is only activated if the closing of the previous bar is in the loss limit condition. It's useful to prevent the SL from triggering when they do a ‘pump’ to sweep Stops and then return the price to the previous state.
█ ALERTS
There is an alert for each leverage, therefore a maximum of 8 alerts can be set for 'long' and 8 for 'short', plus an alert to close the trade with Take Profit or Stop Loss in market mode. You can also place Take Profit limit and Stop Loss limit orders a few seconds after filling the position entry order.
- 'MAXIMUM LEVERAGE': It is the maximum allowed multiplier of the % quantity entered on each entry for 1X according to the volume condition.
- 'ADVANCE ALERTS': There is always a time delay from when the alert is triggered until it reaches the exchange and can be between 1-15 seconds. With this parameter, you can advance the alert by the necessary seconds to activate it earlier. In this way it can be synchronized with the exchange so that the execution time of the entry order to the position coincides with the opening of the bar.
The settings are for Bitcoin at Binance Futures (BTC: USDTPERP) in 15 minutes.
For other pairs and other timeframes, the settings have to be adjusted again. And within a month, the settings will be different because we all know the market and the trend are changing.
888 BOT #backtest█ 888 BOT #backtest (open source)
This is an Expert Advisor 'EA' or Automated trading script for ‘longs’ and ‘shorts’, which uses only a Take Profit or, in the worst case, a Stop Loss to close the trade.
It's a much improved version of the previous ‘Repanocha’. It doesn`t use 'Trailing Stop' or 'security()' functions (although using a security function doesn`t mean that the script repaints) and all signals are confirmed, therefore the script doesn`t repaint in alert mode and is accurate in backtest mode.
Apart from the previous indicators, some more and other functions have been added for Stop-Loss, re-entry and leverage.
It uses 8 indicators, (many of you already know what they are, but in case there is someone new), these are the following:
1. Jurik Moving Average
It's a moving average created by Mark Jurik for professionals which eliminates the 'lag' or delay of the signal. It's better than other moving averages like EMA , DEMA , AMA or T3.
There are two ways to decrease noise using JMA . Increasing the 'LENGTH' parameter will cause JMA to move more slowly and therefore reduce noise at the expense of adding 'lag'
The 'JMA LENGTH', 'PHASE' and 'POWER' parameters offer a way to select the optimal balance between 'lag' and over boost.
Green: Bullish , Red: Bearish .
2. Range filter
Created by Donovan Wall, its function is to filter or eliminate noise and to better determine the price trend in the short term.
First, a uniform average price range 'SAMPLING PERIOD' is calculated for the filter base and multiplied by a specific quantity 'RANGE MULTIPLIER'.
The filter is then calculated by adjusting price movements that do not exceed the specified range.
Finally, the target ranges are plotted to show the prices that will trigger the filter movement.
Green: Bullish , Red: Bearish .
3. Average Directional Index ( ADX Classic) and ( ADX Masanakamura)
It's an indicator designed by Welles Wilder to measure the strength and direction of the market trend. The price movement is strong when the ADX has a positive slope and is above a certain minimum level 'ADX THRESHOLD' and for a given period 'ADX LENGTH'.
The green color of the bars indicates that the trend is bullish and that the ADX is above the level established by the threshold.
The red color of the bars indicates that the trend is down and that the ADX is above the threshold level.
The orange color of the bars indicates that the price is not strong and will surely lateralize.
You can choose between the classic option and the one created by a certain 'Masanakamura'. The main difference between the two is that in the first it uses RMA () and in the second SMA () in its calculation.
4. Parabolic SAR
This indicator, also created by Welles Wilder, places points that help define a trend. The Parabolic SAR can follow the price above or below, the peculiarity that it offers is that when the price touches the indicator, it jumps to the other side of the price (if the Parabolic SAR was below the price it jumps up and vice versa) to a distance predetermined by the indicator. At this time the indicator continues to follow the price, reducing the distance with each candle until it is finally touched again by the price and the process starts again. This procedure explains the name of the indicator: the Parabolic SAR follows the price generating a characteristic parabolic shape, when the price touches it, stops and turns ( SAR is the acronym for 'stop and reverse'), giving rise to a new cycle. When the points are below the price, the trend is up, while the points above the price indicate a downward trend.
5. RSI with Volume
This indicator was created by LazyBear from the popular RSI .
The RSI is an oscillator-type indicator used in technical analysis and also created by Welles Wilder that shows the strength of the price by comparing individual movements up or down in successive closing prices.
LazyBear added a volume parameter that makes it more accurate to the market movement.
A good way to use RSI is by considering the 50 'RSI CENTER LINE' centerline. When the oscillator is above, the trend is bullish and when it is below, the trend is bearish .
6. Moving Average Convergence Divergence ( MACD ) and ( MAC-Z )
It was created by Gerald Appel. Subsequently, the histogram was added to anticipate the crossing of MA. Broadly speaking, we can say that the MACD is an oscillator consisting of two moving averages that rotate around the zero line. The MACD line is the difference between a short moving average 'MACD FAST MA LENGTH' and a long moving average 'MACD SLOW MA LENGTH'. It's an indicator that allows us to have a reference on the trend of the asset on which it is operating, thus generating market entry and exit signals.
We can talk about a bull market when the MACD histogram is above the zero line, along with the signal line, while we are talking about a bear market when the MACD histogram is below the zero line.
There is the option of using the MAC-Z indicator created by LazyBear, which according to its author is more effective, by using the parameter VWAP ( volume weighted average price ) 'Z-VWAP LENGTH' together with a standard deviation 'STDEV LENGTH' in its calculation.
7. Volume Condition
Volume indicates the number of participants in this war between bulls and bears, the more volume the more likely the price will move in favor of the trend. A low trading volume indicates a lower number of participants and interest in the instrument in question. Low volumes may reveal weakness behind a price movement.
With this condition, those signals whose volume is less than the volume SMA for a period 'SMA VOLUME LENGTH' multiplied by a factor 'VOLUME FACTOR' are filtered. In addition, it determines the leverage used, the more volume , the more participants, the more probability that the price will move in our favor, that is, we can use more leverage. The leverage in this script is determined by how many times the volume is above the SMA line.
The maximum leverage is 8.
8. Bollinger Bands
This indicator was created by John Bollinger and consists of three bands that are drawn superimposed on the price evolution graph.
The central band is a moving average, normally a simple moving average calculated with 20 periods is used. ('BB LENGTH' Number of periods of the moving average)
The upper band is calculated by adding the value of the simple moving average X times the standard deviation of the moving average. ('BB MULTIPLIER' Number of times the standard deviation of the moving average)
The lower band is calculated by subtracting the simple moving average X times the standard deviation of the moving average.
the band between the upper and lower bands contains, statistically, almost 90% of the possible price variations, which means that any movement of the price outside the bands has special relevance.
In practical terms, Bollinger bands behave as if they were an elastic band so that, if the price touches them, it has a high probability of bouncing.
Sometimes, after the entry order is filled, the price is returned to the opposite side. If price touch the Bollinger band in the same previous conditions, another order is filled in the same direction of the position to improve the average entry price, (% MINIMUM BETTER PRICE ': Minimum price for the re-entry to be executed and that is better than the price of the previous position in a given %) in this way we give the trade a chance that the Take Profit is executed before. The downside is that the position is doubled in size. 'ACTIVATE DIVIDE TP': Divide the size of the TP in half. More probability of the trade closing but less profit.
█ STOP LOSS and RISK MANAGEMENT.
A good risk management is what can make your equity go up or be liquidated.
The % risk is the percentage of our capital that we are willing to lose by operation. This is recommended to be between 1-5%.
% Risk: (% Stop Loss x % Equity per trade x Leverage) / 100
First the strategy is calculated with Stop Loss, then the risk per operation is determined and from there, the amount per operation is calculated and not vice versa.
In this script you can use a normal Stop Loss or one according to the ATR. Also activate the option to trigger it earlier if the risk percentage is reached. '% RISK ALLOWED'
'STOP LOSS CONFIRMED': The Stop Loss is only activated if the closing of the previous bar is in the loss limit condition. It's useful to prevent the SL from triggering when they do a ‘pump’ to sweep Stops and then return the price to the previous state.
█ BACKTEST
The objective of the Backtest is to evaluate the effectiveness of our strategy. A good Backtest is determined by some parameters such as:
- RECOVERY FACTOR: It consists of dividing the 'net profit' by the 'drawdown’. An excellent trading system has a recovery factor of 10 or more; that is, it generates 10 times more net profit than drawdown.
- PROFIT FACTOR: The ‘Profit Factor’ is another popular measure of system performance. It's as simple as dividing what win trades earn by what loser trades lose. If the strategy is profitable then by definition the 'Profit Factor' is going to be greater than 1. Strategies that are not profitable produce profit factors less than one. A good system has a profit factor of 2 or more. The good thing about the ‘Profit Factor’ is that it tells us what we are going to earn for each dollar we lose. A profit factor of 2.5 tells us that for every dollar we lose operating we will earn 2.5.
- SHARPE: (Return system - Return without risk) / Deviation of returns.
When the variations of gains and losses are very high, the deviation is very high and that leads to a very poor ‘Sharpe’ ratio. If the operations are very close to the average (little deviation) the result is a fairly high 'Sharpe' ratio. If a strategy has a 'Sharpe' ratio greater than 1 it is a good strategy. If it has a 'Sharpe' ratio greater than 2, it is excellent. If it has a ‘Sharpe’ ratio less than 1 then we don't know if it is good or bad, we have to look at other parameters.
- MATHEMATICAL EXPECTATION: (% winning trades X average profit) + (% losing trades X average loss).
To earn money with a Trading system, it is not necessary to win all the operations, what is really important is the final result of the operation. A Trading system has to have positive mathematical expectation as is the case with this script: ME = (0.87 x 30.74$) - (0.13 x 56.16$) = (26.74 - 7.30) = 19.44$ > 0
The game of roulette, for example, has negative mathematical expectation for the player, it can have positive winning streaks, but in the long term, if you continue playing you will end up losing, and casinos know this very well.
PARAMETERS
'BACKTEST DAYS': Number of days back of historical data for the calculation of the Backtest.
'ENTRY TYPE': For '% EQUITY' if you have $ 10,000 of capital and select 7.5%, for example, your entry would be $ 750 without leverage. If you select CONTRACTS for the 'BTCUSDT' pair, for example, it would be the amount in 'Bitcoins' and if you select 'CASH' it would be the amount in $ dollars.
'QUANTITY (LEVERAGE 1X)': The amount for an entry with X1 leverage according to the previous section.
'MAXIMUM LEVERAGE': It's the maximum allowed multiplier of the quantity entered in the previous section according to the volume condition.
The settings are for Bitcoin at Binance Futures (BTC: USDTPERP) in 15 minutes.
For other pairs and other timeframes, the settings have to be adjusted again. And within a month, the settings will be different because we all know the market and the trend are changing.
[RS]JMA Modified RSI
RSI modified with Jurik's ma as a center point of difference.
-added optional calculation to simulate rsi with x length at certain timeframes.
-added optional barcolor.
[CP]VWAP + 9 Moving Averages + 3 Jurik MA9 Adjustable EMAs with offsets, with two of them having the option of adjustable 'bands' around them.
VWAP line along with an offset and adjustable 'band'.
Incredible 3 Jurik Moving Averages!
A single indicator giving you infinite options to play around with EMAs, VWAP and the amazing JMA.
Note: The bands look best in dark mode.
All MAs displayedThis is a collection of moving averages.
Thanks to everget and other pinecoders to pubblish their codes in tradingview.
I just collect a lot of moving averages in one script and transform them in stand alone functions, so you can copy and paste in your script the MA that best fit your needs.
Furthermore, the chart shows which moving average has more smooth and which one has less lag and so on: in this way it is easy to graphically compare moving averages.
Moving Average Compendium===========
Moving Average Compendium (16 MA Types)
===========
A selection of the most popular, widely used, interesting and most powerful Moving Averages we can think of. We've compiled 16 MA's into this script, and allowed full access to the source code so you can use what you need, as you need it.
-----------
From very simple moving averages using built-in functions, all the way through to Fractal Adaptive Averages, we've tried to cover as much as we can think of! BUT, if you would like to make a suggestion or recommendation to be added to this compendium of MA's please let us know! Together we can get a complete list of many dozens of types of Moving Average.
Full List (so far)
---
SMA - Simple Moving Average
EMA - Exponential Moving Average
WMA - Weighted Moving Average
VWMA - Volume Weighted Moving Average
DEMA - Double Exponential Moving Average
TEMA - Triple Exponential Moving Average
SMMA - Smoothed Moving Average
HMA - Hull Moving Average
ZLEMA - Zero-Lag Exponential Moving Average
KAMA - Kaufman Adaptive Moving Average
JMA - Jurik Moving Average
SWMA - Sine-Weighted Moving Average
TriMA - Triangular Moving Average
MedMA - Moving Median Average
GeoMA - Geometric Mean Moving Average
FRAMA - Fractal Adaptive Moving Average
Line color changes from green (upward) to red (downward) - some of the MA types will "linger" without moving up or down and when they are in this state they should appear gray in color.
Thanks to all involved -
Good Luck and Happy Trading!
FALSE BREAKOUT NO PROBLEM !! CHK TWIN MOV AVG SEGREGATED RIBBON PROBLEM DEFINITION 1 : To Avoid False Breakouts
PROBLEM DEFINITION 2 : To Ascertain if the trend has changed when a Stock opens with a Gap up or Gap Down
## PROBABLE SOLUTION : Use a Moving Average with lot of latency
## PROBLEM WITH ABOVE SOLUTION : Misses on lot of trades, Late exits leads to drain on winning trades
S O L U T I O N
An Indicator which plots two different types of Moving Averages at the same time
For the MA length 5-100 a fast plot of choice
For the MA Length 110-200 a plot with a lag to ascertain the trend
And then ONE LAST MAN STANDING with even bigger MA length for a lagging indicator to save the day
This indicator gives one 9X9 = 81 Permutation Combinations to look at the markets
One can devise strategies basis if one particular MA Type has crossed another MA Type
Feel free to post the strategies you have come out with!
//// CREDITS AND ACKNOWLEDGEMENTS //////////////////////////////////////////////////////////////////
Following contributors helped the author ::
Credits to Neobutane for his Multiple Type Mov. Avg. Guppy at ......
hxxps://www.tradingview.c0m/script/UQAv1U0c-MA-Study-Different-Types-and-More-NeoButane/
Credits to Jose5770 for sharing Jurik MA code at .....
hxxps://www.tradingview.c0m/script/uqYvkHna-Trend-Direction-Force-Index/
Appreciate and Thank You for sharing your work.
//////////////////////////////////////////////////////////////////////////////////////////////////////
P.S You might notice in the code that the few plots are skipped. It is done to fasten the indicator without compromising
on the functionality
CB Moving Average [ChuckBanger]I was experimenting with the zero lag moving average from John Ehlers and the Hull moving average and noticed that they seemed to respond in complementary to each other. They blend together to make a moving average which responds with almost no lag at all. It is similar to Jurik's moving average clones i have found here on TradingView...
This is a comparison to Everget's Juriks Moving Average . The green line is CB Moving Average and the purple line is JMA
SuPeR-RePaNoCHa #2TP#This is the last of the 'RePaNoCHa' script for Automatic Trading ;-) ... This time with two take profits ...
It Use 6 indicators + volume:
-JURIK MOVING AVERAGE
-RANGE FILTER
-ADX
-PARABOLIC SAR
-RSI + VOLUME WEIGHTED
-MACD
-VOLUME
To close the position you can choose between 2 Take Profit and the amount to use on each one.
You can transform it yourself into 'study' mode to get alerts.
Take Profits can be generated from the same entry, (syntax example on the script) so the fees will be lower (0.04 + 0.02 / 2 = 0.03).
Settings for BINANCE FUTURES BTC:USDT
Enjoy...
Jurik Moving Average Crossover Strategy [ChuckBanger]The classic moving average crossover strategy does not work well in markets that, instead of trending, tend to frequently reverse within a trading range. The lag between the actual time the market has reversed direction and when the moving average is signalling a trade, the trend is already over and the market is about to go against your position. In this environment, a more appropriate trading strategy is suggested here using an JMA Keltner Channel.
The idea is to create a channel based of support and resistance. When the market breaks out of the channel, and fails to maintain momentum. It is likely the price will fall back toward the center of the channel. This tendency can be exploited in the following manner.
In the chart above, The aqua and maroon (center line) and the blue lines are part of a channel. The middle line is a slow running JMA of the closing prices, with Length = 30 and phase = 0. The upper blue band is constructed by adding 1.5 times of 30-bar ATR (average true range) to the center JMA line and the lower blue band by deducting the same amount. There is a grey line running through the data- That is a fast running JMA with length = 5 and phase = 100 representing the price.
The red dots indicate that the the price is going back in the channel and the market is retracting from a failed upward breakout, and the green dots mark when price is retracting from a failed downward breakout. These are places where one might want to enter the trade. The orange dots indicate where price crosses the center line, a reasonable place to take profit from or even exit the trade.
The center line also shows the up or down movements if the setting is ticked. This feature is useful to use when exit a trade. For example, you enter a long position on a green dot signal and the color is maroon. You can wait for 3-5 candles (depending of markets). And if the color doesn’t change it can be an indication that the price is going lower. Here it is possible to switch to a short possible or the opposite apply if you enter on a red dot.
The parameter use in this study is for demonstrating purposes only. This is to show how you can use JMA. Do not trade with real money without thoroughly test the strategy. And always use stop-losses.
$ SuPeR-RePaNoCHa $ [Alerts]Script for automatic trading (Alerts). This is the second part of the previous RePanoCHa script but with Take Profit.
It Use 6 indicators + volume:
-JURIK MOVING AVERAGE
-RANGE FILTER (DONOVAN WALL)
-ADX (ORIGINAL VERSION)
-PARABOLIC SAR
-RSI + VOLUME WEIGHTED (LAZYBEAR)
-MACD
-VOLUME
To close the position you can choose between Take Profit only, Trailing Stop only or both at the same time.
Example of bot syntax: (alerts once per bar)
LONG | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=order | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position b=short t=market ro=1 | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT b=long q=100% t=market | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position b=long p=0.7% q=50% t=post ro=1
SHORT | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=order | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position b=long t=market ro=1 | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT b=short q=100% t=market | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position b=short p=-0.7% q=50% t=post ro=1
LONG TP | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position q=50% t=market ro=1 (if you set the TP from entry this alert is not necessary)
SHORT TP | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position q=50% t=market ro=1 (if you set the TP from entry this alert is not necessary)
LONG TS | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position q=10% t=market // (alerts once per minute)
SHORT TS | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position q=10% t=market // (alerts once per minute)
XLONG/STOP-LOSS | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=order | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position b=long t=market ro=1
XSHORT/STOP-LOSS | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=order | delay=1 | e=BINANCEFUTURES a=ACCOUNT s=BTCUSDT c=position b=short t=market ro=1
Jurik Smoothed Williams %R by jwammo12This is Williams %R that has been used using Jurik's method. This removes a lot of the chop and false signals of William's %R while adding only minimal lag.
Trend Angle BFThanks to Duyck for the idea for this code, and for the code itself. Also thanks to Everget, KyJ and kiasaki for code used in the calculations.
The indicator measures Moving average angles and generates a long or short signal based on the slope.
The chart used to optimise the current settings is XBT/USD on Bitmex 8hr.
You can change the MA length and stop loss, take profit params in the settings.
Green = long, red = short, white = no trade!
Jurik PPO PercentileRank Mkt Tops & BottomsI saw that Juriks Moving average and its variation of the following script has been pretty popular on MT4/MT5 FX so I decided to try to recreate it in Tradingview.
The basic logic was taken from:
Inspired by the script by one of the most active pinescripters in the early days.
The Jurik Moving average has been created by one of the most active pinescripters nowadays everget:
Those two did all the heavy lifting I am just putting all together.
Cheers to everyone and I hope you guys are a having better day than I am.
Dickinson Moving Average (DMA)Implementation of the "Dickinson Moving Average" from the r/algotrading post by Nathan Dickinson
Quoted from the author of the Dickinson Moving Average:
"I was experimenting with the “zero lag” code from John Ehlers and the Hull Moving Average and noticed that they seemed to respond in complementary ways when properly set up. With the right starting values, they blend together to make a moving average which responds with one (or maybe even half a bar) of lag. To my eye, it looks to be almost as good as the Jurik Moving Average."
Optional parameter input available to use Exponential Hull Moving Average (EHMA) instead of WMA for the Hull MA is available.
Acknowledgements/Credits:
Nathan Dickinson, Dickinson Moving Average
@RicardoSantos, Function for Hull Moving Average
Exponential Hull Moving Average sourced from:
// Raudys, Aistis & Lenčiauskas, Vaidotas & Malčius, Edmundas. (2013). Moving Averages for Financial Data Smoothing.
// Communications in Computer and Information Science. 403. 34-45. 10.1007/978-3-642-41947-8_4.
@Everget, Jurik Moving Average
General Filter Estimator-An Experiment on Estimating EverythingIntroduction
The last indicators i posted where about estimating the least squares moving average, the task of estimating a filter is a funny one because its always a challenge and it require to be really creative. After the last publication of the 1LC-LSMA , who estimate the lsma with 1 line of code and only 3 functions i felt like i could maybe make something more flexible and less complex with the ability to approximate any filter output. Its possible, but the methods to do so are not something that pinescript can do, we have to use another base for our estimation using coefficients, so i inspired myself from the alpha-beta filter and i started writing the code.
Calculation and The Estimation Coefficients
Simplicity is the key word, its also my signature style, if i want something good it should be simple enough, so my code look like that :
p = length/beta
a = close - nz(b ,close)
b = nz(b ,close) + a/p*gamma
3 line, 2 function, its a good start, we could put everything in one line of code but its easier to see it this way. length control the smoothing amount of the filter, for any filter f(Period) Period should be equal to length and f(Period) = p , it would be inconvenient to have to use a different length period than the one used in the filter we want to estimate (imagine our estimation with length = 50 estimating an ema with period = 100) , this is where the first coefficients beta will be useful, it will allow us to leave length as it is. In general beta will be greater than 1, the greater it will be the less lag the filter will have, this coefficient will be useful to estimate low lagging filters, gamma however is the coefficient who will estimate lagging filters, in general it will range around .
We can get loose easily with those coefficients estimation but i will leave a coefficients table in the code for estimating popular filters, and some comparison below.
Estimating a Simple Moving Average
Of course, the boxcar filter, the running mean, the simple moving average, its an easy filter to use and calculate.
For an SMA use the following coefficients :
beta = 2
gamma = 0.5
Our filter is in red and the moving average in white with both length at 50 (This goes for every comparison we will do)
Its a bit imprecise but its a simple moving average, not the most interesting thing to estimate.
Estimating an Exponential Moving Average
The ema is a great filter because its length times more computing efficient than a simple moving average. For the EMA use the following coefficients :
beta = 3
gamma = 0.4
N.B : The EMA is rougher than the SMA, so it filter less, this is why its faster and closer to the price
Estimating The Hull Moving Average
Its a good filter for technical analysis with tons of use, lets try to estimate it ! For the HMA use the following coefficients :
beta = 4
gamma = 0.85
Looks ok, of course if you find better coefficients i will test them and actualize the coefficient table, i will also put a thank message.
Estimating a LSMA
Of course i was gonna estimate it, but this time this estimation does not have anything a lsma have, no moving average, no standard deviation, no correlation coefficient, lets do it.
For the LSMA use the following coefficients :
beta = 3.5
gamma = 0.9
Its far from being the best estimation, but its more efficient than any other i previously made.
Estimating the Quadratic Least Square Moving Average
I doubted about this one but it can be approximated as well. For the QLSMA use the following coefficients :
beta = 5.25
gamma = 1
Another ok estimate, the estimate filter a bit more than needed but its ok.
Jurik Moving Average
Its far from being a filter that i like and its a bit old. For the comparison i will use the JMA provided by @everget described in this article : c.mql5.com
For the JMA use the following coefficients :
for phase = 0
beta = pow*2 (pow is a parameter in the Jma)
gamma = 0.5
Here length = 50, phase = 0, pow = 5 so beta = 10
Looks pretty good considering the fact that the Jma use an adaptive architecture.
Discussion
I let you the task to judge if the estimation is good or not, my motivation was to estimate such filters using the less amount of calculations as possible, in itself i think that the code is quite elegant like all the codes of IIR filters (IIR Filters = Infinite Impulse Response : Filters using recursion) .
It could be possible to have a better estimate of the coefficients using optimization methods like the gradient descent. This is not feasible in pinescript but i could think about it using python or R.
Coefficients should be dependant of length but this would lead to a massive work, the variation of the estimation using fixed coefficients when using different length periods is just ok if we can allow some errors of precision.
I dont think it should be possible to estimate adaptive filter relying a lot on their adaptive parameter/smoothing constant except by making our coefficients adaptive (gamma could be)
So at the end ? What make a filter truly unique ? From my point of sight the architecture of a filter and the problem he is trying to solve is what make him unique rather than its output result. If you become a signal, hide yourself into noise, then look at the filters trying to find you, what a challenging game, this is why we need filters.
Conclusion
I wanted to give a simple filter estimator relying on two coefficients in order to estimate both lagging and low-lagging filters. I will try to give more precise estimate and update the indicator with new coefficients.
Thanks for reading !
Jurik RSXAdopted to Pine from www.prorealcode.com .
I haven't yet understood the details of the algorithm but it matches the original Jurik's RSX one to one.
Jurik's RSX is a "noise free" version of RSI, with no added lag. To learn more about this indicator see www.jurikres.com .
Good luck!