SPX Expected Move For ThinkOrSwim

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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 this
CSS:
#// 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
 
@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.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
267 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top