Plot 1hour Fibonacci Retracement lines on any timeframe

zeek

Active member
2019 Donor
Hi guys, i like to use Fib retracement lines to find areas of support and resistance and i have been thinking about an idea for a while and wanted to ask if its possible to make a script for this. What i am looking for is basically a script that plots the Fib retracement lines but not based on the current selected timeframe but rather i would like the script to plot the Fib lines based on the highest high & lowest low on the 1 hour timeframe and going back 180 days. And i want these line to show on any timeframe i select on a chart.

So in the example pic i attached, i want these Fib lines for BYND on the 1hour timeframe going 180 days back in time to show on a 3min timeframe for example.

Can this be done?

9Uewr5W.png
 

Attachments

  • 9Uewr5W.png
    9Uewr5W.png
    317.4 KB · Views: 69
Strange page, but there is a code on it that plots what you want on 4-hours. You can change it to 1 hour.

Code:
# CopyCode
#
# cisRxSESSIONS
# Corum Integrated Solutions Inc
# GreatGatsbyProTrader Solution Series
# RxSERIES
#
# Joshua Corum (c) 2009-2017
#
declare upper;
# CopyCode
def HLRANGE = high – low;
def RANGE = High(period = AggregationPeriod.FOUR_HOURS)[1] – low(period = AggregationPeriod.FOUR_HOURS)[1];
def HLR21 = ExpAverage(HLRANGE, AggregationPeriod.HOUR)[1];
def HLR3 = ExpAverage (HLRANGE, AggregationPeriod.HOUR)[1];
# CorumIntegratedSolutions.com
def Rx= hlc3(period=AggregationPeriod.FOUR_HOURS)[1];
# thinkorswimTOOLKIT.com
plot BALANCE = hl2(period=AggregationPeriod.FOUR_HOURS)[1];
BALANCE.SetPaintingStrategy (paintingstrategy.DASHES);
BALANCE.SetDefaultColor (Color.DARK_GRAY);
BALANCE.SetLineWeight (2);
# youtube.com/user/cisTRADING
plot UPPER_Band=BALANCE+RANGE*.5;
UPPER_Band.SetPaintingStrategy (paintingstrategy.DASHES);
UPPER_Band.SetDefaultColor (Color.GREEN);
UPPER_Band.SetLineWeight (1);
plot LOWER_Band=BALANCE-RANGE*.5;
LOWER_Band.SetPaintingStrategy (paintingstrategy.DASHES);
LOWER_Band.SetDefaultColor (Color.BLUE);
LOWER_Band.SetLineWeight (1);
plot UPPER_R=BALANCE+RANGE*.5+ HLR3;
UPPER_R.SetPaintingStrategy (paintingstrategy.DASHES);
UPPER_R.SetDefaultColor (Color.GREEN);
UPPER_R.SetLineWeight (1);
plot LOWER_R=BALANCE-RANGE*.5-HLR3;
LOWER_R.SetPaintingStrategy (paintingstrategy.DASHES);
LOWER_R.SetDefaultColor (Color.BLUE);
LOWER_R.SetLineWeight (1);
# thinkscriptTHINKORSWIM.com
plot UPPER_x=BALANCE+ HLR21;
UPPER_x.SetPaintingStrategy (paintingstrategy.DASHES);
UPPER_x.SetDefaultColor (Color.GREEN);
UPPER_x.SetLineWeight (1);
plot LOWER_x=BALANCE-HLR21;
LOWER_x.SetPaintingStrategy (paintingstrategy.DASHES);
LOWER_x.SetDefaultColor (Color.BLUE);
LOWER_x.SetLineWeight (1);
# JoshuaCorum.com
# PasteCode

Source
 
Last edited by a moderator:
Why is it four hour and then these lines say .HOUR ?
def HLR21 = ExpAverage(HLRANGE, AggregationPeriod.HOUR)[1];
def HLR3 = ExpAverage (HLRANGE, AggregationPeriod.HOUR)[1];

It appears this line does nothing.
def Rx= hlc3(period=AggregationPeriod.FOUR_HOURS)[1];

Please clarify. Thank you.
 
Here is another option. Plots the levels on any candle.

Code:
#Code by BLT
def last = if isnan(close[-1]) and !isnan(close) then barnumber() else last[1];
def hilo = if hl2 then barnumber() else hilo[1];

def cond = if barNumber() == hilo then barNumber()-1 else double.nan;
def pbar = if barNumber() >= HighestAll(cond) and !last then 1 else double.nan;

input show50 = yes;
plot HalfBack = if show50 and !isnan(pbar) then hl2 else double.nan;
HalfBack.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
HalfBack.SetDefaultColor(color.Yellow);
HalfBack.SetLineWeight(3);
def hbext    = if isnan(halfback) then hbext[1] else halfback;
plot hbextline = hbext;
hbextline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hbextline.SetDefaultColor(color.Yellow);
hbextline.SetLineWeight(3);

input show75 = yes;
plot Back75 = if show75 and !isnan(pbar) then low+(high-low)*.75 else double.nan;
Back75.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Back75.SetDefaultColor(color.white);
Back75.SetLineWeight(1);

input show25 = yes;
plot Back25 = if show25 and !isnan(pbar) then low+(high-low)*.25 else double.nan;
Back25.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Back25.SetDefaultColor(color.white);
Back25.SetLineWeight(1);

input bubblemover = 1;
def n1 = bubblemover + 1;
input showbubble_candle    = no;
input showbubble_expansion = no;
addchartBubble(showbubble_candle and barnumber()==highestall(last-1),high,"H: " +high,color.white,yes);
addchartBubble(showbubble_candle and barnumber()==highestall(last-1),low,"L: " +low,color.white,no);
addchartBubble(showbubble_expansion and isnan(close[bubblemover]) and !isnan(close[n1]),high[n1+1],"H: " +high[n1+1],color.white,yes);
addchartBubble(showbubble_expansion and isnan(close[bubblemover]) and !isnan(close[n1]),low[n1+1],"L: " +low[n1+1],color.white,no);
def h1 = if isnan(close) then h1[1] else high[1];
plot h1p = if barnumber()>=highestall(last) then h1 else double.nan;
h1p.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
h1p.setdefaultColor(color.white);
input showcolor_light_gray = yes;
h1p.assignvalueColor(if showcolor_light_gray then color.light_gray else color.white);
def l1 = if isnan(close) then l1[1] else low[1];
plot l1p = if barnumber()>=highestall(last) then l1 else double.nan;
l1p.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
l1p.setdefaultColor(color.white);
l1p.assignvalueColor(if showcolor_light_gray then color.light_gray else color.white);
 
Last edited by a moderator:
I'm trying to get the following code to plot the previous day and week candle 50%, 75%, and 25% price levels on a 5min - 1Hr chart. I cannot seem to figure it out:

Code:
input showlabels = yes;

def last = if isnan(close[-1]) and !isnan(close) then barnumber() else last[1];
def hilo = if hl2 then barnumber() else hilo[1];

def cond = if barNumber() == hilo then barNumber()-1 else double.nan;
def pbar = if barNumber() >= HighestAll(cond) and !last then 1 else double.nan;

input show50 = yes;
plot HalfBack = if show50 and !isnan(pbar) then hl2 else double.nan;
HalfBack.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
HalfBack.SetDefaultColor(color.Yellow);
HalfBack.SetLineWeight(3);
def hbext    = if isnan(halfback) then hbext[1] else halfback;
plot hbextline = hbext;
hbextline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hbextline.SetDefaultColor(color.Yellow);
hbextline.SetLineWeight(3);

input show75 = yes;
plot Back75 = if show75 and !isnan(pbar) then low+(high-low)*.75 else double.nan;
Back75.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Back75.SetDefaultColor(color.white);
Back75.SetLineWeight(1);

input show25 = yes;
plot Back25 = if show25 and !isnan(pbar) then low+(high-low)*.25 else double.nan;
Back25.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Back25.SetDefaultColor(color.white);
Back25.SetLineWeight(1);

input bubblemover = 1;
def n1 = bubblemover + 1;
input showbubble_candle    = no;
input showbubble_expansion = no;
addchartBubble(showbubble_candle and barnumber()==highestall(last-1),high,"H: " +high,color.white,yes);
addchartBubble(showbubble_candle and barnumber()==highestall(last-1),low,"L: " +low,color.white,no);
addchartBubble(showbubble_expansion and isnan(close[bubblemover]) and !isnan(close[n1]),high[n1+1],"H: " +high[n1+1],color.white,yes);
addchartBubble(showbubble_expansion and isnan(close[bubblemover]) and !isnan(close[n1]),low[n1+1],"L: " +low[n1+1],color.white,no);
def h1 = if isnan(close) then h1[1] else high[1];
plot h1p = if barnumber()>=highestall(last) then h1 else double.nan;
h1p.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
h1p.setdefaultColor(color.white);
input showcolor_light_gray = yes;
h1p.assignvalueColor(if showcolor_light_gray then color.white else color.white);
def l1 = if isnan(close) then l1[1] else low[1];
plot l1p = if barnumber()>=highestall(last) then l1 else double.nan;
l1p.setpaintingStrategy(PaintingStrategy.HORIZONTAL);
l1p.setdefaultColor(color.white);
l1p.assignvalueColor(if showcolor_light_gray then color.white else color.white);

AddLabel(yes, Concat(“H=”, high[1]),  if close > high[1] then Color.GREEN else Color.gray);
AddLabel(yes, Concat(“M=”, (high[1]+low[1])/2),  if close > high[1] then Color.gray else Color.gray);
AddLabel(yes, Concat(“L=”, low[1]),  if close < low[1] then Color.red else Color.gray);


# Alerts
 

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