Average True Range (ATR) Implied Move for ThinkorSwim

David45

Active member
2019 Donor
New study by Mobius. What do you all think?

oiytTnU.png


Code:
# These attributions and study notes are part of the study code.
# Average True Range Implied Move
# Mobius
# V01.08.22.2020
# Notes: Chart data must be intraday. Extended Hours must be turned on. Chart data must include the data needed to calculate the highest Average True Range (10 days of data to calculate a 10 day Average True Range). For lower aggregations (5 minute and less) Settings > Price Axis > Fit Studies may need to be checked yes to show ATR Daily limit lines. If using on a thinly traded equity there may not be a trade at the RTH open and the Daily Implied Move may not plot for that day.
# Study Limitation: Average True Range is an average of the averaged bars range. Tying that average to any fixed point on a bar makes the erroneous assumption that the range is equal distance from that point. This study divides ATR in half and plots half above and half below the open of whatever aggregation period the user inputs. In order to keep chart clutter at a minimum the study plot only the most recent range. If the expansion area is set wide enough for the next period open to display then lines will begin plotting in the expansion area instead of at the current price bar.

input ATRlength = 10;
input Agg_1 = AggregationPeriod.Day;
input Agg_2 = AggregationPeriod.hour;

def o = open;
def h = high;
def l = low;
def c = close;
def o_1 = open(period = Agg_1);
def h_1 = high(period = Agg_1);
def l_1 = low(period = Agg_1);
def c_1 = close(period = Agg_1);
def o_2 = open(period = Agg_2);
def h_2 = high(period = Agg_2);
def l_2 = low(period = Agg_2);
def c_2 = close(period = Agg_2);
def x = barNumber();
def nan = double.nan;
def ts = TickSize();
def ATR_1 = Average(TrueRange(h_1[1], c_1[1], l_1[1]), ATRlength);
def ATR_2 = Average(TrueRange(h_2[1], c_2[1], l_2[1]), ATRlength);
def RTHo = getTime() crosses above RegularTradingStart(getYYYYMMDD());
def Y1 = if RTHo
         then o
         else Y1[1];
def x1 = if RTHo
         then x
         else x1[1];
def a1 = if RTHo
         then round((ATR_1 / 2) / ts, 0) * ts
         else a1[1];
plot RTHopen = if x >= highestAll(x1)
               then highestAll(if isNaN(c[1])
                                then Y1
                                else nan)
               else nan;
     RTHopen.SetStyle(Curve.Long_Dash);
     RTHopen.SetLineWeight(3);
     RTHopen.SetDefaultColor(Color.Yellow);
     RTHopen.HideTitle();
plot Dh = RTHopen + a1;
     Dh.SetStyle(Curve.Short_Dash);
     Dh.SetLineWeight(2);
     Dh.SetDefaultColor(Color.Green);
     Dh.HideTitle();
plot Dl = RTHopen - a1;
     Dl.SetStyle(Curve.Short_Dash);
     Dl.SetLineWeight(2);
     Dl.SetDefaultColor(Color.Red);
     Dl.HideTitle();
def Y2 = if getTime() % Agg_2 == 0
         then o_2
         else Y2[1];
def x2 = if o == o_2 and getTime() % Agg_2 == 0
         then x
         else x2[1];
def a2 = if getTime() % Agg_2 == 0
         then round((ATR_2 / 2) / ts, 0) * ts
         else a2[1];   
plot open_2 = if x >= highestAll(x2)
              then highestAll(if isNaN(c[1])
                              then Y2
                              else nan)
              else nan;
     open_2.SetStyle(Curve.Long_Dash);
     open_2.SetLineWeight(1);
     open_2.SetDefaultColor(Color.Yellow);
     open_2.HideTitle();
plot O2_h = open_2 + a2;
     O2_h.SetStyle(Curve.Short_Dash);
     O2_h.SetLineWeight(1);
     O2_h.SetDefaultColor(Color.Green);
     O2_h.HideTitle();
plot O2_l = open_2 - a2;
     O2_l.SetStyle(Curve.Short_Dash);
     O2_l.SetLineWeight(1);
     O2_l.SetDefaultColor(Color.Red);
     O2_l.HideTitle();
# End Code

https://tos.mx/eWDyyVP

https://www.mytrade.com/profile/Mobius/statuses/16089103
 
Last edited by a moderator:
It seems to produce the same levels as the Mobius script from years ago that was called "Implied and probable moves for futures"

