dgtrd

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)
where,
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

Conclusion

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

Hence;
- 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).
Skript med en öppen källkod

I sann TradingView-anda har författaren till detta skript publicerat det som öppen källkod, så att handlare kan förstå och verifiera det. Skål för författaren! Du kan använda den gratis men återanvändning av den här koden i en publikation regleras av våra Ordningsregler. Du kan göra den till favorit för att använda den i ett diagram.

Vill du använda det här skriptet i ett diagram?

Kommentarer

thank you so much for quick answer!
200 coins
+3 Svara
dgtrd smartiesss
;-) Thank You @smartiesss
+1 Svara
Hi there @dgtrd
First, thanks for the great work !
I'd like some explanations on a config for stats :
"Long : Candle Direction as Confirmation : Short"
What does this mean and what is the effect behind the first checkbock before "long" and the one after "short" ?

Because the backtest stats are not the same at all if nothing is selected, or one selected or both selected !

Thanks !

Have a great day
Svara
dgtrd anaikem
thank you @anaikem,

by default the trade with backtest framework enabled will be triggered on the next candle open price

enabling "Long : Candle Direction as Confirmation : Short" or "Avoid Sudden Price Changes" options will execute the trade on the second candle after MaMA detects the signal
they are basically additional filterings
"Long : Candle Direction as Confirmation : Short" are 2 option for long and short. assume you are planning to enter long position on the next bar's open price, what if the next bar is bearish bar this option will ignore the trading (may not be good for all cases but it is worth to watch)

"Avoid Sudden Price Changes"- is to fillter out the cases when on the next bar the indicator generate the opposite signal comparing to the first bar - this is the case in the sideway markets and this option aims to avoid them

hope this clarifies a bit, i wil suggest to test them on the charts before putting in use
Svara
Im trying to plot the early warning and the confirmed signal
using this:

//warning labels
plotshape(longAlertCondition , style = shape.triangleup, color = color.blue, location = location.belowbar, size = size.small)
plotshape(shortAlertCondition, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)

//confirmed buy and sell labels
plotshape(longAlertCondition , style=shape.labelup, location=location.belowbar, color=color.green, size=size.tiny, title="Buy", text="Buy", textcolor=color.white)
plotshape(shortAlertCondition , style=shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny, title="Sell", text="sell", textcolor=color.white)

https://snipboard.io/d1X0NO.jpg

https://snipboard.io/rDEFJf.jpg

but im getting multiple false signal, compare to backtesting

bTW very good indicator. thanks so much. more power
Svara
dgtrd Aakifah
thnak you very much @Aakifah🙏

this study and my other studies where backtest framefork is applied have two types of signals.

1st type is pure related to the implemneted study, no filterin just simply related with MaMA (you used the conditions from this part of the study)

2nd type singals are the ones coming by combining the study and some filtering applied with the bactest framefork.

please check for further details here : https://www.tradingview.com/script/3twfvd3k-Elliott-Wave-Oscillator-Signals-by-DGT/#tc5938446
Svara
Aakifah dgtrd
@dgtrd, thanks so much. false signals sometimes smoothen buy heiken Ashi ..hoping next update will filter the false signals. Very good study .
Svara
dgtrd Aakifah
hello @Aakifah, thanks for the feedback and let me remind that the trade stats presented on the panel when backtest framework is enabled are not compatable with heikin ashi candles
Svara
Hi, looks great. When i apply it to the chart, I'm getting a different indicator than the one in the screenshoot. Are they different? Can you please explain?

Thanks in advance.
Svara
dgtrd Mufcruz
hello @Mufcruz, thnaks for your kind words

with the updates there was aditions have you tried to eable backtest framework feature
Svara