Returns Model by TenozenHey there! I've been diving into the book "Paul Wilmott on Quantitative Finance," and I stumbled upon this cool model for calculating and modeling returns. Basically, it helps us figure out how much a price has changed over a set number of periods—I like to use 20 periods as a default. Once we get that rate of change value, we crunch some numbers to find the standard deviation and mean using all the historical data we have. That's the foundation of this model.
Now, let's talk about how to use it. This model shows us how returns and price behavior are connected. When returns hang out in the +1 to +2 standard deviation range, it usually means returns are about to drop, and vice versa. Often, this leads to corresponding price moves. But here's the thing: sometimes prices don't do what we expect. Why? It's because there's another hidden factor at play—I like to call it "power."
This "power" isn't something we can see directly, but it's there. Basically, when returns are within that standard deviation range, the market faces resistance when trying to move in its preferred direction, whether bullish or bearish. The strength of this "power" determines if the market will snap back to the average or go for a wild ride. It can show up as small price wiggles, big price jumps, or lightningfast moves. By understanding this "power," we can get a better handle on what the market might do next and avoid getting blindsided. In the meantime, I couldn't explain "power" yet, but In the future, when I've learned enough, I'd love to share the model with you guys!
So... I'm planning to explore and share more models from this book as I learn, even if those pesky math formulas can be tough to crack. I hope you find this indicator as helpful as I do, and if you've got any suggestions or feedback, please feel free to share! Ciao!
Returns
YoY or MoM ReturnsThis script is a technical indicator that calculates the yearoveryear (YoY) or monthovermonth (MoM) returns of a security.
The returns are then plotted on a chart, with positive returns colored in green and negative returns colored in red.
Monthly ReturnsDisplays monthly and yearly returns in tabular format along with maximum, minimum, average returns and standard deviations.
This uses boxes to build the table and as maximum boxes that could be used is 500, it displays up to 32 years of returns. However, for maximum, minimum, average and standard deviation calculations, it uses data from all months since inception.
This requires timeframe to be set to one month (1M). Cell widths correspond to years. For the first year, cell widths may be shorter and there could be overlap of numbers as nothing could be drawn before the first bar.
Provide sufficient space for the table to render properly. Zooming out or less space may lead to overlapping of numbers.
Performance Tablethis scrip is modified of Performance Table () of TradingView user @BeeHolder = Thank u very much.

@BeeHolder formula is based on daily basis,
but my calculation is based on respective day, week and month.

The formula of the calculation is (Current Close  Previous Close) * 100 / Previous Close, where Past value is:
1D = close 1 day before
5D = close 5 day before
1W  close 1 week before
4W = close 4 week before
1M  close 1 month before
3M  close 3 month before
6M  close 6 month before
12M  close 12 month before
52W  close 52 week before
Also table position cane be set.
thank you all

Annual Returns % Comparison [By MUQWISHI]Overview
The Annual Returns % Comparison indicator aimed to compare the historical annual percentage change of any two symbols. The indicator output shows a columnplot that was developed by two using a pine script table, so each period has pair columns showing the yearly percentage change for entered symbols.
Features
 Enter date range.
 Fill up with any two symbols.
 Choose the output data whether adjusted or not.
 Change the location of the table plot
 Color columns by a symbol.
 Size the height and width of columns.
 Color background, border, and text.
 The tooltip of the column value appears once the cursor sets above the specific column. As it seen below.
Let me know if you have any questions.
Thanks.
ln(close/20 sma) adjusted for time (BTC)(This indicator was designed for the BTC index chart)
Designed for Bitcoin. Plots the log of the close/20W SMA with a linear offset m*t, where m is the gradient I've chosen and t is the candle index. Anything above 1 is a mania phase/market cycle top. If it peaks around 0.92 and rolls over, it could be a local/market cycle top.
This will obviously not work at all in the long term as Bitcoin will not continue following the trend line on the log plot (you can even see it start to deviate in the JanFeb 2021 peaks where the indicator went to 1.15).
It identifies the 2011, 2013 (both of them), 2017 tops as being just above 1. It also identifies the 2019 local peak and 2021 market cycle top at ~0.94.
Feel free to change the gradient or even add a function to curve the straight line eventually. I made this for fun, feel free to use it as you wish.
Yearly Percentage ReturnsAn indicator that lets you visualize the historical Yearly Percentage returns of any symbol .
Key Features:
Displays the yearly returns from start to end of each year
Displays a table showing all yearly returns for current symbol
Displays start of each year as a vertical line
Displays up to 5 custom horizontal levels
Table Settings:
Enable table  Show/Hide the table
Size  Sets the size of the table
Position  Sets the position of the table on the screen
Direction  Sets the direction of the table to display the data (Vertically or Horizontally)
One Year ReturnThis is a script meant for the weekly timeframe . It shows the change between the current close and the close 52 bars ago. I find that this data can be useful for deciding how long to stay in a trade, and for deciding how far a stock is likely to move in a year based on it's historical returns. The High average takes the sum of all positive returns and averages it using the number of bars where the data was positive, the low average does the same but with all the returns below zero. When both are turned on you will see a band between these values.
conditional_returnsThis script attempts to contextualize the instrument's latest return. It asks, "when a return of the same or greater magnitude occurred in the past, in the same direction, what was the following period's return?"
By default, the latest return is used. For example, on a daily chart, that would mean "today's" return. However, you can select any return you want using the "override" input.
The output table shows:
 The latest/override return, as a percentage. This is in the top left, fuchsia cell.
The first three, blue columns, show:
 The count of up and down (or positive and negative) next period returns. This shows you the sample size.
 The percentage of up/down next period returns.
 The average nextperiod return return, up and down, as percentages.
The next three, green columns show these same statistics, but for all returnsevery period in the active date range is used. This data serves as a basis for comparison.
Note that you can select a custom date range with the "start" and "end" inputs. The corresponding area on the chart is shaded light grey, to show which data is used in the computations.
Risk adjusted returns data (volatility optimised)RAR  risk adjusted returns. This methodology could be helpful in portfolio creation and position size risk management. We can set our own preference of risk tolerance via the X variable which is the exponent of volatility in our calculations. This gives an unlimited set of example portfolios on a given timeframe that can be sorted from return oriented to volatility reduction oriented as X increases. RARs are to be compared against eachother.
Rolling ReturnsWhat does this indicator show?
This indicator shows the rolling return of a set lookback period.
The default indicator value is 20 which will show the rolling 20day return because 20 trading days is 1 month.
Seasonality of ReturnsHi!
I want to share a simple script I built to analize the seasonality of Bitcoin and other assets.
So far it just displays the average return of each month, but I might add some more things later on.
The best timeframe to use it is the monthly timeframe it works on all timeframes but you need the full history for the average, and on weekly you will see issues cause weeks dont match months
On the dataview you can see the variance of each month, feel free to edit it at your own like
Mikel
[BCT] Can BTC be predicted or is it purely random?Variance Ratio**This indicator can be applied to the ticker of your choice (not just BTC)**
Markets are said to be "efficient". An efficient market is by definition unpredictable  no matter the amount of ML, computation, or indicators thrown at it. In particular, in an efficient market, TA will not be of help.
An illustration of efficient markets is the WSJ's longstanding monkey vs. human contest:Blindfolded Monkey Beats Humans With Stock Picks, granted there are several flaws to it.
BTC is a relatively new market. New markets are typically highly inefficient (easier to make money) and become more and more efficient over time (harder to make money). How much more efficient is BTC becoming?
We apply the Variance Ratio method and apply it to BTC.
BACKGROUND ON THE VARIANCE RATIO METHOD
Based on 1988 MacKinlay's seminal paper "Stock Market Prices do not Follow a Random Walk", the idea is to exploit a phenomenon called "variance scaling".
For those keen on looking into the math, the short version of it is under the assumption of iid (random walk) we have the following:
H0: Var(Sum(returns over K bars))=Sum(Var(returns over 1 bar))=k*Var(return over 1 bar)
We look to reject or not H0 depending on the observations.
In this script, we compare the variance of the (log) returns for the chart selected between:
(1) The (average) variance over k bars (call this Vk)
(2) The (average) variance over 1 bar (call this V1)
H0 simply says that Vk=k*V1 if the stock follows a random walk.
We compute the Variance Ratio VR(k)=Variance(returns over k bar)/(Sum(Var(returns over 1 bar)))1
We then compute the associated Zscore which we chart out for a configurable k number of bars.
HOW TO INTERPRET THE CHART
The line drawn is the ZScore for VR(k). It represents the number of standard deviations of VR(k) from 0  the further out, the less random.
 If the line is close / hovers around 0, the ticker appears to follow a random walk (i.e. may not be predictable)
 If the line is consistently > 2 or <2, the ticker likely does not follow a random walk (i.e. may have predictable features)
 If the line is positive, it means that the Variance on the k bars is larger than the variance on 1 bar (more variance on longer timeframes)
 If the line is negative, it means that the Variance on the k bars is smaller than the variance on 1 bar (more variance on smaller timeframes)
