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);
---
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: