# Rate of Return (RoR) by DGT

2272浏览
A rate of return ( RoR ) is the net gain or loss of an investment over a specified time period, expressed as a percentage of the investment’s initial cost

This study measures monthly, annual and custom length of rate of return

In the previous version, annual and monthly calculations was suitable for crypto market and daily time frame only. Thanks to @spetry who find out the issue and warned me

now updated to cover other markets and will be shown for daily timeframe only

Custom length RoR will be calculated in all time frames for all markets.

Reminder: RoR provides identical figures with momentum indicator, only values expressed in percentage

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

observations of applying feedback effect :
-emphasis the sudden large price movements
-emphasis the probable reversal or corrections points of momentum
-emphasis stability periods - no affects observed during average prices movements (both direction), rate of return with feedback effect remain almost same as rate of return

Sensitivity can be adjusted with feedback factor provided as user argument, monthly and annual plotting does not benefit from feedback factor

mathematical expression and formulation of feedback effect
our formula of the rate of return is expressed as
rate-of-return = (current value - initial value) / initial value
alternatively, rate-of-return can be expressed by current value / initial value
In Pine,
rate-of-return = source / source(length)

Let’s apply a negative feedback as in electronic engineering concept, just it would be easy to consider the negative feedback in trading as brokerage commission or the effect of inflation over time which are not taken into consideration of simple rate of return calculation

rewriting the formula as:
rate-of-return * source(length) = source
adding negative feedback by subtracts a fraction of current source value from initial source value, we can express
rate-of-return * (source(length) - feedback-factor * source) = source
where feedback-factor is the feedback fraction (with this study value from 0 to 1)
rate-of-return * source(length) - feedback-factor * source * rate-of-return = source
rate-of-return * source(length) = source * ( 1 + feedback-factor * rate-of-return )

the rate-of-return with negative feedback effect becomes
rate-of-return-negative-feedback = source / source(length) = rate-of-return / ( 1 + feedback-factor * rate-of-return )

similarly, positive feedback is adding fraction of current source value to initial source value, which results as
rate-of-return-positive-feedback = rate-of-return / ( 1 - feedback * rate-of-return )

Disclaimer: The script is for informational and educational purposes only. Use of the script does not constitute professional and/or financial advice. You alone have 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

## 评论

it is such a good indicator that can predict abnormal price movement and take advantage to it, very useful and have great insight! Superb!!

smartiesss
thank You @smartiesss, i am so glad to hear this

I think you may want 21 bars for monthly and 252 for annual as those are the average number of trading days.

close goes back n number of bars, not n number of day.

spetry
Hello @spetry,
thanks for warning indeed. I was playing around with crypto on daily chart and completely skipped both of them.
appreciated a lot your valuable feedback, will update the study the soonest possible.
best regards

spetry
@spetry, thanks a lot again, I made an quick update and corrected the issue you have pointed

dgtrd
@dgtrd,
if timeframe.isdaily
if syminfo.type == "crypto" or syminfo.type == "bitcoin"
mLength := 30
yLength := 365

Don't forget to change these. And just wondering, why do you need daily, crypto, bitcoin factors here at all? I think really you're building a generic indicator that should work on any chart.

spetry
hi @spetry, yes exactly my aim is to have it generic and applicabale on all markets. cryto market is open 7/24 for trading so I kept mLength := 30 and yLength := 365 and assigned values as you suggested to mLength := 21 and yLength := 252 for non-crypto market

I have discovered that this indicator appears to be exactly the same with Momentum only values are displayed as percentage and have 3 lines indication annual, monthly and customizable setted line
So besides providing sight for return rate of gain or loss of an investment over a specified time period, the indicator will benefit from all the vision provided by Momentum Indicator

dgtrd
@dgtrd, Ahhhh...makes total sense! Nice one!

spetry