USE CASES
 Identify timeframes where you won't be able to make money
 Identify whether a stock cannot be predicted (forget about TA, indicators etc.  a random walk is not predictable)
 Identify whether a stock is becoming less and less predictable (Zscore amplitude will decrease over time)
FEATURES
 select the number of K bar to compare vs. 1 bar (default = 16)  ideally a power of 2 but any other number will work. The chart is based off this selection
 select the lookback period for the analysis (500 bars by default)
 select the source to analyze (default = close, but you may select other inputs to calculate the returns from)
 results form the statistical tests on different K's in the table on the right/bottom side of the chart (H0 rejected = not random walk; H0 not rejected = it essentially looks rather random and we can't conclude that it's not a random walk)
COMMENTARY ON BTC
 It appears BTC's absolute value of the ZScore on the Variance Ratio is declining year after year  corroborating an increasingly efficient market as new participants join.
 However, we can still detect a fair amount of potential inefficiency using this simple test.
As usual, this is not investment advice. DYOR.
With love,
🐵BCT🐵
Return by day of the weekBuy on Mondays sell on Tuesdays.
Just a simple tracking of returns.
It works only on the weekly charts
Return (Percent Change)This Script displays Regular or Log Returns as either a line or histogram and labels the current bar.
If something other than price is selected as the source, the result is percent change with a positive or negative slope.
If a moving average of price is used as the source, the result is analogous to a strength index
Other options include a lookback period adjustment (the default is 1),
smoothing results by converting to an EMA, and
Bollinger Bands with Length and Standard Deviation inputs.
KolmogorovSmirnov TestThe Kolmogorov–Smirnov test aims to tell you if the distribution of prices (or log returns) tends to follow a normal distribution or not. You can read about this test on Wikipedia . It seems to be a basic but trusted measure in the quantitative trading world.
When KSt columns are blue, then it's safe to assume normal distribution. When they are red, the normal distribution assumption is proven wrong by the magnitude of the KSt value.
In the plotting tab of the script, you can activate another option that displays the probability of the distribution being actually normal. It's values are bounded between 0 and 1, like all probabilities.
This test can be useful when using statistical concepts for trading markets, like standard deviations, zscores, etc because they all depend on the assumption of prices (or log returns) being normaly distributed.
If you see something wrong, don't hesitate to message me.
Happy trading to all.
Risk Metrics: beta 'β', correl 'ρxy', stdev 'σ', variance 'σ²'Portfolio Risk Metrics (Part I):
beta 'β'
The beta coefficient can be interpreted as follows:
β =1 exactly as volatile as the market
β >1 more volatile than the market
β <1>0 less volatile than the market
β =0 uncorrelated to the market
β <0 negatively correlated to the market
excerpt from the Corporate Finance Institute
correlation coefficient 'ρxy'
The correlation coefficient is a value that indicates the strength of the relationship between variables.
The coefficient can take any values from 1 to 1. The interpretations of the values are:
1: Perfect negative correlation. The variables tend to move in opposite directions
(i.e., when one variable increases, the other variable decreases).
0: No correlation. The variables do not have a relationship with each other.
1: Perfect positive correlation. The variables tend to move in the same direction
(i.e., when one variable increases, the other variable also increases).
excerpt from the Corporate Finance Institute
standard deviation 'σ'
68% of returns will fall within 1 standard deviation of the arithmetic mean
95% of returns will fall within 2 standard deviations of the arithmetic mean
99% of returns will fall within 3 standard deviations of the arithmetic mean
excerpt from Corporate Finance Institute
variance 'σ²'
In investing, variance is used to compare the relative performance of each asset in a portfolio.
Because the results can be difficult to analyze, standard deviation is often used instead of variance.
In either case, the goal for the investor is to improve asset allocation.
excerpt from Investopedia
Compound Value @ annual rateBy studying historical data we can know the compounded growth rate of an investment from the inception date. For example if we know that an investment has grown at the rate of 6% in the past and if we expect similar growth in the future also, We can plot this graph to understand whether the current price is underpriced or overpriced as per projected return.
In this graph, it takes the initial close price as a principle and rate from the input and calculates the compound amount at each interval.
Alpha Performance of PeriodAlpha Performance of Period (PoP) produces a visualization of returns (gains and losses) over a quarterly, monthly, or annual period. It also displays the total % gain and loss over any length of days, months, and years as defined by the user.
Performance of Period (PoP) can be used to understand the performance of an asset over multiple periods using a single chart layout, and to compare the performance of different assets by using a multichart layout.
This can, for example, be used to compare the NASDAQ, S&P, and DJI over the past 20 years to create a dow vs. nasdaq vs. s&p performance chart. This can help you understand a comparison of historical returns by showing which performs the best monthovermonth, quartertoquarter, yeartoyear, throughout any custom period of days/months/years.
The ability to get a visualization of the % gain/loss can help to better understand how markets have performed over time and which markets have historically performed the best.
Check out the up and coming Educational Idea we will be releasing soon after this is live to see an example of how we use this tool.
Current Period Label

Current Period : This label shows the current period's performance only when you hover over it.
(This label is located to the left of the current period's open candle and at the current candles close price)
TICKER "Time Period" Performance Label

Total Period Gain : The total of all % gain periods from the start to end date.
Largest Period Gain : The biggest % gain period from the start to end date.
Total Period Loss : The total of all % loss periods from the start to end date.
Largest Period Loss : The biggest % loss period from the start to end date.
Total period Performance : The total % performance, the difference between the total gain and total loss.
NOTE : The "Current Period" performance is excluded from ALL five of the abovementioned figures. This was done to avoid giving inaccurate comparison figures due to the period not being finished yet.
Inputs

Current Script Version + Info : A dropdown list of instructions for the user to refer to.
Dark Mode Labels : Toggle on for Dark Mode. This is done since Labels text and background color can not be adjusted separately within the visual inputs so this is the best fit solution.
Time Period of Returns : Pick the period of performance you would like to emulate monthly/quarterly/annual.
Start Date : The day to start tracking performance.
Start Month : The month to start tracking performance.
Start Year : The year to start tracking performance.
End Date : The day to stop tracking performance.
End Month : The month to stop tracking performance.
End Year : The year to stop tracking performance.
As always if you have any feedback let us know in the comments and leave a like if you enjoy this tool :)
Daily Returns & STDWhat happened last time when xx increased by xx%?  Start collecting some stats!
You can choose the ticker and the timeframe you're interested in