5 MAs w. alerts [LucF]

Is this gazillionth MA indicator worth an addition to the already crowded field of contenders? I say yes! This one shows up to 5 MAs and 6 different marker conditions that can be used to create alerts, among many other goodies.

  • MAs can be darkened when they are falling.
  • MAs from another time frame can be displayed, with the option of smoothing them.
  • Markers can be filtered to Longs or Shorts only.
  • EMAs can be selected for either all or the two shortest MAs.
  • The background can be colored using any of the marker states except no. 3.
  • Markers are:
  • 1. On crosses between any two user-defined MAs,
  • 2. When price is above or below an MA,
  • 3. On Quick Flips (a specific setup involving a cross, multiple MA states and increasing volume , when available),
  • 4. When the difference between two MAs is within a % of its high/low historic values,
  • 5. When an MA has been rising/falling for n bars,
  • 6. When the difference between two MAs is greater than a multiple of ATR.
Some markers use similar visual cues, so distinguishing them will be a challenge if they are used concurrently.

Alerts can be created on any combination of alerts. Only non-consecutive instances of markers 5 and 6 will trigger the alert condition. Make sure you are on the interval you want the alert to run at. Using the “Once Per Bar Close” trigger condition is usually the best option.

When an alert is created in TradingView, a snapshot of the indicator’s settings is saved with the alert, which then takes on a life of its own. That is why even though there is only one alert to choose from when you bring up the alert creation dialog box and choose “5 MAs”, that alert can be triggered from any number of conditions. You select those conditions by activating the markers you want the alert to trigger on before creating the alert. If you have selected multiple conditions, then it can be a good idea to record a reminder in the alert’s message field. When the alert triggers, you will need the indicator on the chart to figure out which one of your conditions triggered the alert, as there is currently no way to dynamically change the alert’s message field from within the script.

Background settings will not trigger alerts; only marker configurations.

MAs are just… averages. Trader lure would have them act as support and resistance levels. I’m not sure about that, and not the only one thinking along these lines. Adam Grimes has studied moving averages in quite a bit of detail. His numbers point to no evidence indicating they act as support/resistance , and to specific MA lengths not being more meaningful than others. His point of view is debated by some—not by me. Mean reversion does not entail that price stops when it reaches its MA; rather, it makes sense to me that price would often more or less oscillate around its MA, which entails the MA does not act as support/resistance . Aren’t the best mean reversion opportunities when price is furthest away from its MA? If so, it should be more profitable to identify these areas, which some of this indicator’s markers try to do.

I think MAs can be much more powerful when thought of as instruments we can use to situate price events in contexts of various resolutions, from the instantaneous to the big picture. Accordingly, I use the relative positions and slopes of MAs in both discretionary and automated trading; but never their purported ability to support/resist.

Regardless of how you use MAs, I hope you will find this indicator useful.

Biased References
The Art and Science of Technical Analysis: Market Structure, Price Action, and Trading Strategies, Adam Grimes, 2012.
Does the 200 day moving average “work”?
Moving averages: digging deeper

Информация о релизе: Converted to v4.
For each of the 5 MAs, added independent choice of:
- 9 different MA types: SMA, EMA, RMA, WMA, KAMA, VWMA, ALMA, Lin Reg, HMA.
- Higher timeframe selection
- Source
You have the possibility of smoothing higher timeframe MAs.
You can choose to have higher timeframe MAs repaint or not.
You can choose to have high markers in green or red for the markers that plot dots above/below price or on MAs.

Chart shows a 5 and 15 EMA with 50, 200 and 400 KAMAs. The background is colored on the closes above/below MA3 (marker 2).
Active markers are:
- Marker 1: set to crosses between M1 and M4
- Marker 3: Quick Flips
If an alert was configured now, it would trigger on either marker 1 or 3, since they are active, and you could configure the indicator to trigger alerts on longs or shorts only.
Информация о релизе: Updated comments.
Информация о релизе: Updated comments.
Информация о релизе: Added possibility to define an interval for each MA above which the MA is hidden. The default for MA4 and MA5 is 1D, so they are automatically hidden on this 3D chart.
Информация о релизе: Fixed comments.
Информация о релизе: Reorganized Inputs.
Удалить из избранных скриптов Добавить в избранные индикаторы
"The stock market is a device for transferring money from the impatient to the patient."
— Buffet

Tools and ideas for all Pine coders:


HOLY!! I have never seen a script like this are certainly a master of pine. Because I'm a noob to pine, my script writing is not good. To automate this script trading on mt4, not only would I need to change this script to 'strategy' but I would have to add some code for long and short positions correct? Thank you for your help with educating me (all of us) are someone I follow so I can learn as much as possible. stay safe. Justin
LucF j9productions
@j9productions, Thx for the good words and I'm happy you find the code useful. It would be relatively simple to build strategy entries from the code, yet I don't usually include strategy code in my scripts because entries are probably the most trivial part of usable, real-world strategies. For me, the value of strategies lies more in the numerous other design decisions they require, and how well they coalesce to provide the synergy and characteristics that make a particular strategy usable in specific markets—and compatible with a trader's personality and objectives. I don't see how I would add value by making those decisions for traders. Strategies also require more overhead, so I prefer the study format because it does not penalize traders who don't need the indicator's logic in strategy form.

I have written the "Backtesting & Trading Engine" for traders interested in starting from what I consider to be a sound architecture for my own needs. If that design suits them, they can use the Engine to build their own strategies with it:
@LucF, WOW - Thank you so much for your time and much information to digest but I love it - I will review all and especially your Engine. Again, thank you soooooooooooooooo much and seriously, you are a PINE Master - all the best. Sincerely, Justin
hi, like and interesting your idea to complete an indicator.
Love the organization.
Not sure what I like more: your scripts, or your thorough descriptions followed by your methodology. If you ever start a blog I'll be your first subscriber!
LucF kviateq
@kviateq, ) Thx. I'm thinking of starting a long series of tutorials right here on TV for 2020.
+3 Ответить
@LucF, already on it ? plz
LucF daytraderph
@daytraderph, Not yet. My idea was to publish chapters of a future book as Ideas here on TV, before the book is published, so TV traders can be its first readers. The book's focus won't be on trading setups, as they already receive a disproportionate amount of attention, in my view. I will instead cover the other, numerous and often neglected aspects of trading I think newcomers should master. While there is a high probability that I will write the book, I cannot say when that will be. I am currently invested in other projects that take up quite a bit of my time, but the book is slowly coming together, structurally. TV users will be the first to know when the first chapters pop up.
+5 Ответить
@LucF, thanks , i will look to get benefit from your expertise
Домой Скринер акций Скринер форекс Скринер криптовалют Экономический календарь О проекте Особенности Цены Приведи друга Правила поведения Справочный центр Решения для сайтов и брокеров Виджеты Графики TradingView для сайтов Легкая версия графиков Блог и новости Твиттер
Профиль Настройка профиля Счёт и оплата Ваши друзья Монеты Мои запросы в поддержку Справочный центр Опубликовано идей Подписчики Подписки Личные сообщения Чат Выйти