Expected Move and ATR level.

CashMoney

Member
VIP
Hi,
@samer800 @MerryDay
I need some help in plotting fib levels using this indicator. I took some parts of the indicator out.
There are three lines in the indicator: MidRange, High ATR and Low ATR.

I would like fib level to be automatically plotted from following levels.
I would like Fib levels (o % to 100%) to be plotted (lines) from Mid range to High ATR.
I would like fib levels ( 0% to 100%) to be plotted (lines) from Mid range to low ATR .

Also, if small bubbles can be plotted on fib levels as well as options of fib extension to be plotted.

Thank you!! I appreciate all the help that I can get.


Here is the indicator:

# Expected Market Move
# Daily and intraday
# Assembled by Chewie 1/2/2022

input labels = yes;
input length = 14;
input em_skew_percent = 70;
input em_bandwidth = 100;


input aggregationPeriod_nd = AggregationPeriod.WEEK;
def averageType = AverageType.WILDERS;
def hi_nd = high(period = aggregationPeriod_nd)[1];
def lo_nd = low(period = aggregationPeriod_nd)[1];
def cl_nd = close(period = aggregationPeriod_nd)[1];
def open_nd = open(period = aggregationPeriod_nd);

def ivGapHi;
def expmove;

ivGapHi = imp_volatility(period = aggregationPeriod_nd)[1];
expmove = close[1] * ivGapHi * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100;

# Start Volatility Range B
def ATR_nd = MovingAverage(averageType, TrueRange(hi_nd, cl_nd, lo_nd), length);
def op_nd = open_nd;
plot ATRHI = (op_nd + ATR_nd);
plot ATRLO = (op_nd - ATR_nd);

plot weeklyMID = (ATRHI - ATRLO) / 2 + ATRLO;
weeklyMID.AssignValueColor(Color.YELLOW);
weeklyMID.SetLineWeight(2);

AddLabel(yes and labels and close > weeklyMID, "WK", color.green);
AddLabel(yes and labels and close < weeklyMID, "WK", color.red);


# Customizations

ATRHI.AssignValueColor(Color.DARK_RED);
ATRHI.SetLineWeight(4);
#t2_percentile.AssignValueColor(color.light_red);

ATRLO.AssignValueColor(Color.DARK_GREEN);
ATRLO.SetLineWeight(4);
#b2_percentile.AssignValueColor(color.light_green);

ATRHI.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRLO.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:
Solution
Hi,
@samer800 @MerryDay
I need some help in plotting fib levels using this indicator. I took some parts of the indicator out.
There are three lines in the indicator: MidRange, High ATR and Low ATR.

I would like fib level to be automatically plotted from following levels.
I would like Fib levels (o % to 100%) to be plotted (lines) from Mid range to High ATR.
I would like fib levels ( 0% to 100%) to be plotted (lines) from Mid range to low ATR .

Also, if small bubbles can be plotted on fib levels as well as options of fib extension to be plotted.

Thank you!! I appreciate all the help that I can get.


Here is the indicator:

# Expected Market Move
# Daily and intraday
# Assembled by Chewie 1/2/2022

input labels =...
Hi,
@samer800 @MerryDay
I need some help in plotting fib levels using this indicator. I took some parts of the indicator out.
There are three lines in the indicator: MidRange, High ATR and Low ATR.

I would like fib level to be automatically plotted from following levels.
I would like Fib levels (o % to 100%) to be plotted (lines) from Mid range to High ATR.
I would like fib levels ( 0% to 100%) to be plotted (lines) from Mid range to low ATR .

Also, if small bubbles can be plotted on fib levels as well as options of fib extension to be plotted.

Thank you!! I appreciate all the help that I can get.


Here is the indicator:

# Expected Market Move
# Daily and intraday
# Assembled by Chewie 1/2/2022

input labels = yes;
input length = 14;
input em_skew_percent = 70;
input em_bandwidth = 100;


input aggregationPeriod_nd = AggregationPeriod.WEEK;
def averageType = AverageType.WILDERS;
def hi_nd = high(period = aggregationPeriod_nd)[1];
def lo_nd = low(period = aggregationPeriod_nd)[1];
def cl_nd = close(period = aggregationPeriod_nd)[1];
def open_nd = open(period = aggregationPeriod_nd);

def ivGapHi;
def expmove;

ivGapHi = imp_volatility(period = aggregationPeriod_nd)[1];
expmove = close[1] * ivGapHi * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100;

# Start Volatility Range B
def ATR_nd = MovingAverage(averageType, TrueRange(hi_nd, cl_nd, lo_nd), length);
def op_nd = open_nd;
plot ATRHI = (op_nd + ATR_nd);
plot ATRLO = (op_nd - ATR_nd);

plot weeklyMID = (ATRHI - ATRLO) / 2 + ATRLO;
weeklyMID.AssignValueColor(Color.YELLOW);
weeklyMID.SetLineWeight(2);

AddLabel(yes and labels and close > weeklyMID, "WK", color.green);
AddLabel(yes and labels and close < weeklyMID, "WK", color.red);


# Customizations

ATRHI.AssignValueColor(Color.DARK_RED);
ATRHI.SetLineWeight(4);
#t2_percentile.AssignValueColor(color.light_red);

ATRLO.AssignValueColor(Color.DARK_GREEN);
ATRLO.SetLineWeight(4);
#b2_percentile.AssignValueColor(color.light_green);

ATRHI.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRLO.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


draw 2 sets of fib lines, between weekly price levels

can choose to have lines on all bars or just the last week period.

if the 2nd aggregation time is changed from week , then the x formula will have to be changed


Code:
#expected_move_atr_fib_00

#https://usethinkscript.com/threads/expected-move-and-atr-level.14549/
#Expected Move and ATR level.

#There are three lines in the indicator: MidRange, High ATR and Low ATR.


# Expected Market Move
# Daily and intraday
# Assembled by Chewie 1/2/2022

input labels = yes;
input length = 14;
input em_skew_percent = 70;
input em_bandwidth = 100;


input aggregationPeriod_nd = AggregationPeriod.WEEK;
def averageType = AverageType.WILDERS;
def hi_nd = high(period = aggregationPeriod_nd)[1];
def lo_nd = low(period = aggregationPeriod_nd)[1];
def cl_nd = close(period = aggregationPeriod_nd)[1];
def open_nd = open(period = aggregationPeriod_nd);

def ivGapHi;
def expmove;

ivGapHi = imp_volatility(period = aggregationPeriod_nd)[1];
expmove = close[1] * ivGapHi * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100;

# Start Volatility Range B
def ATR_nd = MovingAverage(averageType, TrueRange(hi_nd, cl_nd, lo_nd), length);
def op_nd = open_nd;

def ATRHI = (op_nd + ATR_nd);
def ATRLO = (op_nd - ATR_nd);
def weeklyMID = (ATRHI - ATRLO) / 2 + ATRLO;


AddLabel(yes and labels and close > weeklyMID, "WK", color.green);
AddLabel(yes and labels and close < weeklyMID, "WK", color.red);


# Customizations

plot ATRHI2 = atrhi;
ATRHI2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRHI2.setdefaultColor(Color.DARK_RED);
ATRHI2.SetLineWeight(4);

plot weeklyMID2 = weeklyMID;
weeklymid2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
weeklyMID2.AssignValueColor(Color.YELLOW);
weeklyMID2.SetLineWeight(2);

plot atrlo2 = atrlo;
ATRLO2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRLO2.setdefaultColor(Color.DARK_GREEN);
ATRLO2.SetLineWeight(4);


#-----------------------

input show_fib_lines_only_current_period = yes;

def x = if !show_fib_lines_only_current_period then 1
 else if getweek() == getlastweek() then 1
 else 0;

def na = double.nan;

# fib levels
#  23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%, 161.8%, 261.8%, and 423.6%
def f1 = 0.236;
def f2 = 0.382;
def f3 = 0.50;
def f4 = 0.618;
def f5 = 0.786;

# rng ,  ATR_nd
#-----------------------------
plot hi5 = if !x then na else weeklyMID + (ATR_nd * f5);
plot hi4 = if !x then na else weeklyMID + (ATR_nd * f4);
plot hi3 = if !x then na else weeklyMID + (ATR_nd * f3);
plot hi2 = if !x then na else weeklyMID + (ATR_nd * f2);
plot hi1 = if !x then na else weeklyMID + (ATR_nd * f1);

hi1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi1.setdefaultColor(Color.gray);
hi1.hidebubble();
hi2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi2.setdefaultColor(Color.gray);
hi2.hidebubble();
hi3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi3.SetStyle(Curve.MEDIUM_DASH);
hi3.setdefaultColor(Color.light_gray);
hi3.hidebubble();
hi4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi4.setdefaultColor(Color.gray);
hi4.hidebubble();
hi5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi5.setdefaultColor(Color.gray);
hi5.hidebubble();

#-----------------------------

plot lo5 = if !x then na else weeklyMID - (ATR_nd * f5);
plot lo4 = if !x then na else weeklyMID - (ATR_nd * f4);
plot lo3 = if !x then na else weeklyMID - (ATR_nd * f3);
plot lo2 = if !x then na else weeklyMID - (ATR_nd * f2);
plot lo1 = if !x then na else weeklyMID - (ATR_nd * f1);

lo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo1.setdefaultColor(Color.gray);
lo1.hidebubble();
lo2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo2.setdefaultColor(Color.gray);
lo2.hidebubble();
lo3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo3.SetStyle(Curve.MEDIUM_DASH);
lo3.setdefaultColor(Color.light_gray);
lo3.hidebubble();
lo4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo4.setdefaultColor(Color.gray);
lo4.hidebubble();
lo5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo5.setdefaultColor(Color.gray);
lo5.hidebubble();

#-----------------------------

addchartbubble(0, low,
op_nd + "\n" +
open_nd + "\n" +
 ATR_nd + "\n" +
(getday() == getlastday()) + "\n" +
(getweek() == getlastweek())
, color.yellow, no);
#

