Seeking code to Extend Orb Target lines to end of day

omfinancial

New member
Good Day and Happy February,
orginal study: https://usethinkscript.com/threads/...nkorswim-with-fibonacci-levels.29/#post-11740
I am seeking to know if it is possible to edit this code to extend lines horizontally automatically.

It is an ORB study so it is dependent on the time frame, but I am trying to have the target lines extended to the end of the day as soon as they are set - similar to any pivot point study.

Thank you for reading - and if so inclined to help, thank you in advance
---

#Opening Range Fibs
#Using the first candle to create Fib Support/Resist Levels
#Saw a Variation posted by BenTen, Decided to Edit to fit my needs
#Added Options to Hide/Show lines

input ORBegin = 0930;
input OREnd = 0945;
Input FibExt1 = 1.621;
Input FibExt2 = 2.621;
#Input FibExt3 = 4.121;
Input FibExt3 = 3.621;
#Input FibExt4 = 3.921;
Input ShowORH = yes;
Input ShowORL = yes;
Input ShowFibMid = yes;
Input ShowFibExt1 = yes;
Input ShowFibExt2 = yes;
Input ShowFibExt3 = yes;


input ShowTodayOnly={"No", default "Yes"};
def s=ShowTodayOnly;




Def ORActive = if secondstilltime(OREnd)>0 AND secondsfromtime(ORBegin)>=0 then 1 else 0;

Def today=if s==0 OR getday()==getlastday() AND secondsfromtime(ORBegin)>=0 then 1 else 0;

Def ORHigh = if ORHigh[1]==0 or ORActive[1]==0 AND ORActive==1 then high else if ORActive AND high>ORHigh[1] then high else ORHigh[1];

Def ORLow = if ORLow[1]==0 or ORActive[1]==0 AND ORActive==1 then low else if ORActive AND low<ORLow[1] then low else ORLow[1];

Def ORWidth = ORHigh - ORLow;


Def fib_mid = (ORHigh+ORLow)/2;
Def fib_ext_up1 = ORHigh + ORWidth*(FibExt1 - 1);
Def fib_ext_down1 = ORLow - ORWidth*(FibExt1 - 1);
Def fib_ext_up2= ORHigh + ORWidth*(FibExt2 - 1);
Def fib_ext_down2 = ORLow - ORWidth*(FibExt2 - 1);
Def fib_ext_up3= ORHigh + ORWidth*(FibExt3 - 1);
Def fib_ext_down3 = ORLow - ORWidth*(FibExt3 - 1);
#Def fib_ext_up4= ORHigh + ORWidth*(FibExt4 - 1);
#Def fib_ext_down4 = ORLow - ORWidth*(FibExt4 - 1);
#
# Define all the plots:
#
Plot ORH=if ORActive OR today < 1 OR !ShowORH then double.nan else ORHigh;
Plot ORL=if ORActive OR today < 1 or !ShowORL then double.nan else ORLow;
Plot FibMid=if ORActive OR today < 1 or !ShowFibMid then double.nan else fib_mid;
Plot FibExtUp1=if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_up1;
Plot FibExtDown1=if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_down1;
Plot FibExtUp2=if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_up2;
Plot FibExtDown2=if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_down2;
Plot FibExtUp3=if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_up3;
Plot FibExtDown3=if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_down3;
#Plot FibExtUp4=if ORActive OR today < 1 then double.nan else fib_ext_up3;
#Plot FibExtDown4=if ORActive OR today < 1 then double.nan else fib_ext_down3;


ORH.setdefaultcolor(color.gray);
ORH.setStyle(curve.Long_DASH);
ORH.setlineweight(1);
ORL.setdefaultcolor(color.gray);
ORL.setStyle(curve.Long_DASH);
ORL.setlineweight(1);
FibMid.setdefaultcolor(color.gray);
FibMid.setStyle(curve.SHORT_DASH);
FibMid.setlineweight(1);
FibExtUp1.setdefaultcolor(color.gray);
FibExtUp1.setStyle(curve.SHORT_DASH);
FibExtUp1.setlineweight(1);
FibExtDown1.setdefaultcolor(color.gray);
FibExtDown1.setStyle(curve.SHORT_DASH);
FibExtDown1.setlineweight(1);
FibExtUp2.setdefaultcolor(color.gray);
FibExtUp2.setStyle(curve.SHORT_DASH);
FibExtUp2.setlineweight(1);
FibExtDown2.setdefaultcolor(color.gray);
FibExtDown2.setStyle(curve.SHORT_DASH);
FibExtDown2.setlineweight(1);
FibExtUp3.setdefaultcolor(color.gray);
FibExtUp3.setStyle(curve.SHORT_DASH);
FibExtUp3.setlineweight(1);
FibExtDown3.setdefaultcolor(color.gray);
FibExtDown3.setStyle(curve.SHORT_DASH);
FibExtDown3.setlineweight(1);