I wonder if this is an updated version so it doesn't need to go based off of the options(can cause some issues on some stocks/futures to give -99999 value) .
 
New study by Mobius. What do you all think?

oiytTnU.png


Code:
# These attributions and study notes are part of the study code.
# Average True Range Implied Move
# Mobius
# V01.08.22.2020
# Notes: Chart data must be intraday. Extended Hours must be turned on. Chart data must include the data needed to calculate the highest Average True Range (10 days of data to calculate a 10 day Average True Range). For lower aggregations (5 minute and less) Settings > Price Axis > Fit Studies may need to be checked yes to show ATR Daily limit lines. If using on a thinly traded equity there may not be a trade at the RTH open and the Daily Implied Move may not plot for that day.
# Study Limitation: Average True Range is an average of the averaged bars range. Tying that average to any fixed point on a bar makes the erroneous assumption that the range is equal distance from that point. This study divides ATR in half and plots half above and half below the open of whatever aggregation period the user inputs. In order to keep chart clutter at a minimum the study plot only the most recent range. If the expansion area is set wide enough for the next period open to display then lines will begin plotting in the expansion area instead of at the current price bar.

input ATRlength = 10;
input Agg_1 = AggregationPeriod.Day;
input Agg_2 = AggregationPeriod.hour;

def o = open;
def h = high;
def l = low;
def c = close;
def o_1 = open(period = Agg_1);
def h_1 = high(period = Agg_1);
def l_1 = low(period = Agg_1);
def c_1 = close(period = Agg_1);
def o_2 = open(period = Agg_2);
def h_2 = high(period = Agg_2);
def l_2 = low(period = Agg_2);
def c_2 = close(period = Agg_2);
def x = barNumber();
def nan = double.nan;
def ts = TickSize();
def ATR_1 = Average(TrueRange(h_1[1], c_1[1], l_1[1]), ATRlength);
def ATR_2 = Average(TrueRange(h_2[1], c_2[1], l_2[1]), ATRlength);
def RTHo = getTime() crosses above RegularTradingStart(getYYYYMMDD());
def Y1 = if RTHo
         then o
         else Y1[1];
def x1 = if RTHo
         then x
         else x1[1];
def a1 = if RTHo
         then round((ATR_1 / 2) / ts, 0) * ts
         else a1[1];
plot RTHopen = if x >= highestAll(x1)
               then highestAll(if isNaN(c[1])
                                then Y1
                                else nan)
               else nan;
     RTHopen.SetStyle(Curve.Long_Dash);
     RTHopen.SetLineWeight(3);
     RTHopen.SetDefaultColor(Color.Yellow);
     RTHopen.HideTitle();
plot Dh = RTHopen + a1;
     Dh.SetStyle(Curve.Short_Dash);
     Dh.SetLineWeight(2);
     Dh.SetDefaultColor(Color.Green);
     Dh.HideTitle();
plot Dl = RTHopen - a1;
     Dl.SetStyle(Curve.Short_Dash);
     Dl.SetLineWeight(2);
     Dl.SetDefaultColor(Color.Red);
     Dl.HideTitle();
def Y2 = if getTime() % Agg_2 == 0
         then o_2
         else Y2[1];
def x2 = if o == o_2 and getTime() % Agg_2 == 0
         then x
         else x2[1];
def a2 = if getTime() % Agg_2 == 0
         then round((ATR_2 / 2) / ts, 0) * ts
         else a2[1];  
plot open_2 = if x >= highestAll(x2)
              then highestAll(if isNaN(c[1])
                              then Y2
                              else nan)
              else nan;
     open_2.SetStyle(Curve.Long_Dash);
     open_2.SetLineWeight(1);
     open_2.SetDefaultColor(Color.Yellow);
     open_2.HideTitle();
plot O2_h = open_2 + a2;
     O2_h.SetStyle(Curve.Short_Dash);
     O2_h.SetLineWeight(1);
     O2_h.SetDefaultColor(Color.Green);
     O2_h.HideTitle();
plot O2_l = open_2 - a2;
     O2_l.SetStyle(Curve.Short_Dash);
     O2_l.SetLineWeight(1);
     O2_l.SetDefaultColor(Color.Red);
     O2_l.HideTitle();
# End Code

https://tos.mx/eWDyyVP

https://www.mytrade.com/profile/Mobius/statuses/16089103
To function properly and per Mobius directions, "Extended Hours must be turned on".
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
295 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