Favor to request. If someone can help with converting this https://www.tradingview.com/script/kvk4QGap-SPX-Expected-Move/ to a thinkscript that would be of great help. Thank you.
try thisFavor to request. If someone can help with converting this https://www.tradingview.com/script/kvk4QGap-SPX-Expected-Move/ to a thinkscript that would be of great help. Thank you.
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © robertsullivan1956
#indicator("SPX Expected Move by:", overlay=true)
# Converted and mod by by Sam4Cok@Samer800 - 03/2023
input volSymbol = {"VIX", "VIX9D", "VIXMO", "VIX3M", "VIX6M", "VIXY", "VIIX.IV", "UVXY", default "VOLI"};#("VOLI", "VOL Symbol", ])
input UseCustomTimeframe = no;
input CustomTimeframe = AggregationPeriod.FIVE_MIN;
input CalcMethod = {Default "Trading days in one year","Trading days in current year"};
input displayShading = yes; # "Display color between 1 STD and 2 STD?"
def na = Double.NaN;
def year = CalcMethod==CalcMethod."Trading days in one year";
def current = GetAggregationPeriod();
def tf = if UseCustomTimeframe then CustomTimeframe else current;
def volValue = open(volSymbol, Period = tf);
def minute =(RegularTradingEnd(GetYYYYMMDD()) - GetTime()) / AggregationPeriod.DAY;
def yearstart = if year then GetYYYYMMDD() - 10000 else GetYEAR() * 10000 + 101;
def tradingDaysInYear = CountTradingDays(yearstart, GetYYYYMMDD());
#// first calculate the fraction of the trading day remaining.
def frac = minute;
def timeRemaining = sqrt(frac) / sqrt(tradingDaysInYear);
def sd = close * (volValue/100) * timeRemaining;
def sd2Above = close + sd;
def sd1Above = close + (sd/2);
def sd2Below = close - sd;
def sd1Below = close - (sd/2);
plot p1 = sd1Above;#, "1SD Above"
plot p2 = sd2Above;#, "2SD Above"
plot p3 = sd1Below;#, "1SD Below"
plot p4 = sd2Below;#, "2SD Below"
p1.SetDefaultColor(Color.DARK_GREEN);
p2.SetDefaultColor(Color.DARK_GREEN);
p3.SetDefaultColor(Color.DARK_RED);
p4.SetDefaultColor(Color.DARK_RED);
AddCloud(if displayShading then p2 else na, p1, Color.DARK_GREEN);
AddCloud(if displayShading then p3 else na, p4, Color.DARK_RED);
#--- END CODE
Awesome. Do you have a script for ToS where the site you posted for the divergence it was showing at the bottom of the chart for SPX?
@tosalerts6247 Did you ever get a script to get what you requested here done?@samer800 thanks a lot for the script, is it possible to have the expected move plotted by the timeframe chosen as horizontal lines rather than the cloud as it becomes hard to interpret the levels of the expected move. For example if the timeframe in the calc method is chosen to 1 hour then can we plot 1 hour expected movement upside and downside with horizontal lines along with its ST deviations that will be really helpful to play iron condors within that range. Would highly appreciate if this is possible. thanks in advance.
no@tosalerts6247 Did you ever get a script to get what you requested here done?
Have you come across anything similar ? Perhaps we can bump the mods to look into this possibility.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.