Momentum adjusted Moving Average by DGT

A brand new Moving Average, calculated using Momentum, Acceleration and Probability (Psychological Effect).

Momentum adjusted Moving Average( MaMA ) is an indicator that measures Price Action by taking into consideration not only Price movements but also its Momentum, Acceleration and Probability. MaMA , provides faster responses comparing to the regular Moving Average

Here is the math of the MaMA idea

Momentum measures change in price over a specified time period

momentum = source – source(length)
source, indicates current bar’s price value
source(length), indicates historical price value of length bars earlier

Lets play with this formula and rewrite it by moving source(length) to other side of the equation

source = source(length) + momentum

to avoid confusion let’s call the source that we aim to predict as adjustedSource

adjustedSource = source(length) + momentum

looks nice the next value of source simply can be calculated by summing of historical value of the source value and value of the momentum. I wish it was so easy, the formula holds true only when the momentum is conserved/constant/steady but momentum move up or down with the price fluctuations (accelerating or decelerating)

Let’s add acceleration effects on our formula, where acceleration is change in momentum for a given length. Then the formula will become as (skipped proof part of acceleration effects, you may google for further details)

adjustedSource = source(length) + momentum + 1/2 * acceleration

here again the formula holds true when the acceleration is constant and once again it is not the case for trading, acceleration also changes with the price fluctuations

Then, how we can benefit from all of this, it has value yet requires additional approaches for better outcome

Let’s simulate behaviour with some predictive approach such as using probability (also known as psychological effect), where probability is a measure for calculating the chances or the possibilities of the occurrence of a random event. As stated earlier above momentum and acceleration are changing with the price fluctuations, by using the probability approach we can add a predictive skill to determine the likelihood of momentum and acceleration changes (remember it is a predictive approach). With this approach, our equations can be expresses as follows

adjustedSource = source(length) + momentum * probability
adjustedSource = source(length) + ( momentum + 1/2 * acceleration ) * probability
, with acceleration effect

Finally, we plot MaMA with the new predicted source adjustedSource, applying acceleration effect is made settable by the used from the dialog box, default value is true.

What to look for:
• Trend Identification
Support and Resistance
• Price Crossovers

Recommended settings are applied as default settings, if you wish to change the length of the MaMA then you should also adjust length of Momentum (and/or Probability). For example for faster moving average such as 21 period it would be suggested to set momentum length to 13
Alternative usage, set moving average length to 1 and keep rest lengths with default values, it will produce a predictive price line based on momentum and probability. Experience acceleration factor by enabling and disabling it


MaMA provide an added level of confidence to a trading strategy and yet it is important to always be aware that it implements a predictive approach in a chaotic market use with caution just like with any indicator

Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely

Disclaimer: The script is for informational and educational purposes only. Use of the script does not constitutes professional and/or financial advice. You alone the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script
Release Notes: This update introduces an experimental application of feedback concept common in Electronic Engineering, attempting to present additional value/insight to the Indicator

Feedback concept in Electronic Engineering
Negative feedback (or balancing feedback) is applied to reduce the fluctuations, whether caused by changes in the source or by other disturbances. The applied negative feedback can improve performance, gain stability, linearity and reduce sensitivity to parameter variations due to environment.
Whereas positive feedback tends to lead to instability via exponential growth, oscillation or chaotic behaviour

mainly all testing is performed with crypto market, others sometimes requires to reduce feedback multiplier

Detailed explanation and calculation approach can be found in the description of "Rate of Return (RoR) by DGT"
Release Notes: backtest ability added for price crosses above or below MaMA line

optimization can be performed with available settable variables
Release Notes: alert condition added
Release Notes: Enable Non-Repaint Version option added
Release Notes: exit price calculation error fixed when stop loss condition meets

many many thanks for you highly valuable comments @sotiri 🙏
Release Notes: removed "Enable Non-repaint Vertion" option and made Alerts and BackTest Non-Repaint
Release Notes: Enhancements in BackTest Framework

1-) Historical Data Evaluation
in the real-time processing when the condition is satisfied to avoid repainting the signals are presented on the next bar, this feature was already available with this study
change implemented with this update is to made historical data evaluation behavior same as real-time behavior and all plottings, statistical panel calculations are performed based on the next bar

- traders will observe the same behavior both in real-time and in historical bars (even when the study is reloaded)
- trade statistics will display whatever the user traded on the real-time bars with the signals generated
- since the signals are generated on the next bar, “Entry/Exit Price Assumption” input necessity is no longer required, trades with the backtest framework will be assumed as open price on the next candle

