Daily ATR High and Low with Fibonacci Lines Plotted

Andy98sanchez

New member
Hey guys, big fan of scripts! I have been using the daily ATR's high and lows to chart potential key levels, but I also manually plot the Fibonacci levels from the current Day's upper ATR and lower ATR. I only like to see it on the current or prev day like the script shown, but i follow the levels into the following day. I'm not sure how to write those Fib levels into the script so that they plot with the ATR levels with Fib100% being ATR high and Fib0% being ATR low. Only for the current period though and the smaller timeframes.

https%3A//i.imgur.com/5yd5Tpp.png[/img]']
5yd5Tpp.png



https%3A//i.imgur.com/baUEmZN.png[/img]']
baUEmZN.png




Code:
input ATRperiod = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input ATRMultiplier = 1;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRperiod);
def DailyClose = close(period = ”DAY”)[0];
def HighATR = DailyClose + ATR ;
def LowATR = DailyClose - ATR;
def LastBar = !IsNaN(open) and IsNaN(open[-1]);

plot ADR_H = if LastBar then HighATR else Double.NaN;
plot ADR_L = if LastBar then LowATR else Double.NaN;
 
Hey guys, big fan of scripts! I have been using the daily ATR's high and lows to chart potential key levels, but I also manually plot the Fibonacci levels from the current Day's upper ATR and lower ATR. I only like to see it on the current or prev day like the script shown, but i follow the levels into the following day. I'm not sure how to write those Fib levels into the script so that they plot with the ATR levels with Fib100% being ATR high and Fib0% being ATR low. Only for the current period though and the smaller timeframes.

https%3A//i.imgur.com/5yd5Tpp.png[/img]']
5yd5Tpp.png



https%3A//i.imgur.com/baUEmZN.png[/img]']
baUEmZN.png




Code:
input ATRperiod = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input ATRMultiplier = 1;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[1], close(period = ”DAY”)[1], low(period = ”DAY”)[1]), ATRperiod);
def DailyClose = close(period = ”DAY”)[0];
def HighATR = DailyClose + ATR ;
def LowATR = DailyClose - ATR;
def LastBar = !IsNaN(open) and IsNaN(open[-1]);

plot ADR_H = if LastBar then HighATR else Double.NaN;
plot ADR_L = if LastBar then LowATR else Double.NaN;

See if this helps

Screenshot-2022-11-28-140403.png
Ruby:
input lookback  = 1;
input ATRperiod = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input ATRMultiplier = 1;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[lookback+1], close(period = ”DAY”)[lookback+1], low(period = ”DAY”)[lookback+1]), ATRperiod);
def DailyClose = close(period = ”DAY”)[lookback+0];
def HighATR = DailyClose + ATR ;
def LowATR = DailyClose - ATR;
def bn = BarNumber();
def na = Double.NaN;
def LastBar = !IsNaN(open) and IsNaN(open[-1]);
def lastbarnumber = HighestAll(if LastBar then bn else na);
def ADRH = if IsNaN(close) then ADRH[1] else  if LastBar then HighATR[lookback] else ADRH[1];
def ADRL = if IsNaN(close) then ADRL[1] else  if LastBar then LowATR[lookback] else ADRL[1];

input limit_line_plot = 4;

def range   = ADRH - ADRL;

plot f100   = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRH else na;
plot f0     = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL else na;
plot f236   = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * .236 else na;
plot f382   = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * .382 else na;
plot f500   = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * .500 else na;
plot f618   = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * .618 else na;
plot f764   = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * .764 else na;
plot f1236  = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * 1.236 else na;
plot f1382  = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL + range * 1.382 else na;
plot f1236_ = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL - range * .236 else na;
plot f1382_ = if Between(bn, lastbarnumber, lastbarnumber + limit_line_plot) then ADRL - range * .382 else na;

f100.SetPaintingStrategy(PaintingStrategy.DASHES);
f0.SetPaintingStrategy(PaintingStrategy.DASHES);
f236.SetPaintingStrategy(PaintingStrategy.DASHES);
f382.SetPaintingStrategy(PaintingStrategy.DASHES);
f500.SetPaintingStrategy(PaintingStrategy.DASHES);
f618.SetPaintingStrategy(PaintingStrategy.DASHES);
f764.SetPaintingStrategy(PaintingStrategy.DASHES);
f1236.SetPaintingStrategy(PaintingStrategy.DASHES);
f1382.SetPaintingStrategy(PaintingStrategy.DASHES);
f1236_.SetPaintingStrategy(PaintingStrategy.DASHES);
f1382_.SetPaintingStrategy(PaintingStrategy.DASHES);

DefineGlobalColor("F", Color.WHITE);
f100.SetDefaultColor(GlobalColor("F"));
f0.SetDefaultColor(GlobalColor("F"));
f236.SetDefaultColor(GlobalColor("F"));
f382.SetDefaultColor(GlobalColor("F"));
f500.SetDefaultColor(GlobalColor("F"));
f618.SetDefaultColor(GlobalColor("F"));
f764.SetDefaultColor(GlobalColor("F"));
f1236.SetDefaultColor(GlobalColor("F"));
f1382.SetDefaultColor(GlobalColor("F"));
f1236_.SetDefaultColor(GlobalColor("F"));
f1382_.SetDefaultColor(GlobalColor("F"));

f100.HideBubble();
f0.HideBubble();
f236.HideBubble();
f382.HideBubble();
f500.HideBubble();
f618.HideBubble();
f764.HideBubble();
f1236.HideBubble();
f1382.HideBubble();
f1236_.HideBubble();
f1382_.HideBubble();

input showbubbles = yes;
input bubblemover = 4;
input showbubble_price = yes;
def b = bubblemover;
def b1 = b + 1;

AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f100[b1], "100% " + (if showbubble_price then AsDollars(f100[b1]) else " "), f100.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f0[b1], "0% " + (if showbubble_price then AsDollars(f0[b1]) else " "), f0.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f236[b1], "23.6% " + (if showbubble_price then AsDollars(f236[b1]) else " "), f236.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f382[b1], "38.2% " + (if showbubble_price then AsDollars(f382[b1]) else " "), f382.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f500[b1], "50% " + (if showbubble_price then AsDollars(f500[b1]) else " "), f500.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f618[b1], "61.8% " + (if showbubble_price then AsDollars(f618[b1]) else " "), f618.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f764[b1], "76.% " + (if showbubble_price then AsDollars(f764[b1]) else " "), f764.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1236[b1], "123.6% " + (if showbubble_price then AsDollars(f1236[b1]) else " "), f1236.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1382[b1], "138.2% " + (if showbubble_price then AsDollars(f1382[b1]) else " "), f1382.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1236_[b1], "-23.6% " + (if showbubble_price then AsDollars(f1236_[b1]) else " "), f1236_.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1382_[b1], "-38.2% " + (if showbubble_price then AsDollars(f1382_[b1]) else " "), f1382_.TakeValueColor());
 
SleepyZ after applying the indicator and testing it for a bit, is there a way to extend the plotted lines to the Left of the chart.

Sure, great suggestion! The input limit_line_plot now controls whether if no, to have the plots extended across the chart or if yes, then just the
input limit_plot_length to the right.

Screenshot-2022-11-29-102133.png
Ruby:
input limit_line_plot   = yes;
input limit_plot_length = 4;

input lookback  = 1;
input ATRperiod = 14;
input averageType = AverageType.WILDERS;
input BasePeriod = AggregationPeriod.DAY;
input ATRMultiplier = 1;

def ATR = MovingAverage(averageType, TrueRange(high(period = ”DAY”)[lookback+1], close(period = ”DAY”)[lookback+1], low(period = ”DAY”)[lookback+1]), ATRperiod);
def DailyClose = close(period = ”DAY”)[lookback+0];
def HighATR = DailyClose + ATR ;
def LowATR = DailyClose - ATR;
def bn = BarNumber();
def na = Double.NaN;
def LastBar = !IsNaN(open) and IsNaN(open[-1]);
def lastbarnumber = HighestAll(if LastBar then bn else na);
def ADRH = if IsNaN(close) then ADRH[1] else  if LastBar then HighATR[lookback] else ADRH[1];
def ADRL = if IsNaN(close) then ADRL[1] else  if LastBar then LowATR[lookback] else ADRL[1];


def range   = ADRH - ADRL;

