Prime Distance Frame Quant Model for Risk Reward & Pivot PointsIn this script we take all of the prime numbers up to 100 and plot them as olive lines and then consider the distance between two adjacent plots and color code these distances with the fill function. This allows us to find higher and lower prime gaps allowing us to make much more informed decisions on our risk reward for a given trade and the levels where we should consider taking profit.
The Script includes scaling for all assets and is intended to be used for crypto trading.
Models
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
Implied Volatility SuiteThis is an updated, more robust, and open source version of my 2 previous scripts : "Implied Volatility Rank & Model-Free IVR" and "IV Rank & IV Percentile".
This specific script provides you with 4 different types of volatility data: 1)Implied volatility, 2) Implied Volatility Rank, 3)Implied Volatility Percentile, 4)Skew Index.
1) Implied Volatility is the market's forecast of a likely movement, usually 1 standard deviation, in a securities price.
2) Implied Volatility Rank, ranks IV in relation to its high and low over a certain period of time. For example if over the past year IV had a high of 20% and a low of 10% and is currently 15%; the IV rank would be 50%, as 15 is 50% of the way between 10 & 20. IV Rank is mean reverting, meaning when IV Rank is high (green) it is assumed that future volatility will decrease; while if IV rank is low (red) it is assumed that future volatility will increase.
3) Implied Volatility Percentile ranks IV in relation to how many previous IV data points are less than the current value. For example if over the last 5 periods Implied volatility was 10%,12%,13%,14%,20%; and the current implied volatility is 15%, the IV percentile would be 80% as 4 out of the 5 previous IV values are below the current IV of 15%. IV Percentile is mean reverting, meaning when IV Percentile is high (green) it is assumed that future volatility will decrease; while if IV percentile is low (red) it is assumed that future volatility will increase. IV Percentile is more robust than IV Rank because, unlike IV Rank which only looks at the previous highs and lows, IV Percentile looks at all data points over the specified time period.
4)The skew index is an index I made that looks at volatility skew. Volatility Skew compares implied volatility of options with downside strikes versus upside strikes. If downside strikes have higher IV than upside strikes there is negative volatility skew. If upside strikes have higher IV than downside strikes then there is positive volatility skew. Typically, markets have a negative volatility skew, this has been the case since Black Monday in 1987. All negative skew means is that projected option contract prices tend to go down over time regardless of market conditions.
Additionally, this script provides two ways to calculate the 4 data types above: a)Model-Based and b)VixFix.
a) The Model-Based version calculates the four data types based on a model that projects future volatility. The reason that you would use this version is because it is what is most commonly used to calculate IV, IV Rank, IV Percentile, and Skew; and is closest to real world IV values. This version is what is referred to when people normally refer to IV. Additionally, the model version of IV, Rank, Percentile, and Skew are directionless.
b) The VixFix version calculates the four data types based on the VixFix calculation. The reason that you would use this version is because it is based on past price data as opposed to a model, and as such is more sensitive to price action. Additionally, because the VixFix is meant to replicate the VIX Index (except it can be applied to any asset) it, just like the real VIX, does have a directional element to it. Because of this, VixFix IV, Rank, and Percentile tend to increase as markets move down, and decrease as markets move up. VixFix skew, on the other hand, is directionless.
How to use this suite of tools:
1st. Pick the way you want your data calculated: either Model-Based or VixFix.
2nd. Input the various length parameters according to their labels:
If you're using the model-based version and are trading options input your time til expiry, including weekends and holidays. You can do so in terms of days, hours, and minutes. If you're using the model-based version but aren't trading options you can just use the default input of 365 days.
If you're using the VixFix version, input how many periods of data you want included in the calculation, this is labeled as "VixFix length". The default value used in this script is 252.
3rd. Finally, pick which data you want displayed from the dropdown menu: Implied Volatility, IV Rank, IV Percentile, or Volatility Skew Index.
Garch (1,1) ModelThe Garch (General Autoregressive Conditional Heteroskedasticity) model is a non-linear time series model that uses past data to forecast future variance.
The Garch (1,1) formula is:
Garch = (gamma * Long Run Variance) + (alpha * Squared Lagged Returns) + (beta * Lagged Variance)
The gamma, alpha, and beta values are all weights used in the Garch calculations. According to RiskMetrics by JP Morgan, the optimal beta weight is 0.94, but this figure is highly disputed in the academic realm. The biggest problem academics and economists have with the 0.94 figure is that JP Morgan used monthly data to come to this number, meaning it does not take other time frames into account. Because of the disputed nature of what beta should be, this script will automatically calculate the beta weight for you in real time, taking into account the time frame you're using and realized variance, by using the Minimum Sum of Squared Errors Method.
The gamma and alpha weights are also calculated for you.
Even though the Garch formula provides today's projected variance, today's projected deviation is also calculated. This is done by taking the square root of Garch.
Additionally, if you want to project the variance or deviation for as many days forward as you want, you can.
In order to project the variance and deviation beyond just today, these equations are used:
Projected Variance = Long Run Variance + (alpha + beta)^Days Forward * (Garch - Long Run Variance)
Projected Deviation = sqrt(Projected Variance)
How to use this model:
1st. Decide the type of data you want: Projected Variance in % or Projected Deviation in %.
2nd. Decide how many days you want projected forward. If you input 0, you will get projections for today. If you input 1, you will get projections for tomorrow, and etc.
That's it. If you have any further questions, I left detailed comments in the code explaining each step, as best as I could.
COVID Statistics Tracker & Model Projections by Cryptorhythms😷 COVID-19 Coronavirus Tracker & Statistics Tools by Cryptorhythms 😷
📜Intro
I wanted to put some more meaning behind the numbers for 2020's Covid pandemic. I hope this tool can help people analyze and deal with these hard times. With these metrics I hope to give greater depth and dimension to whats available. While also at the same time creating something that looks decently presentable and gives actionable information.
I had planned on including a few forecasting models and letting the user play with values to see how social distancing works. But alas I couldnt complete those in the scope of time I gave myself for the indicator. If you are interested in collaborating on it, I will share what I have with you and we can further work on it.
📋Description
The script contains 3 main parts you will interact with. I suggest you enable the chart labels for "indicator name" and "indicator last value" to make the charts more readable (right click on the scale of your chart and goto the "labels" pop out menu). Depending on what plots and data you choose to chart, logarithmic and regular scales can both be applied in different situations. To get similar visuals to the examples I will show below, you can goto the indicator options > style tab. I then play with the line styles, colors and transparencies to achieve the nice looking charts. Please also note there is a distinction between "Infected" and "Infectious". A model telling you the number of infected doesnt designate whether that person can still pass the virus on to others (infectious). So Infectious numbers are usually lower than total confirmed, but this isnt always the case if for example a country wasnt testing very much during the early phase or something else.
🚧Disclaimer
I am not a medical professional and none of this should be considered medical advice. All of the models, numbers and math I sourced from professional places but this is not a guarantee of the future only an approximation based on current information. Numbers change daily and so can these models!
🌐PART ONE
In this area you select a region to read the proper statistics data from tradingview. You can do global totals, country totals, or for a few places (AU, CA, CN, US) you can see state/province totals. Remember to SELECT ONLY ONE region.
🧮PART TWO
The Plots/Stats/Data section includes:
1. ) Plot the Days to Double Number of Confirmed
2. ) Plot the Infection Growth Ratio
3. ) Plot Fatality Risk Rate (Total Deaths / Total Outcomes)
4. ) Plot Overall Fatality Rate / Recovery Rate
5. ) Plot % of World Infected & % of USA Infected
6. ) Plot Daily New Deaths, Confirmed & Recovered
7. ) Plot Daily Change Percentages
🎱PART THREE
Forecasting Models and Settings:
1 .) Plot the % of Custom Population Infected (Vs. the Region Selected in Part 1 of Settings)
2 .) Plot the True Num. of Infectious (Death Model / DM)
3 .) Plot the Current and Next Weeks Cumulative Infection Projection (DM)
4 .) Plot Estimated Infection Rates? (DM)
5 .) Enable Basic Trajectory Projection?
6 .) Plot the Likelihood of > 0 **Infectious** in a Group (DM) for Today, Tomorrow and Next Week
7 .) Plot the True Num. of Infected (Confirmed/Tested Model)
8 .) Plot the Estimated Epidemiology for 7 and 14 Days Out (Hospital Beds, ICU Beds, Ventilator Units)
Planned But not completed
9.) SIR Epidemiology Model
10.) Exponential Growth Plot & Correlation
To use the Estimator for likelihood of Infected in N group of people you need to do 2 things. Select and use "Custom Population" as the population source for part 3. Then you need to enable "Custom Infected" as the source for the model. Then you enter your geographical area's population and confirmed cases. Its best to goto the smallest / most granular level of data available to accurately estimate the likelihood. So for instance in the order of least effective to most effective data source: global, country, state, county, city...etc.
If you do not understand what these terms or numbers represent, please read the source materials I have linked in the code, or use google. I dont have the time or expertise to explain all the various specific methods and terms included here. This entire project was a learning journey for me and I have zero experience in epidemiology so please excuse any errors I may have made. (and tell me, so I can change it!)
🔮Future Additions
If anyone has a model or stat they would like included I will be happy to add your code to this toolbox to make it more effective and give you credit here in the description. If you want to collaborate please message me.
📊Some Example Charts:
The Cryptorhythms Team wish you and your families all the absolute best of health!
P.S. Stay safe and act smart I dont think this will be the EOTW.