Bank Nifty strike price 2/3σ Calculates the strike prices for the Bank Nifty index in steps of 50 and marks the 2 and 3 sigma price levels.
Options
vol_bracketThis simple script shows an "N" standard deviation volatility bracket, anchored at the opening price of the current month, week, or quarter. This anchor is meant to coincide roughly with the expiration of options issued at the same interval. You can choose between a manually-entered IV or the hv30 volatility model.
Unlike my previous scripts, which all show the volatility bracket as a rolling figure, the anchor helps to visualize the volatility estimate in relation to price as it ranges over the (approximate) lifetime of a single, real contract.
portfolio_strikesA simple script for keeping track of your options portfolio. Basically, you can write one line of code per strategy (single, vertical, or strangle) to keep a line drawn on the underlying's chart, at the strike price, from the current bar until expiration. See the comments at the top of the code for more explanation.
Binary Option Strategy Tester with MartingaleIn Binary options, strategy testing is a bit different. The script is just a try to test Binary options strategies.
Assumption:
We are opening position at next candle after signal come
We are taking the position at opening price
Our call will be profitable if we get a green candle and put will be profitable if we get a red candle
We can open only one trade at a time. So if we are in trade, subsequent signals will be ignored.
The script is not counting your profit or loss, it just counting the winning and losing trades.
Input Options:
Choose long only or short only test. Default is both.
You can continue your trade with Martingale Level, up to 5. Default is 1 (no Martingale)
You can choose Martingale trade type
SAME: if call subsequent trade will be call only and vice versa
OPPOSITE: if call subsequent trade will be put
FOLLOW CANDLE COLOR: Subsequent trade will follow previous candle color
OPPOSITE CANDLE COLOR: Subsequent trade will opposite of previous candle color
You can choose trading session to test. Default is false.
The strategy is taken from Vdub Binary Options SniperVX v1 (by @vdubus) . I have deleted extra parts and kept only the necessary part.
Without Martingale
Result Table
With Martingale
I am very new to Pine script, so waiting for your comments and review.
pricing_tableThis script helps you evaluate the fair value of an option. It poses the question "if I bought or sold an option under these circumstances in the past, would it have expired in the money, or worthless? What would be its expected value, at expiration, if I opened a position at N standard deviations, given the volatility forecast, with M days to expiration at the close of every previous trading day?"
The default (and only) "hv" volatility forecast is based on the assumption that today's volatility will hold for the next M days.
To use this script, only one step is mandatory. You must first select days to expiration. The script will not do anything until this value is changed from the default (-1). These should be CALENDAR days. The script will convert to these to business days for forecasting and valuation, as trading in most contracts occurs over ~250 business days per year.
Adjust any other variables as desired:
model: the volatility forecasting model
window: the number of periods for a lagged model (e.g. hv)
filter: a filter to remove forecasts from the sample
filter type: "none" (do not use the filter), "less than" (keep forecasts when filter < volatility), "greater than" (keep forecasts when filter > volatility)
filter value: a whole number percentage. see example below
discount rate: to discount the expected value to present value
precision: number of decimals in output
trim outliers: omit upper N % of (generally itm) contracts
The theoretical values are based on history. For example, suppose days to expiration is 30. On every bar, the 30 days ago N deviation forecast value is compared to the present price. If the price is above the forecast value, the contract has expired in the money; otherwise, it has expired worthless. The theoretical value is the average of every such sample. The itm probabilities are calculated the same way.
The default (and only) volatility model is a 20 period EWMA derived historical (realized) volatility. Feel free to extend the script by adding your own.
The filter parameters can be used to remove some forecasts from the sample.
Example A:
filter:
filter type: none
filter value:
Default: the filter is not used; all forecasts are included in the the sample.
Example B:
filter: model
filter type: less than
filter value: 50
If the model is "hv", this will remove all forecasts when the historical volatility is greater than fifty.
Example C:
filter: rank
filter type: greater than
filter value: 75
If the model volatility is in the top 25% of the previous year's range, the forecast will be included in the sample apart from "model" there are some common volatility indexes to choose from, such as Nasdaq (VXN), crude oil (OVX), emerging markets (VXFXI), S&P; (VIX) etc.
Refer to the middle-right table to see the current forecast value, its rank among the last 252 days, and the number of business days until
expiration.
NOTE: This script is meant for the daily chart only.
vertical_pricer
USAGE
1. Select the type of contract (call or put), the long strike, and the width.
2. Select the volatility model
3. The standard deviation is shown, enter it into the input.
The tool gives a theoretical price of a vertical spread, based on a
historical sample. The test assumes that a spread of equal width was sold on
every prior trading day at the given standard deviation, based on the
volatility model and duration of the contract. For example, if the 20 dte
110 strike is presently two standard deviations based on the 30 period
historical volatility, then the theoretical value is the average price all
2SD (at 20 dte) calls upon expiration, limited by the width of the spread and
normalized according to the present value of the underlying.
Other statistics include:
- The number of spreads in the sample, and percentage expired itm
- The median value at expiration
- The Nth percentile value of spreads at expiration
- The number of spreads that expired at max loss
Check the script comments and release notes for further updates, since Tradingview doesn't allow me to edit this description.
strangle_pricerUsage:
1. Set the put and call strike inputs to values of your choosing.
2. Select "days to expiration".
3. Set the put and call standard deviations using the output table.
The indicator is meant help price a strangle using historical data and a volatility model. By default, the model is an ewma-method historical volatility. After selecting strikes and standard their corresponding standard deviation, theoretical values and probabilities will be shown in the table. The script is initialized with -1 for several inputs, and won't show any data until these are adjusted.
The theoretical values shown assume a strangle was bought or sold on every historical bar, and averaging their value at expiration.
For example, if you choose the $50 call and $40 put when the underlying is at $45 and there are 30 days until expiration, suppose the volatility is N and
these strikes correspond to M standard deviations. Input those and the resulting theoretial values shown will be based on opening a 30 dte call and put at M standard deviations with respect to the volatility at each bar.
- Past volatility forecasts are plotted in blue, and hidden by default.
- The current volatility forecast is drawn as a blue line.
- The put and call strikes are drawn as red lines.
This indicator is only meant for the daily chart!
Since I won't be able to edit this description later, also check the release notes and script comments for important changes.
Weekly Options Expiry CandleThis script shows weekly expiry candle on daily chart. In weekly expiry, week starts on Friday and end on next Thursday.
How the candle is constructed:
Open= Open price of Friday, if Friday is a holiday, next available open price
High= Highest high price of Friday, Monday, Tuesday, Wednesday, Thursday
Low= Lowest low price of Friday, Monday, Tuesday, Wednesday, Thursday
Close=Close price of Thursday, if Thursday is a holiday, previously available close price
I am very new to Pine script, so waiting for your comments and review.
vol_rangesThis script shows three measures of volatility:
historical (hv): realized volatility of the recent past
median (mv): a long run average of realized volatility
implied (iv): a user-defined volatility
Historical and median volatility are based on the EWMA, rather than standard deviation, method of calculating volatility. Since Tradingview's built in ema function uses a window, the "window" parameter determines how much historical data is used to calculate these volatility measures. E.g. 30 on a daily chart means the previous 30 days.
The plots above and below historical candles show past projections based on these measures. The "periods to expiration" dictates how far the projection extends. At 30 periods to expiration (default), the plot will indicate the one standard deviation range from 30 periods ago. This is calculated by multiplying the volatility measure by the square root of time. For example, if the historical volatility (hv) was 20% and the window is 30, then the plot is drawn over: close * 1.2 * sqrt(30/252).
At the most recent candle, this same calculation is simply drawn as a line projecting into the future.
This script is intended to be used with a particular options contract in mind. For example, if the option expires in 15 days and has an implied volatility of 25%, choose 15 for the window and 25 for the implied volatility options. The ranges drawn will reflect the two standard deviation range both in the future (lines) and at any point in the past (plots) for HV (blue), MV (red), and IV (grey).
Trade Vertex - Bank Nifty Volume IndicatorNSE:BANKNIFTY
We all know that the value of an Bank Nifty is derived from top banking sector underlying stocks.
The value of Bank Nifty is calculated from free float market capitalization.
Using the same formula, I made an indicator on the bases of weighted volume of each stock.
This indicator will help you to plot Volume on Bank Nifty.
Intrangle - Straddle / StrangleIntrangle is an indicator to assist Nifty / Bank Nifty Option Writers / Sellers to identify the PE / CE legs to Sell for Straddle and Strangle positions for Intraday.
Basic Idea : (My Conclusion for making this Indicator)
1) Last 10 Years data says Nifty / Bank Nifty More than 66% of times Index are sideways or rangebound (within 1% day) .
2) Mostly, First one hour high and low working as good support and resistance.
Once First one hour complete, this indicator will show Strangle High (CE), Strangle Low (PE) and Straddle (CE/PE).
Straddle:
If you want to do straddle strategy, sell at the money strike (CE/PE) when price comes near to the straddle line (black line),
Strangle:
If you want to do Strangle strategy, sell Strangle High (CE) and Strangle Low (PE) when price comes near to the straddle line (black line). Both Strangle High and Low will be out of the money when price near to the straddle line (black line).
Adjustment: option adjustment to be done based on the price movement. Adjustment purely up to the user / trader.
Note1: If price not comes to near straddle line after first hour, better to stay light…
Note2: If first hour not giving wide High / Low, don’t use strangle strike based on this indicator. Straddle can be done any day with require adjustment / hedge. This Indicator is purely for education purpose, user / trader has to be back-tested before their start using it.
This indicator will work in Nifty / Bank Nifty only. Best Time frames are 3/5/15 Mins. This is purely made for Intraday
Happy Trading 😊
Last Friday of MonthThis script marks the last Friday of the month in a daily chart because this is the day when BTC and ETH options expire according to Deribit.
I only found a script that highlights the 3rd Friday of the month, which is not what I wanted.
This script tries to figure out the correct number of days per month but is not aware of holidays which might displace the expiry date.
OptionsMillionaire SPY Moving Averages and Signalsby ColeJustice
OptionsMillionaire's SPY Options trading system is based mainly on these indicators:
- 8 EMA*
- 21 EMA*
- 100 SMA*
- 200 SMA*
- MACD
- RSI
- Squeeze Momentum
(*provided by this indicator)
and follows these rules:
|
| 1) I never fight the trend. If its green, i buy calls. If its red, i buy puts. I will only buy puts on a green day if there is a overall change in market trend. Inversely, calls on a red day
| 2) Price action is my #1 indicator. I wait for it to confirm my thesis before i enter a trade
| 3) I only trade SPY Options
| 4) My baseline is to choose a call/put that has a DTE (Date To Expiration) 6-7 days out, with a strike $2-$3 away. I adjust that to fit my current appetite for volatility. i virtually never play same day DTE's.
| 5) I set a 10% stop, but usually exit at 8% before my stop triggers depending on current situation
| 6) I utilize about 10-20% of my Portfolio for one trade. Sometimes more. Rarely less.
| 7) I never hold overnight in these market conditions.
| 8) I shoot for 10-20% for gains. Depending on market conditions.
| 9) Always look for confirmations in your indicators.
| 10) I never force a trade. No trade is a good trade too if the entry just isn't there.
| 11) Patience always pays off. A great set-up can form in minutes or seconds. I never regret being patient to enter. I nearly always regret rushing into a trade.
|
This indicator combines the moving averages into a single unit to simplify one part of the indicator usage rules: the 8 EMA / 21 EMA Cross. . The 8 crossing over the 21 is a Bullish signal, while the 8 crossing under the 21 is a Bearish signal. This indicator places flags at these crossover/under points, as well as shading the area between the 8 and 21 EMAs to help visualize the strength of the trend; green during a Bullish cross, and red during a Bearish cross.
A new addition to this strategy is the Hull Moving Average, or HMA. This script defaults to an HMA of 20 and shows alerts when candles close above or below the plot in the form of green and red candle backgrounds. This alert is best used in conjunction with the main crossovers and should be considered an addition level of confidence rather than providing trade entry/exits directly. This indicator is more flexible and you should feel free to adjust the period if you find a different value works better within your own personal trading style.
Each individual element of this indicator can be modified or toggled, providing maximum customization. While you should strive to become comfortable with the default settings, these options are provided in case you feel the need to adjust for your own style (or if testing on tickers other than SPY, for example).
Goodluch, and happy trading!
wEMPlotDescription:
Plots the Weekly Expected Move (wEM) using the following week's Option Chain ATM Call+Put ask price to determine the EM for the following week
The wEM is the options market pricing in the expected future volatility for the following week.
The wEM is the range that the underlying price will be contained during the week 68% of the time.
These levels can be used as targets for options or equity trades for either directional or non-directional trades.
The options market in the major indices, such as SPX, can drive the overall market's order flow and so the EM can provide
useful insight into the hedging levels being used by professionals and market markers.
As Trading View does not currently provide access to option chain data, the option chain expected move for an underlying has to be manually
entered each week, but the script provides an easy to use framework to enter the parameters for the next week.
These parameters are as follows:
eg.
t1_1 = timestamp(2021, 02, 08) <==== timestamp for the start of next week (yyyy,mm,dd)
t1_2 = timestamp(2021, 02, 12) <==== timestamp for the end of next week (yyyy,mm,dd)
plotwem("QQQ", 331.36, 5.86, t1_1, t1_2, 0, 0)
^^^^
plotwem(Symbol, Close-last-week, Expected Move next week, Next week start timestamp, Next week end timestamp, Highlight-Upper-EM, Highlight-Lower-EM)
Parameters are:
Symbol : Underlying chart symbol (aka ticker). Can be a symbol for equity, future or index.
Close-last-week: Closing price at the end of last week.
Expected Move next week: The Expected Move for next week: Calculated from next week's Option Chain ATM Call+Put ask price
Next week start timestamp : Timestamp for the start of next week
Next week end timestamp : Timestamp for the end of next week
Highlight-Upper-EM : highlight upper expected move level. Set to 1 to highlight with red color. Set to 0 is no highlight.
Highlight-Lower-EM : highlight lower expected move level. Set to 1 to highlight with red color. Set to 0 is no highlight.
The highlight parameters can be updated at any point to indicate that the underlying has either touched the EM level or breached the level.
The highlights can be used to visually determine periods of market instability which can provide insight into applicable strategies for the market conditions.
Put Call OscillatorThis is a volume-based oscillator used for detecting market sentiment.
This plots two moving averages of the CBOE S&P500 PCR (put call ratio), and a histogram to measure the distance between them. The histogram will generate signals of green (bullish) or red (bearish), depending on whether put volume is decreasing or increasing.
The moving averages are adjustable. They are set at 4 and 16 by default. Increasing the moving averages will generate less signals, while decreasing them will generate more signals.
The background will change color from red to green depending on whether the PCR is above or below 1.
I used capriole_charles script "Put/Call Ratio (PCR)" to help me build this.
Doms 0dte/hassan conversion v2 Hello Guys
This is a reupload!
The 0dte is for options trading and is used for the main 1 to 0 odte strategy!
It uses volume, sector and tik analysis in order to give an understanding of looking which way to play.
The next version will look at correlations between the es! Feel free to point out bugs and reach out as I want this to grow into something way stronger!
Monthly Options Expiration 2021Monthly options expiration for the year 2021.
Also you can set a flag X no. of days before the expiration date. I use it at as marker to take off existing positions in expiration week or roll to next expiration date or to place new trades.
Happy new year 2021 in advance and all the best traders.
Swing Reversal IndicatorSwing Reversal Indicator was meant to help identify pivot points on the chart which indicate momentum to buy and sell. The indicator uses 3 main questions to help plot the points:
Criteria
Did price take out yesterday's high or low?
Is today's range bigger than yesterday? (Indicates activity in price)
Is the close in the upper/lower portion of the candle? Thus, indicating momentum in that direction
This indicator was built to help me find pivot points for directional options trading however can be used for equities and forex swing trading and other strategies. Used in conjunction with a BB extreme can provide good setups.
Alerts are available for both the long and the short positions and the indicator will repaint as price moves.
The character Plotted can be changed in the settings
The size of the candle area can be changed as well if you want to tighten/loosen the trigger points based on the third question above.
Implied Volatility PercentileThis script calculates the Implied Volatility (IV) based on the daily returns of price using a standard deviation. It then annualizes the 30 day average to create the historical Implied Volatility. This indicator is intended to measure the IV for options traders but could also provide information for equities traders to show how price is extended in the expected price range based on the historical volatility.
The IV Rank (Green line) is then calculated by looking at the high and low volatility over the number of days back specified in the input parameter, default is 252 (trading days in 1 year) and then calculating the rank of the current IV compared to the High and Low. This is not as reliable as the IV Percentile as the and extreme high or low could have a side effect on the ranking but it is included for those that want to use.
The IV Percentile is calculated by counting the number of days below the current IV, then returns this as a % of the days back in the input
You can adjust the number of days back to check the IV Rank & IV Percentile if you are not wanting to look back a whole year.
This will only work on Daily or higher timeframe charts.
Trendy Bar Trend Color LiteLite version of the original Trendy Bar Trend Color
This will only color the candlestick body of your chart
Can be used with solid, hollow, renko, or any other chart type
Custom coloring for Highs, Lows, and consolidation is removed
Black Scholes Model [racer8]This is the Black Scholes Model. This indicator tells you the prices of both a call option & a put option.
Input variables are spot price, strike price, risk free rate %, days to maturity, and implied volatility %.
This indicator was made generally for educational purposes.
By using this indicator, you will develop a better understanding of how options are priced.
This indicator was made to be as simple as possible so that the user can easily understand it.
I recreated the Black Scholes Model because there is very little scripts on TV that are based on the Black Scholes Model.
I am aware that are Black Scholes Model (BSM) scripts already on TV, but mine is not the same. Correct me if I'm wrong, but I don't think there is a BSM script out there yet that relies on the exact same inputs that mine does.
Why use this indicator?
If you don't already have your own IV indicator...
You can use this indicator to approximate the value of implied volatility %.
You already know every input variable except IV%, and you know the call & put option prices.
So put in the numbers for each input and put a random number between 0 to 100 into the IV% input to get the options prices.
Adjust that random number for IV% until the output (options prices) matches correctly with what you already know they are to be.
This is called the trial and error method.
On the other hand, if you already know all input variables including IV%. Then you can use this indicator to find the call & put options prices directly.
Hope this helps. Enjoy 🙂
FOMO DRIVEN DEVELOPMENT OPTIONS RETICLE Options Reticle caters to degenerate traders and gamblers worldwide, reaching out for long distant contract expiration and just OTM strike placement.
Generate the overlay yourself using the tradingview-options-reticle CLI tool found on GitHub.
The Options Reticle provides a targeting system overlay that will show a horizontal OTM strike price and verticle expiration target. If you're thinking as soon as the expiration date has passed, this overlay will be useless; you're right but, you can use the options-reticle CLI tool to generate a new overlay from a watchlist exported from TradingView.
OVERLAY FEATURES:
Quick Action PUT (QAP) Mode - When you flip the chart by adding a 0- in front of the symbol, you will see the PUT contract target. Strike Price / Expiration Crosshairs.
Fill Mode - Shows a fill between the historical price and the target strike price. It will show green when ITM and red when OTM. Target information panel - Shows the company name, days till expiration, month and day of expiration, strike price, dollars OTM or ITM, and the contract type.
Emotion Indicator - Shows an exact representation of your feelings based on if you were in the trade. It has an accuracy of 99.9 percent.
QUICK ACTION PUT (QAP) MODE :
This style of reticle is not visible until you flip the chart. The advantage of the (QAP) is that it maintains the same appearance as the standard style of reticle, making PUT contract targeting feel the same. When targeting with (QAP) mode, be aware that the chart prices are reversed. Up is down, and down is up; this can be confusing but will feel normal overtime. Activate QAP mode by appending a 0- to the symbol of the chart. If nothing appears, no put option data was found for that symbol.
CALIBRATING YOUR RETICLE :
The overlay is generated using the options-reticle CLI tool found on GitHub. The adjustment script will parse a watchlist exported from TradingView then download options data for each ticker in the watchlist. The max amount of symbols you can add to a single overlay is about 200. Any more than 200 and the overlay will crash. Luckily, If you use a TradingView watchlist with more than 200 ticker symbols to generate overlays, the options-reticle command-line tool will automatically create multiple overlays with 200 tickers each. You can add multiple overlays to your chart to get all the tickers in the watchlist.
RETICLE GENERATION AND MOUNTING :
Add all the tickers you want to track into a watchlist on Tradingview.
Export the watchlist into a txt file using TradingView's watchlist export list button.
Open the terminal and change to the directory with the downloaded watchlist txt file.
Install options-reticle command tool with pipx. pipx install tradingview-options-reticle.
Run the command options-reticle download --watchlist {name of watchlist.txt file}. This will download the options data to an options_data.toml in the same directory as the watchlist txt file.
Run the command options-reticle build --options-data-input-path options_data.toml. This will generate the overlay scripts. If the watch list has more than 200 ticker symbols, it will generate a separate overlay script for every 200 ticker symbol chunk.
Copy and paste each of the generated overlay scripts one at a time into the Pine Editor on TradingView, then click the Add to Chart button. Make sure you copy the entire code.
FUTURE FEATURES :
Give the choice to generate PUT option contracts without using QAP mode. This option will allow you to use the input settings to change the contract type without flipping the chart.
Max OTM target argument - This will allow the option-reticle CLI to generate overlays with deeper OTM contracts. It currently only searches for the first OTM contract.
Add the ability to change the crosshair line type.
Realized Variables for Options ComparisonThese variables can be used in comparison with the implied volatility of options.
Variables:
Realized Volatility
mathematical notation lowercase 'sigma'
Realized Variance
mathematical notation lowercase 'sigma' squared
Realized Beta
mathematical notation lowercase 'beta'
Timeframes:
Yearly = 250 or 365
Quarterly = 50 or 90
Monthly = 20 or 30
Important Note:
Options Contract Expiry = barmerge.lookahead_on
"Merge strategy for the requested data position. Requested barset is merged with current barset in the order of sorting bars by their opening time. This merge strategy can lead to undesirable effect of getting data from "future" on calculation on history. This is unacceptable in backtesting strategies, but can be useful in indicators."
[ All other timeframes barmerge.lookahead is disabled.