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

Versionshinweise: 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.
Versionshinweise: Updated comments.
Versionshinweise: Updated comments.
Versionshinweise: 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.
Versionshinweise: Fixed comments.
Versionshinweise: Reorganized Inputs.
Von Favorisierten Skripten entfernen Zu Favorisierten Skripten hinzufügen
"The stock market is a device for transferring money from the impatient to the patient."
— Buffet

Tools and ideas for all Pine coders:


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 Antworten
@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.
+4 Antworten
@LucF, thanks , i will look to get benefit from your expertise
Best MAs code i've seen so far. Well done!
LucF e2e4mfck
@e2e4mfck, Thx for the good words. Appreciate.
+1 Antworten
Startseite Aktien-Screener Forex-Screener Krypto-Screener Wirtschaftskalender So funktioniert es! Chartmerkmale Preise Einen Freund empfehlen Hausregeln Hilfe Center Webseite & Brokerlösungen Widgets Charting Lösungen Lightweight Charting Library Blog & News Twitter
Profil Profileinstellungen Konto und Abrechnung Angeworbene Freunde Coins Meine Support Tickets Hilfe Center Veröffentlichte Ideen Followers Ich folge Private Nachrichten Chat Abmelden