2-) Early Warning : Alert + Label
As a rule as explained above, signals are triggered on the next bar in case the condition is still valid and the logic of the study is already aware of the likelihood of an signal occurrence on the next bar but the trader who is analyzing the chart is not (according to this study’s logic of course). So to increase the awareness, with this update ;
 - a label with a warning sign is going to be plotted which of course is subject to repaint but will warn the trader to keep eyes closer on the instrument and proceed trading immediately on the next bar if the signal is confirmed and presented on the chart.
 - for the same warning also an alert is defined (using new alert() function call), so the trader will be able to be notified with the probable not yet confirmed trade opportunity in advance, even if the trader is not monitoring the instrument.
Having said that, I would like to remind : Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely.

3-) Improved Conditions
 Avoid Sudden Price Changes : Since the long/short conditions are triggered on next bar there might be cases where a sudden change in price direction and hence signal change may occur especially in sideway market conditions with low volatility, this option is to avoid such cases

 Candle Direction as Confirmation : confirms signal if the candle formation is in favor of the trade

Please note : selecting the above options will cause the signals to be executed on the second bar so to have the study non-repaint. For test purposes only you may enable "❗❗❗ Simulate Trade on Next Bar : Only For Test Purpose (REPAINTS)" option to simulate the trade on the next bar.

Important note : stop loss condition will be executed when price fall below the calculated value and trade will be closed with the close price on bar close (not yet able to get the price value at the moment of the cross). Stop loss condition is subject to repainting and to avoid any further loss an alert can be triggered at the moment the first cross is observed. Since stop loss is subject to repaint and in case it happens the statistical panel calculation will not be able to calculate till the bar is closed. You may disable application of stop loss from user dialog box to avoid any inconsistency that may appear on statistical panel and observe results of the trades executed without stop loss.

Other updates in Study
• Enhanced Alerts setup to have two alerts settings for bull condition and two for bear condition, one with the repaint version (early warning) and one non-repaint version (on the next bar if still condition holds true).
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


thank you so much for quick answer!
200 coins
+2 Reply
dgtrd smartiesss
;-) Thank You @smartiesss
Is it possible to get an excel foolproof for this?
dgtrd LTZ33
hello @LTZ33, i wish i know how to get. TV have some export abilities to excel but i do not have any idea how
Does this indicator repaint sir and can you suggest which is the best indicator for beginner from your creation
dgtrd Venkataze
hello @Venkataze, no, it is not, btw, a planned update is on the way where there will option where it will non-repaint and also there will be repaint option (to be warned earlier and may be to take the trade if your startegy or other indicator confimations are on place).

regarding the indicators for beginners : the easiest to interpret is probably SuperTrend and may be Bollinger Bands (links below), for an overview of an instrumnet my technical analyist can help. Try others as well, usually i aim to place a label of you you will interpret the study to easy the job especially for beginners

SuperTrend :

Bollinger Bands:


Also you may look at the ones that have Backtest Framework that simulates the trades : MACD-X, More Than MACD, Momentum Acceleration, Elliott Wave Oscillator Signals, Logistic RSI, STOCH, ROC, AO, ...

Great work. much appreciated, thanks
dgtrd Jamescba1993
@Jamescba1993, thank You
this is a wonderful piece of work - plus the code is written for 5-year old programmer (thank you).

have one thought/question for you: was wondering whether trading acceleration could be multiplied by some m "mass" to get some demand output Force(d) and some supply output Force(S)? Essentially the goal is to calculate Force Normal on any given candlestick to determine the probabilities underlying

1) short-term direction retroactively (not just up and down, but specific angle of ascent/descent as well), and,

2) the probability that a "throw over" results in binary success(bears win)/failure(bulls squeeze).

Would really find your thoughts interesting, so please let me know if you have any.

Thanks again, this script is awesome.
dgtrd Perma_Pig
Hello @Perma_Pig, thnak you :)

i have assumed to multiply with the occurance of bull/bear ratio for a given period. do you have any other/better suggestion in your mind? One user have used this code and he assumed multiplying with a user defined value from the input. the occurance of bull/bear ratio does not count the cnadle length may be atr may help in that sense (may be worth testing)

atr may also help with "specific angle of ascent/descent" or including somehow slope in action could be worth.

thnaks for your valuable comment
Home Stock Screener Forex Screener Crypto Screener Economic Calendar About Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter