Auto Fib Levels Using High and Low of # of Input Days

Hello - this probably exists, but I have not been able to find it among the hundreds of posts on fib levels. In my observation, and that suits my strategy and style, I have noticed price respecting the Fib levels I draw on a 10 day 5 min chart (using the high and low of the previous 10 days). I do this manually now every day for each of my charts, and I typically analyze 15-20 charts. I want to see if I can automate this to make my life easier :). I can live with static 10 day indicator, but would prefer one where number of days can be an input so I can adjust it if I need to.

Does such an indicator exist, or can it be created?
 
Solution
Hello - this probably exists, but I have not been able to find it among the hundreds of posts on fib levels. In my observation, and that suits my strategy and style, I have noticed price respecting the Fib levels I draw on a 10 day 5 min chart (using the high and low of the previous 10 days). I do this manually now every day for each of my charts, and I typically analyze 15-20 charts. I want to see if I can automate this to make my life easier :). I can live with static 10 day indicator, but would prefer one where number of days can be an input so I can adjust it if I need to.

Does such an indicator exist, or can it be created?

This might work for you. Set showtodayonly to NO to test basis of HH and LL


Screenshot 2023-08-20 122746.png
...
Hello - this probably exists, but I have not been able to find it among the hundreds of posts on fib levels. In my observation, and that suits my strategy and style, I have noticed price respecting the Fib levels I draw on a 10 day 5 min chart (using the high and low of the previous 10 days). I do this manually now every day for each of my charts, and I typically analyze 15-20 charts. I want to see if I can automate this to make my life easier :). I can live with static 10 day indicator, but would prefer one where number of days can be an input so I can adjust it if I need to.

Does such an indicator exist, or can it be created?

This might work for you. Set showtodayonly to NO to test basis of HH and LL


Screenshot 2023-08-20 122746.png

Code:
#Auto_Fib_Levels_Using_High_and_Low_of_#_of_Input_Days_Excluding_Todays

input showtodayonly = yes;#Hint showtodayonly: Set to NO to test HH/LL Basis
input daysago       = 10;

def ymd      = GetYYYYMMDD();
def candles  = !IsNaN(close);
def capture  = candles and ymd != ymd[1];
def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0);
def thisDay  = (HighestAll(dayCount) - dayCount) ;

def hi  = if thisDay == daysago and thisDay != thisDay[1]
          then high
          else if thisDay != 0
          then Max(high, hi[1])
          else hi[1];
plot hh = if showtodayonly and thisDay == 0
          then hi
          else if !showtodayonly and thisDay <= daysago
          then hi
          else Double.NaN;
def lo  = if thisDay == daysago and thisDay != thisDay[1]
          then low
          else if thisDay != 0
          then Min(low, lo[1])
          else lo[1];
plot ll = if showtodayonly and thisDay == 0
          then lo
          else if !showtodayonly and thisDay <= daysago
          then lo
          else Double.NaN;
AddVerticalLine(thisDay == daysago and thisDay != thisDay[1], "", Color.WHITE);

input showbubbles   = yes;
input bubblemover   = 4; #Hint n: Number of Bars to shift bubble to the right

input F1 = -1.00;
input F2 = -0.62;
input F3 = -0.27;
input F4 = 0.236;
input F5 = 0.382;
input F6 = 0.500;
input F7 = 0.618;
input F8 = 0.764;
input F10 = 1.27;
input F11 = 1.618;
input F12 = 2.00;

def rHi =  hh;
def rLo =  ll;

def range  = rHi - rLo;
plot FF1   = rLo + (range * F1);
plot FF2   = rLo + (range * F2);
plot FF3   = rLo + (range * F3);
plot FF4   = rLo + (range * F4);
plot FF5   = rLo + (range * F5);
plot FF6   = rLo + (range * F6);
plot FF7   = rLo + (range * F7);
plot FF8   = rLo + (range * F8);
plot FF10  = rLo + (range * F10);
plot FF11  = rLo + (range * F11);
plot FF12  = rLo + (range * F12);

FF1.SetDefaultColor(Color.GREEN);
FF1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF1.SetLineWeight(1);

FF2.SetDefaultColor(Color.GREEN);
FF2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF2.SetLineWeight(1);

FF3.SetDefaultColor(Color.GREEN);
FF3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF3.SetLineWeight(1);

FF4.SetDefaultColor(Color.RED);
FF4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF4.SetLineWeight(1);

FF5.SetDefaultColor(Color.RED);
FF5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF5.SetLineWeight(1);

FF6.SetDefaultColor(Color.YELLOW);
FF6.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF6.SetLineWeight(1);

FF7.SetDefaultColor(Color.CYAN);
FF7.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF7.SetLineWeight(1);

FF8.SetDefaultColor(Color.CYAN);
FF8.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF8.SetLineWeight(1);


FF10.SetDefaultColor(Color.GREEN);
FF10.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF10.SetLineWeight(1);

FF11.SetDefaultColor(Color.GREEN);
FF11.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF11.SetLineWeight(1);

FF12.SetDefaultColor(Color.GREEN);
FF12.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
FF12.SetLineWeight(1);

def   b           = bubblemover;
def   b1          = b + 1;
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF1[b], F1, FF1.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF2[b], F2, FF2.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF3[b], F3, FF3.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF4[b], F4, FF4.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF5[b], F5, FF5.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF6[b], F6, FF6.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF7[b], F7, FF7.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF8[b], F8, FF8.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF10[b], F10, FF10.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF11[b], F11, FF11.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), FF12[b], F12, FF12.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), hh[b], 1, hh.TakeValueColor());
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), ll[b], 0, ll.TakeValueColor());
 
Last edited:
Solution

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