OPEN-SOURCE SCRIPT

+ ALMA Trend Detector

Atualizado
Hi, again. Here I have a nice moving average script designed to get you into trends and keep you in trends until the opportune moment comes to exit. And, as with any indicator, or suite of indicators, designed to get one into trends and keep him/her in a trend, they do not do so well in chop/ranging/mean reversion conditions, though I would say this one is better than most, otherwise I wouldn’t be fitting it into my trading system.

This is a huge improvement, in my opinion, over an indicator I found recently, and like quite a bit by samsmilesam, which you can find here: tradingview.com/u/samsmilesam/

In this adaptation of his script I changed a bunch of things, but kept the spirit of the indicator true.

This indicator utilizes three different length Arnaud Legoux moving averages, known for being extremely low lag, and incredibly adjustable (though I find the original authors settings excellent).

While he has buy and sell signals triggering regardless of the fast and slow ma’s position to the trending ma, I actually take the trending ma into account. Furthermore, I wouldn’t say I coded in signals indicating buying and selling, but that I coded in signs that answer the question “what kind of trend are we in?” as well as possible ideal trade exits (which couuuuuld also be taken as entries, but aren’t necessarily meant to).

So, the deets on this:

1) 5 period, 20 period, and 70 period ALMAs. Fast, slow and trend. All customizable independent of each other (unlike the sam’s). All three also change color based on their own individual trends.

2) Uptrends are identified when price is closing above the Trend ma, and both Fast and Slow ma’s are above the Trend ma, and vice versa for downtrends. There are in-between points when a trend is not identified, and this is when price closes above or below the Trend ma, but the other two ma’s have not crossed it. Background color is used to identify the trend.

3) Trade exits are based on closing price and Fast and Slow ma’s relative to the Trend ma, once again. To signal exiting an uptrend price must close below both Fast and Slow ma’s and both Fast and Slow ma’s must be above the Trend ma; and vice versa for exiting a down trend. Obviously there may be false signals, but there are fewer signals, and I think it’s a better strategy than most. I prefer to filter out as much noise as possible. There’s little worse in my opinion than an indicator that gives too many false signals, but obviously it’s impossible to remove them all. Some discretion is necessary on the part of the trader.

4) So what does this mean for trade entries? Well, you can certainly enter a trade on a signal for an exit (go long on a short exit signal) if the chart looks good for that. Or you can wait for trend confirmation with the background color, entering on a pullback to the ma’s perhaps. Or you can enter in the “no man’s land” in between trends. If you’ve exited and price continues on trending your best bet would be to wait for a pullback into the ma’s or a s/r level, or look for the next candle that closes beyond the Fast and Slow ma’s. These are just thoughts of mine.

5) Lastly, there are alert conditions set for uptrends, downtrends and both long and short exits!

Enjoy the indicator! I think with some sort of bands or channels for those times when the market is rangebound or in chop, you could really crush it with this.
Notas de Lançamento
A fresh, and imo, much needed update.

Added inputs for turning background color on and off.
Added inputs for turning off both types of exit symbols.
Fudged around with how the indicator determines an exit, and decided to create a second type, so now there is an early exit sign (which shows more frequently, and symbols for those who might want different confirmation to exit (if you're using this script by itself).
I changed some of the default settings for the moving averages, as I like these a bit more.
Also, made the floats for sigma and offset adjustable in smaller increments, so the little arrows are actually useful for adjusting these numbers now. Also makes it a lot easier to fine tune the MA's to your desired preference.
Added a "Quick" MA before I realized I could use price close as an input for crossover/under strategies. Decided to leave it in case you the user might want to use it. It is set to a 1 period, and is not visible by default.

That's all! Hope you like!
Notas de Lançamento
added multi-timeframe functionality--trade with higher timeframe bias background or moving averages or both
Notas de Lançamento
-added 200 EMA option for assessing larger trend
-updated color and transparency code
Notas de Lançamento
Added optional bollinger bands and keltner channels. They are off by default. They both use the mid-term ALMA as their basis. The mid-term ALMA is set to 50, and with the default settings is basically a 20sma (try it: add a 20sma to your chart). Obviously if you adjust the length and settings of the mtALMA the bands and channel boundaries will move as well.

Also, added color inputs! Apologies to anyone using this since my last update who wanted to change colors of the plots. I've written this before, but I'm not a coder, so learning new things here and updating scripts to new versions takes some time as I learn what to do. Anyway, now you can change colors for all of the plots. Will probably add some things later, but this is pretty good for now.
Notas de Lançamento
added groups to the inputs section so that things are more organized

eliminated color.new functionality because it didn't add anything, and kept users from being able to adjust transparency of moving averages

turned bollinger bands and keltner channels into a sort of ribbon-band, or wide band
screenshots below:

snapshot

Bollinger bands above. Simply enable both bands and you get the above style. By default the band plots (the actual lines) are turned off. You can turn them on if you like in the "style" tab.

snapshot

Keltner channels above. Same for this as Bollinger Bands.
Notas de Lançamento
- updated to pinescript version 5
- tuned the default settings for moving averages a bit better
Notas de Lançamento
I'm publishing updates to all of my indicators, so I'm just going to comment on everything here since most of the updates are common across most of my indicators.

Updates specific to the ALMA Trend Detector are changing some colors; adding a neutral, or momentum/trend change, color to the fast and medium period moving averages; adding an optional fill between the same two moving averages indicating a momentum/trend change; and adding some additional alerts.

User Non-Visible Updates (basically backend stuff that makes:
- changes in code legibility and consistency across all indicators (basically standardizing the coding across as many indicators as possible)
- implementation of libraries into my indicators; which helps significantly in doing what I typed above; which in turn will make creating any new indicators, if they are of the type to use these libraries, much simpler
- updated descriptions for all indicators, which should (it's possible I've forgotten things) reflect changes I've made recently and any I may have made in the past after first publication (this is very minor, but as I was changing so much I thought I may as well--I don't intend to update these much, if at all, in the future)

User Visible Updates:
- as I mentioned everything now uses my moving averages library and volatility bands library--this cuts down the total amount of code significantly, and has made it easier for me to add moving averages, or volatility bands to these indicators because I only had to/have to add it one time (to the library) rather than multiple times across all indicators*
- since creating these libraries I've added several new moving averages (Kaufman Adaptive, Laguerre Filter, McGinley Dynamic (doesn't work for all), and Zero-lag) to them while retaining all the previous with the exception of the UMA, which wasn't implemented consistently across all indicators anyway
- eliminated having two Bollinger Bands with different standard deviations and a fill between them in exchange for one with the band fill implementation that I use on my Donchian Channels Bands
- part of my code consistency across all indicators resulted in a much needed organization of the 'style' tab

*(affects all but the Wavetrend Oscillator, Wavetrend Oscillator Overlay, Jurik KDJ, Average Candle Bodies Range, Bollinger Bands Width, ALMA Trend Detector, Ultimate Moving Average, Donchian Channels, and Dynamic Donchian Channels)
almacrossalmatrendarnaudlegouxmovingaveragebackgroundcolorCandlestick analysisMoving AveragesmovingaveragecrossovernononsenseforexnononsensefxOscillators

Script de código aberto

No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Quer usar esse script no gráfico?


Também em:

Aviso legal