plot f100   = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then ADRH else if !limit_line_plot then highestall(ADRH) else  na;
plot f0     = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then ADRL else if !limit_line_plot then highestall(ADRL) else  na;
plot f236   = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * .236 else if !limit_line_plot then highestall( ADRL + range * .236) else  na;
plot f382   = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * .382 else if !limit_line_plot then highestall( ADRL + range * .382) else  na;
plot f500   = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * .500 else if !limit_line_plot then highestall( ADRL + range * .500) else  na;
plot f618   = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * .618 else if !limit_line_plot then highestall( ADRL + range * .618) else  na;
plot f764   = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * .764 else if !limit_line_plot then highestall( ADRL + range * .764) else  na;
plot f1236  = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * 1.236 else if !limit_line_plot then highestall( ADRL + range * 1.236) else  na;
plot f1382  = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL + range * 1.382 else if !limit_line_plot then highestall( ADRL + range * 1.382) else  na;
plot f1236_ = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL - range * .236 else if !limit_line_plot then highestall( ADRL - range * .236) else  na;
plot f1382_ = if limit_line_plot and Between(bn, lastbarnumber, lastbarnumber + limit_plot_length) then  ADRL - range * .382 else if !limit_line_plot then highestall( ADRL - range * .382) else  na;

f100.SetPaintingStrategy(PaintingStrategy.DASHES);
f0.SetPaintingStrategy(PaintingStrategy.DASHES);
f236.SetPaintingStrategy(PaintingStrategy.DASHES);
f382.SetPaintingStrategy(PaintingStrategy.DASHES);
f500.SetPaintingStrategy(PaintingStrategy.DASHES);
f618.SetPaintingStrategy(PaintingStrategy.DASHES);
f764.SetPaintingStrategy(PaintingStrategy.DASHES);
f1236.SetPaintingStrategy(PaintingStrategy.DASHES);
f1382.SetPaintingStrategy(PaintingStrategy.DASHES);
f1236_.SetPaintingStrategy(PaintingStrategy.DASHES);
f1382_.SetPaintingStrategy(PaintingStrategy.DASHES);

DefineGlobalColor("F", Color.WHITE);
f100.SetDefaultColor(GlobalColor("F"));
f0.SetDefaultColor(GlobalColor("F"));
f236.SetDefaultColor(GlobalColor("F"));
f382.SetDefaultColor(GlobalColor("F"));
f500.SetDefaultColor(GlobalColor("F"));
f618.SetDefaultColor(GlobalColor("F"));
f764.SetDefaultColor(GlobalColor("F"));
f1236.SetDefaultColor(GlobalColor("F"));
f1382.SetDefaultColor(GlobalColor("F"));
f1236_.SetDefaultColor(GlobalColor("F"));
f1382_.SetDefaultColor(GlobalColor("F"));

f100.HideBubble();
f0.HideBubble();
f236.HideBubble();
f382.HideBubble();
f500.HideBubble();
f618.HideBubble();
f764.HideBubble();
f1236.HideBubble();
f1382.HideBubble();
f1236_.HideBubble();
f1382_.HideBubble();

input showbubbles = yes;
input bubblemover = 4;
input showbubble_price = yes;
def b = bubblemover;
def b1 = b + 1;

AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f100[b1], "100% " + (if showbubble_price then AsDollars(f100[b1]) else " "), f100.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f0[b1], "0% " + (if showbubble_price then AsDollars(f0[b1]) else " "), f0.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f236[b1], "23.6% " + (if showbubble_price then AsDollars(f236[b1]) else " "), f236.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f382[b1], "38.2% " + (if showbubble_price then AsDollars(f382[b1]) else " "), f382.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f500[b1], "50% " + (if showbubble_price then AsDollars(f500[b1]) else " "), f500.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f618[b1], "61.8% " + (if showbubble_price then AsDollars(f618[b1]) else " "), f618.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f764[b1], "76.% " + (if showbubble_price then AsDollars(f764[b1]) else " "), f764.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1236[b1], "123.6% " + (if showbubble_price then AsDollars(f1236[b1]) else " "), f1236.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1382[b1], "138.2% " + (if showbubble_price then AsDollars(f1382[b1]) else " "), f1382.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1236_[b1], "-23.6% " + (if showbubble_price then AsDollars(f1236_[b1]) else " "), f1236_.TakeValueColor());
AddChartBubble(showbubbles and !IsNaN(open[b1]) and IsNaN(open[b]), f1382_[b1], "-38.2% " + (if showbubble_price then AsDollars(f1382_[b1]) else " "), f1382_.TakeValueColor());
 
Sorry for stupid question, but how I download it, it is indicator for mt4 ? I am looking something like this and having buffer showing % in data windows if possible
 

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