---
 
Last edited by a moderator:
Good Day and Happy February,
orginal study: https://usethinkscript.com/threads/...nkorswim-with-fibonacci-levels.29/#post-11740
I am seeking to know if it is possible to edit this code to extend lines horizontally automatically.

It is an ORB study so it is dependent on the time frame, but I am trying to have the target lines extended to the end of the day as soon as they are set - similar to any pivot point study.

Thank you for reading - and if so inclined to help, thank you in advance
---

#Opening Range Fibs
#Using the first candle to create Fib Support/Resist Levels
#Saw a Variation posted by BenTen, Decided to Edit to fit my needs
#Added Options to Hide/Show lines

input ORBegin = 0930;
input OREnd = 0945;
Input FibExt1 = 1.621;
Input FibExt2 = 2.621;
#Input FibExt3 = 4.121;
Input FibExt3 = 3.621;
#Input FibExt4 = 3.921;
Input ShowORH = yes;
Input ShowORL = yes;
Input ShowFibMid = yes;
Input ShowFibExt1 = yes;
Input ShowFibExt2 = yes;
Input ShowFibExt3 = yes;


input ShowTodayOnly={"No", default "Yes"};
def s=ShowTodayOnly;




Def ORActive = if secondstilltime(OREnd)>0 AND secondsfromtime(ORBegin)>=0 then 1 else 0;

Def today=if s==0 OR getday()==getlastday() AND secondsfromtime(ORBegin)>=0 then 1 else 0;

Def ORHigh = if ORHigh[1]==0 or ORActive[1]==0 AND ORActive==1 then high else if ORActive AND high>ORHigh[1] then high else ORHigh[1];

Def ORLow = if ORLow[1]==0 or ORActive[1]==0 AND ORActive==1 then low else if ORActive AND low<ORLow[1] then low else ORLow[1];

Def ORWidth = ORHigh - ORLow;


Def fib_mid = (ORHigh+ORLow)/2;
Def fib_ext_up1 = ORHigh + ORWidth*(FibExt1 - 1);
Def fib_ext_down1 = ORLow - ORWidth*(FibExt1 - 1);
Def fib_ext_up2= ORHigh + ORWidth*(FibExt2 - 1);
Def fib_ext_down2 = ORLow - ORWidth*(FibExt2 - 1);
Def fib_ext_up3= ORHigh + ORWidth*(FibExt3 - 1);
Def fib_ext_down3 = ORLow - ORWidth*(FibExt3 - 1);
#Def fib_ext_up4= ORHigh + ORWidth*(FibExt4 - 1);
#Def fib_ext_down4 = ORLow - ORWidth*(FibExt4 - 1);
#
# Define all the plots:
#
Plot ORH=if ORActive OR today < 1 OR !ShowORH then double.nan else ORHigh;
Plot ORL=if ORActive OR today < 1 or !ShowORL then double.nan else ORLow;
Plot FibMid=if ORActive OR today < 1 or !ShowFibMid then double.nan else fib_mid;
Plot FibExtUp1=if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_up1;
Plot FibExtDown1=if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_down1;
Plot FibExtUp2=if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_up2;
Plot FibExtDown2=if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_down2;
Plot FibExtUp3=if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_up3;
Plot FibExtDown3=if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_down3;
#Plot FibExtUp4=if ORActive OR today < 1 then double.nan else fib_ext_up3;
#Plot FibExtDown4=if ORActive OR today < 1 then double.nan else fib_ext_down3;


ORH.setdefaultcolor(color.gray);
ORH.setStyle(curve.Long_DASH);
ORH.setlineweight(1);
ORL.setdefaultcolor(color.gray);
ORL.setStyle(curve.Long_DASH);
ORL.setlineweight(1);
FibMid.setdefaultcolor(color.gray);
FibMid.setStyle(curve.SHORT_DASH);
FibMid.setlineweight(1);
FibExtUp1.setdefaultcolor(color.gray);
FibExtUp1.setStyle(curve.SHORT_DASH);
FibExtUp1.setlineweight(1);
FibExtDown1.setdefaultcolor(color.gray);
FibExtDown1.setStyle(curve.SHORT_DASH);
FibExtDown1.setlineweight(1);
FibExtUp2.setdefaultcolor(color.gray);
FibExtUp2.setStyle(curve.SHORT_DASH);
FibExtUp2.setlineweight(1);
FibExtDown2.setdefaultcolor(color.gray);
FibExtDown2.setStyle(curve.SHORT_DASH);
FibExtDown2.setlineweight(1);
FibExtUp3.setdefaultcolor(color.gray);
FibExtUp3.setStyle(curve.SHORT_DASH);
FibExtUp3.setlineweight(1);
FibExtDown3.setdefaultcolor(color.gray);
FibExtDown3.setStyle(curve.SHORT_DASH);
FibExtDown3.setlineweight(1);

---

there is an option to extend the lines or not

Code:
#orb_extend_lines_today_00

#https://usethinkscript.com/threads/seeking-code-to-extend-orb-target-lines-to-end-of-day.14456/
#Seeking code to Extend Orb Target lines to end of day

#Opening Range Fibs
#Using the first candle to create Fib Support/Resist Levels
#Saw a Variation posted by BenTen, Decided to Edit to fit my needs
#Added Options to Hide/Show lines

def na = double.nan;

input ORBegin = 0930;
input OREnd = 0945;
def dayend = 1600;

Input FibExt1 = 1.621;
Input FibExt2 = 2.621;
#Input FibExt3 = 4.121;
Input FibExt3 = 3.621;
#Input FibExt4 = 3.921;
Input ShowORH = yes;
Input ShowORL = yes;
Input ShowFibMid = yes;
Input ShowFibExt1 = yes;
Input ShowFibExt2 = yes;
Input ShowFibExt3 = yes;


input ShowTodayOnly = Yes;
def s = ShowTodayOnly;

input extend_lines = yes;

def daysafter = getday() > getlastday();
def daysbefore = getday() <= getlastday();

Def ORActive = if secondsfromtime(ORBegin) >= 0 and secondstilltime(OREnd) > 0 then 1 else 0;
Def today = if s == 0 OR getday()==getlastday() AND secondsfromtime(ORBegin)>=0 then 1 else 0;

Def ORHigh = if daysafter then na
 else if (extend_lines and isnan(close)) then ORHigh[1]
 else if ORHigh[1] == 0 or ORActive[1] == 0 AND ORActive == 1 then high
 else if ORActive AND high > ORHigh[1] then high
 else ORHigh[1];

Def ORLow = if daysafter then na
 else if (extend_lines and isnan(close)) then ORlow[1]
 else if ORLow[1] == 0 or ORActive[1] == 0 AND ORActive == 1 then low
 else if ORActive AND low < ORLow[1] then low
 else ORLow[1];

Def ORWidth = ORHigh - ORLow;


Def fib_mid = (ORHigh+ORLow)/2;
Def fib_ext_up1 = ORHigh + ORWidth*(FibExt1 - 1);
Def fib_ext_down1 = ORLow - ORWidth*(FibExt1 - 1);
Def fib_ext_up2= ORHigh + ORWidth*(FibExt2 - 1);
Def fib_ext_down2 = ORLow - ORWidth*(FibExt2 - 1);
Def fib_ext_up3= ORHigh + ORWidth*(FibExt3 - 1);
Def fib_ext_down3 = ORLow - ORWidth*(FibExt3 - 1);
#Def fib_ext_up4= ORHigh + ORWidth*(FibExt4 - 1);
#Def fib_ext_down4 = ORLow - ORWidth*(FibExt4 - 1);
#
# Define all the plots:
#
Plot ORH = if ORActive OR today < 1 OR !ShowORH then double.nan else ORHigh;
Plot ORL = if ORActive OR today < 1 or !ShowORL then double.nan else ORLow;
Plot FibMid = if ORActive OR today < 1 or !ShowFibMid then double.nan else fib_mid;
Plot FibExtUp1 = if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_up1;
Plot FibExtDown1 = if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_down1;
Plot FibExtUp2 = if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_up2;
Plot FibExtDown2 = if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_down2;
Plot FibExtUp3 = if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_up3;
Plot FibExtDown3 = if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_down3;
#Plot FibExtUp4=if ORActive OR today < 1 then double.nan else fib_ext_up3;
#Plot FibExtDown4=if ORActive OR today < 1 then double.nan else fib_ext_down3;


ORH.setdefaultcolor(color.light_gray);
ORH.setStyle(curve.Long_DASH);
ORH.setlineweight(1);
ORL.setdefaultcolor(color.light_gray);
ORL.setStyle(curve.Long_DASH);
ORL.setlineweight(1);
FibMid.setdefaultcolor(color.gray);
FibMid.setStyle(curve.SHORT_DASH);
FibMid.setlineweight(1);
FibExtUp1.setdefaultcolor(color.gray);
FibExtUp1.setStyle(curve.SHORT_DASH);
FibExtUp1.setlineweight(1);
FibExtDown1.setdefaultcolor(color.gray);
FibExtDown1.setStyle(curve.SHORT_DASH);
FibExtDown1.setlineweight(1);
FibExtUp2.setdefaultcolor(color.gray);
FibExtUp2.setStyle(curve.SHORT_DASH);
FibExtUp2.setlineweight(1);
FibExtDown2.setdefaultcolor(color.gray);
FibExtDown2.setStyle(curve.SHORT_DASH);
FibExtDown2.setlineweight(1);
FibExtUp3.setdefaultcolor(color.gray);
FibExtUp3.setStyle(curve.SHORT_DASH);
FibExtUp3.setlineweight(1);
FibExtDown3.setdefaultcolor(color.gray);
FibExtDown3.setStyle(curve.SHORT_DASH);
FibExtDown3.setlineweight(1);

#------------------------------
# test stuff

addchartbubble(0, 150,
 getday() + "\n" +
 getlastday() + "\n" +
 daysafter + "\n" +
 daysbefore
#orhigh + "\n" +
#orlow
, color.yellow, no);


addchartbubble(0, 150,
orhigh + "\n" +
orlow
, color.yellow, no);

#Def daytime = if (secondsfromtime(ORBegin)>=0 and secondstilltime(dayend)>0 ) then 1 else 0;
#def daytimex = (isnan(close) and daytime);
#def currentday = getday()==getlastday();
#
#

ULLzmkb.jpg
 

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

there is an option to extend the lines or not

Code:
#orb_extend_lines_today_00

#https://usethinkscript.com/threads/seeking-code-to-extend-orb-target-lines-to-end-of-day.14456/
#Seeking code to Extend Orb Target lines to end of day

#Opening Range Fibs
#Using the first candle to create Fib Support/Resist Levels
#Saw a Variation posted by BenTen, Decided to Edit to fit my needs
#Added Options to Hide/Show lines

def na = double.nan;

input ORBegin = 0930;
input OREnd = 0945;
def dayend = 1600;

Input FibExt1 = 1.621;
Input FibExt2 = 2.621;
#Input FibExt3 = 4.121;
Input FibExt3 = 3.621;
#Input FibExt4 = 3.921;
Input ShowORH = yes;
Input ShowORL = yes;
Input ShowFibMid = yes;
Input ShowFibExt1 = yes;
Input ShowFibExt2 = yes;
Input ShowFibExt3 = yes;


input ShowTodayOnly = Yes;
def s = ShowTodayOnly;

input extend_lines = yes;

def daysafter = getday() > getlastday();
def daysbefore = getday() <= getlastday();

Def ORActive = if secondsfromtime(ORBegin) >= 0 and secondstilltime(OREnd) > 0 then 1 else 0;
Def today = if s == 0 OR getday()==getlastday() AND secondsfromtime(ORBegin)>=0 then 1 else 0;

Def ORHigh = if daysafter then na
 else if (extend_lines and isnan(close)) then ORHigh[1]
 else if ORHigh[1] == 0 or ORActive[1] == 0 AND ORActive == 1 then high
 else if ORActive AND high > ORHigh[1] then high
 else ORHigh[1];

