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
הערות שחרור: 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"
הערות שחרור: backtest ability added for price crosses above or below MaMA line

optimization can be performed with available settable variables
הערות שחרור: alert condition added
הערות שחרור: Enable Non-Repaint Version option added
הערות שחרור: exit price calculation error fixed when stop loss condition meets

many many thanks for you highly valuable comments @sotiri 🙏
הערות שחרור: removed "Enable Non-repaint Vertion" option and made Alerts and BackTest Non-Repaint
הערות שחרור: 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).
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר סקריפט זה פרסם אותו עם קוד פתוח, כך שסוחרים יוכלו להבין ולאמת זאת. הידד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום הנו בכפוף ל כללי הבית . אתה יכול להגדירו כמועדף ולהשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?


thank you so much for quick answer!
+2 השב
dgtrd smartiesss
;-) Thank You @smartiesss
sir, can i use this for TF low ranges.. like 1m->>30m
dgtrd CryptoTWFBIG
hello @CryptoTWFBIG,

this particular study includes a backtest framework which will allow you to simulate long trades and observe results based on different timeframes. You may evaluate the results to see whether it fits with lower timeframes or whether it fits your tradiny strategy

Two questions - any updates on the new release?

What made you decide to write in your own backtesting routine rather than use the one TV includes?
dgtrd LasciviousMonk
hello @LasciviousMonk,

Initially my plan was just to add the ability to optimize and observe the result of the study, so I added a very simple backtesting framework that simulates long trades whcih relies on the signals from the main idea of study and presents the statistical information on the panel. The same framework is available in some of my other studies too

I observed from user comments that they are making use of the framework as a trading strategy, so I made some improvements by adding some filtering and additional conditions.

Whenever i come up with something that may increase the scripts performance, especially when something worth increasing the study's trading success and/or a worthy suggestion from users I do update my studies even the oldest ones.
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, ...