BK 2hr chart
mg3fYDr.jpg
 
Solution
draw 2 sets of fib lines, between weekly price levels

can choose to have lines on all bars or just the last week period.

if the 2nd aggregation time is changed from week , then the x formula will have to be changed


Code:
#expected_move_atr_fib_00

#https://usethinkscript.com/threads/expected-move-and-atr-level.14549/
#Expected Move and ATR level.

#There are three lines in the indicator: MidRange, High ATR and Low ATR.


# Expected Market Move
# Daily and intraday
# Assembled by Chewie 1/2/2022

input labels = yes;
input length = 14;
input em_skew_percent = 70;
input em_bandwidth = 100;


input aggregationPeriod_nd = AggregationPeriod.WEEK;
def averageType = AverageType.WILDERS;
def hi_nd = high(period = aggregationPeriod_nd)[1];
def lo_nd = low(period = aggregationPeriod_nd)[1];
def cl_nd = close(period = aggregationPeriod_nd)[1];
def open_nd = open(period = aggregationPeriod_nd);

def ivGapHi;
def expmove;

ivGapHi = imp_volatility(period = aggregationPeriod_nd)[1];
expmove = close[1] * ivGapHi * Sqrt(6) / Sqrt(365) * em_skew_percent / 100 * em_bandwidth / 100;

# Start Volatility Range B
def ATR_nd = MovingAverage(averageType, TrueRange(hi_nd, cl_nd, lo_nd), length);
def op_nd = open_nd;

def ATRHI = (op_nd + ATR_nd);
def ATRLO = (op_nd - ATR_nd);
def weeklyMID = (ATRHI - ATRLO) / 2 + ATRLO;


AddLabel(yes and labels and close > weeklyMID, "WK", color.green);
AddLabel(yes and labels and close < weeklyMID, "WK", color.red);


# Customizations

plot ATRHI2 = atrhi;
ATRHI2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRHI2.setdefaultColor(Color.DARK_RED);
ATRHI2.SetLineWeight(4);

plot weeklyMID2 = weeklyMID;
weeklymid2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
weeklyMID2.AssignValueColor(Color.YELLOW);
weeklyMID2.SetLineWeight(2);

plot atrlo2 = atrlo;
ATRLO2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ATRLO2.setdefaultColor(Color.DARK_GREEN);
ATRLO2.SetLineWeight(4);


#-----------------------

input show_fib_lines_only_current_period = yes;

def x = if !show_fib_lines_only_current_period then 1
 else if getweek() == getlastweek() then 1
 else 0;

def na = double.nan;

# fib levels
#  23.6%, 38.2%, 50%, 61.8%, 78.6%, 100%, 161.8%, 261.8%, and 423.6%
def f1 = 0.236;
def f2 = 0.382;
def f3 = 0.50;
def f4 = 0.618;
def f5 = 0.786;

# rng ,  ATR_nd
#-----------------------------
plot hi5 = if !x then na else weeklyMID + (ATR_nd * f5);
plot hi4 = if !x then na else weeklyMID + (ATR_nd * f4);
plot hi3 = if !x then na else weeklyMID + (ATR_nd * f3);
plot hi2 = if !x then na else weeklyMID + (ATR_nd * f2);
plot hi1 = if !x then na else weeklyMID + (ATR_nd * f1);

hi1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi1.setdefaultColor(Color.gray);
hi1.hidebubble();
hi2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi2.setdefaultColor(Color.gray);
hi2.hidebubble();
hi3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi3.SetStyle(Curve.MEDIUM_DASH);
hi3.setdefaultColor(Color.light_gray);
hi3.hidebubble();
hi4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi4.setdefaultColor(Color.gray);
hi4.hidebubble();
hi5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hi5.setdefaultColor(Color.gray);
hi5.hidebubble();

#-----------------------------

plot lo5 = if !x then na else weeklyMID - (ATR_nd * f5);
plot lo4 = if !x then na else weeklyMID - (ATR_nd * f4);
plot lo3 = if !x then na else weeklyMID - (ATR_nd * f3);
plot lo2 = if !x then na else weeklyMID - (ATR_nd * f2);
plot lo1 = if !x then na else weeklyMID - (ATR_nd * f1);

lo1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo1.setdefaultColor(Color.gray);
lo1.hidebubble();
lo2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo2.setdefaultColor(Color.gray);
lo2.hidebubble();
lo3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo3.SetStyle(Curve.MEDIUM_DASH);
lo3.setdefaultColor(Color.light_gray);
lo3.hidebubble();
lo4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo4.setdefaultColor(Color.gray);
lo4.hidebubble();
lo5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lo5.setdefaultColor(Color.gray);
lo5.hidebubble();

#-----------------------------

addchartbubble(0, low,
op_nd + "\n" +
open_nd + "\n" +
 ATR_nd + "\n" +
(getday() == getlastday()) + "\n" +
(getweek() == getlastweek())
, color.yellow, no);
#

BK 2hr chart
mg3fYDr.jpg
Thank you. I will try it out
 

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
250 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