Def ORLow = if daysafter then na
 else if (extend_lines and isnan(close)) then ORlow[1]
 else if ORLow[1] == 0 or ORActive[1] == 0 AND ORActive == 1 then low
 else if ORActive AND low < ORLow[1] then low
 else ORLow[1];

Def ORWidth = ORHigh - ORLow;


Def fib_mid = (ORHigh+ORLow)/2;
Def fib_ext_up1 = ORHigh + ORWidth*(FibExt1 - 1);
Def fib_ext_down1 = ORLow - ORWidth*(FibExt1 - 1);
Def fib_ext_up2= ORHigh + ORWidth*(FibExt2 - 1);
Def fib_ext_down2 = ORLow - ORWidth*(FibExt2 - 1);
Def fib_ext_up3= ORHigh + ORWidth*(FibExt3 - 1);
Def fib_ext_down3 = ORLow - ORWidth*(FibExt3 - 1);
#Def fib_ext_up4= ORHigh + ORWidth*(FibExt4 - 1);
#Def fib_ext_down4 = ORLow - ORWidth*(FibExt4 - 1);
#
# Define all the plots:
#
Plot ORH = if ORActive OR today < 1 OR !ShowORH then double.nan else ORHigh;
Plot ORL = if ORActive OR today < 1 or !ShowORL then double.nan else ORLow;
Plot FibMid = if ORActive OR today < 1 or !ShowFibMid then double.nan else fib_mid;
Plot FibExtUp1 = if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_up1;
Plot FibExtDown1 = if ORActive OR today < 1 or !ShowFibExt1 then double.nan else fib_ext_down1;
Plot FibExtUp2 = if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_up2;
Plot FibExtDown2 = if ORActive OR today < 1 or !ShowFibExt2 then double.nan else fib_ext_down2;
Plot FibExtUp3 = if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_up3;
Plot FibExtDown3 = if ORActive OR today < 1 or !ShowFibExt3 then double.nan else fib_ext_down3;
#Plot FibExtUp4=if ORActive OR today < 1 then double.nan else fib_ext_up3;
#Plot FibExtDown4=if ORActive OR today < 1 then double.nan else fib_ext_down3;


ORH.setdefaultcolor(color.light_gray);
ORH.setStyle(curve.Long_DASH);
ORH.setlineweight(1);
ORL.setdefaultcolor(color.light_gray);
ORL.setStyle(curve.Long_DASH);
ORL.setlineweight(1);
FibMid.setdefaultcolor(color.gray);
FibMid.setStyle(curve.SHORT_DASH);
FibMid.setlineweight(1);
FibExtUp1.setdefaultcolor(color.gray);
FibExtUp1.setStyle(curve.SHORT_DASH);
FibExtUp1.setlineweight(1);
FibExtDown1.setdefaultcolor(color.gray);
FibExtDown1.setStyle(curve.SHORT_DASH);
FibExtDown1.setlineweight(1);
FibExtUp2.setdefaultcolor(color.gray);
FibExtUp2.setStyle(curve.SHORT_DASH);
FibExtUp2.setlineweight(1);
FibExtDown2.setdefaultcolor(color.gray);
FibExtDown2.setStyle(curve.SHORT_DASH);
FibExtDown2.setlineweight(1);
FibExtUp3.setdefaultcolor(color.gray);
FibExtUp3.setStyle(curve.SHORT_DASH);
FibExtUp3.setlineweight(1);
FibExtDown3.setdefaultcolor(color.gray);
FibExtDown3.setStyle(curve.SHORT_DASH);
FibExtDown3.setlineweight(1);

#------------------------------
# test stuff

addchartbubble(0, 150,
 getday() + "\n" +
 getlastday() + "\n" +
 daysafter + "\n" +
 daysbefore
#orhigh + "\n" +
#orlow
, color.yellow, no);


addchartbubble(0, 150,
orhigh + "\n" +
orlow
, color.yellow, no);

#Def daytime = if (secondsfromtime(ORBegin)>=0 and secondstilltime(dayend)>0 ) then 1 else 0;
#def daytimex = (isnan(close) and daytime);
#def currentday = getday()==getlastday();
#
#

ULLzmkb.jpg
A sizeable Thank you for your support and post! Please have a great weekend!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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