what you are asking for is an ORB studyHi,
Can some please assist on a TOS code to draw a horizontal line of the high & low of the first 15mins candlestick after the stock market opens please? Much thanks!
P.S. I do NOT know much about coding![]()
#orbs_05_cln
#http://tos.mx/qJhPhgr
# halcyonguy
# 2021-09
# ORB, opening range levels
def na = Double.NaN;
input timeframe = { t1min , t2min , t3min , t5min , t10min , t15min , default t30min };
input show_ORB_label = yes;
input show_range_lines = no;
def srl = show_range_lines;
input orb_range_lines_pricepercent = 16;
# % of the...
what you are asking for is an ORB studyHi,
Can some please assist on a TOS code to draw a horizontal line of the high & low of the first 15mins candlestick after the stock market opens please? Much thanks!
P.S. I do NOT know much about coding![]()
#orbs_05_cln
#http://tos.mx/qJhPhgr
# halcyonguy
# 2021-09
# ORB, opening range levels
def na = Double.NaN;
input timeframe = { t1min , t2min , t3min , t5min , t10min , t15min , default t30min };
input show_ORB_label = yes;
input show_range_lines = no;
def srl = show_range_lines;
input orb_range_lines_pricepercent = 16;
# % of the diff of upper line - lower line
def olpp = orb_range_lines_pricepercent;
input show_arrows = yes;
def period = AggregationPeriod.day;
# open/close times (ET)
input start = 0930;
input end = 1600;
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;
def agg;
def per;
switch (timeframe) {
# add t1min , t2min , t3min , t4min ,
case t1min:
agg = AggregationPeriod.MIN;
per = 1;
case t2min:
agg = AggregationPeriod.two_MIN;
per = 2;
case t3min:
agg = AggregationPeriod.three_MIN;
per = 3;
#case t4min:
# agg = AggregationPeriod.FOUR_MIN;
# per = 4;
case t5min:
agg = AggregationPeriod.fIVE_MIN;
per = 5;
case t10min:
agg = AggregationPeriod.Ten_MIN;
per = 10;
case t15min:
agg = AggregationPeriod.FIFTEEN_MIN;
per = 15;
#case t20min:
# agg = AggregationPeriod.FIFTEEN_MIN;
# per = 20;
case t30min:
agg = AggregationPeriod.THIRTY_MIN;
per = 30;
#case t60min:
# agg = AggregationPeriod.hOUR;
# per = 60;
#default:
# agg = aggregationPeriod.FIFTEEN_MIN;
}
addlabel(show_ORB_label, per + " ORB" , color.cyan);
# get candle width , seconds , timeframe
#def getaggmin = round(getaggregationPeriod()/60,0);
def getgg = getaggregationPeriod();
def getaggmin = round(getgg/60,0);
# test if agg time is > than chart time
def aggok = if (getaggmin*60) <= agg then 1 else 0;
def durationsec = per * 60;
def secondspassed = secondsfromTime(start);
# simulated firstbar , based on orb time
def firstbar = if secondspassed >= 0 and secondspassed < durationsec then 1 else 0;
#addchartbubble(yes,low,per + "__" + firstbar + "__" + agg);
def afterfirst = if ( daytime and !firstbar ) then 1 else 0;
# is this the first bar after open ?
def openbar = if secondspassed >= 0 and secondspassed <= getgg then 1 else 0;
def ehi = high(period = agg);
def elo = low(period = agg);
# looks at firstbar , which is orbtime , NOT bar[1]
def perhigh = if !daytime then na else if firstbar then ehi else perhigh[1];
def perlow = if !daytime then na else if firstbar then elo else perlow[1];
# .....................................................
# calc % tolerance levels within orb lines
# def olpp = orblines_pricepercent;
def linediff = perhigh - perlow;
def orbperamt = linediff * (olpp/100);
def orbupperper = perhigh - orbperamt;
def orblowerper = perlow + orbperamt;
def upperrng = if ( close < perhigh and close > orbupperper) then 1 else 0;
def lowerrng = if ( close > perlow and close < orblowerper) then 1 else 0;
addlabel(upperrng,"upper range", color.green);
addlabel(lowerrng,"lower range", color.red);
# def srl = show_range_lines;
# draw lines at x% within orb lines
# plot dots for first bar timeframe
plot hiperdots = if (srl and daytime) then orbupperper else na;
plot loperdots = if (srl and daytime) then orblowerper else na;
hiperdots.setpaintingStrategy(paintingStrategy.points);
loperdots.setpaintingStrategy(paintingStrategy.pointS);
hiperdots.setDefaultColor(color.violet);
loperdots.setDefaultColor(color.violet);
hiperdots.hidebubble();
loperdots.hidebubble();
# .....................................................
# add label if beyond orb range
addlabel((close > perhigh),"above upper line", color.green);
addlabel((close < perlow),"below lower line", color.red);
# .....................................................
# plot dots for first bar timeframe
plot hidots = if firstbar then perhigh else na;
plot lodots = if firstbar then perlow else na;
hidots.setpaintingStrategy(paintingStrategy.points);
lodots.setpaintingStrategy(paintingStrategy.pointS);
hidots.setDefaultColor(color.yellow);
lodots.setDefaultColor(color.yellow);
# plot line after first bar
plot hiline = if !firstbar then perhigh else na;
plot loline = if !firstbar then perlow else na;
hiline.setpaintingStrategy(paintingStrategy.line);
loline.setpaintingStrategy(paintingStrategy.line);
hiline.setDefaultColor(color.yellow);
loline.setDefaultColor(color.yellow);
def afterabove = if (show_arrows and (close crosses above perhigh)) then 1 else 0;
def afterbelow = if (show_arrows and (close crosses below perlow)) then 1 else 0;
# plot arrows on crossover points
def vfac5 = .0014;
plot upline = if afterabove then min( low , (hiline * (1 - vfac5))) else na;
plot dwnline = if afterbelow then max(high, (loline * (1 + vfac5))) else na;
upline.setPaintingStrategy(paintingStrategy.ARROW_UP);
dwnline.setPaintingStrategy(paintingStrategy.ARROW_down);
upline.setDefaultColor(color.cyan);
dwnline.setDefaultColor(color.cyan);
upline.setlineWeight(4);
dwnline.setlineWeight(4);
upline.hideBubble();
dwnline.hideBubble();
#
Hi, I love this. Of course I started to customize it for me and I added a chart label that measured the gap between the High and the Low, sort of a ATR. Then (and this is where I really need your opinion on this) to have a second ORB at the 12:30 - 1:30 time, however it just doesn't seem to work, I'm sure it's me. I'm thinking much like a Anchored Vwap. We need to adjust our game for the afternoon. Does this make sense and if it does could you help with this code because for some reason the dots don't line up with the plotted lines and I noticed if I change the stock ticker sometimes it works (sort of) and other time it's way off. I was thinking to have a separate script for the morning (your original) and then a modified script for the afternoon. Here's the code:what you are asking for is an ORB study
https://usethinkscript.com/search/1840985/?q=orb&o=date
here is one i made
change the time to 15min
it draws an arrow when a line is crossed
Code:#orbs_05_cln #http://tos.mx/qJhPhgr # halcyonguy # 2021-09 # ORB, opening range levels def na = Double.NaN; input timeframe = { t1min , t2min , t3min , t5min , t10min , t15min , default t30min }; input show_ORB_label = yes; input show_range_lines = no; def srl = show_range_lines; input orb_range_lines_pricepercent = 16; # % of the diff of upper line - lower line def olpp = orb_range_lines_pricepercent; input show_arrows = yes; def period = AggregationPeriod.day; # open/close times (ET) input start = 0930; input end = 1600; def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0; def agg; def per; switch (timeframe) { # add t1min , t2min , t3min , t4min , case t1min: agg = AggregationPeriod.MIN; per = 1; case t2min: agg = AggregationPeriod.two_MIN; per = 2; case t3min: agg = AggregationPeriod.three_MIN; per = 3; #case t4min: # agg = AggregationPeriod.FOUR_MIN; # per = 4; case t5min: agg = AggregationPeriod.fIVE_MIN; per = 5; case t10min: agg = AggregationPeriod.Ten_MIN; per = 10; case t15min: agg = AggregationPeriod.FIFTEEN_MIN; per = 15; #case t20min: # agg = AggregationPeriod.FIFTEEN_MIN; # per = 20; case t30min: agg = AggregationPeriod.THIRTY_MIN; per = 30; #case t60min: # agg = AggregationPeriod.hOUR; # per = 60; #default: # agg = aggregationPeriod.FIFTEEN_MIN; } addlabel(show_ORB_label, per + " ORB" , color.cyan); # get candle width , seconds , timeframe #def getaggmin = round(getaggregationPeriod()/60,0); def getgg = getaggregationPeriod(); def getaggmin = round(getgg/60,0); # test if agg time is > than chart time def aggok = if (getaggmin*60) <= agg then 1 else 0; def durationsec = per * 60; def secondspassed = secondsfromTime(start); # simulated firstbar , based on orb time def firstbar = if secondspassed >= 0 and secondspassed < durationsec then 1 else 0; #addchartbubble(yes,low,per + "__" + firstbar + "__" + agg); def afterfirst = if ( daytime and !firstbar ) then 1 else 0; # is this the first bar after open ? def openbar = if secondspassed >= 0 and secondspassed <= getgg then 1 else 0; def ehi = high(period = agg); def elo = low(period = agg); # looks at firstbar , which is orbtime , NOT bar[1] def perhigh = if !daytime then na else if firstbar then ehi else perhigh[1]; def perlow = if !daytime then na else if firstbar then elo else perlow[1]; # ..................................................... # calc % tolerance levels within orb lines # def olpp = orblines_pricepercent; def linediff = perhigh - perlow; def orbperamt = linediff * (olpp/100); def orbupperper = perhigh - orbperamt; def orblowerper = perlow + orbperamt; def upperrng = if ( close < perhigh and close > orbupperper) then 1 else 0; def lowerrng = if ( close > perlow and close < orblowerper) then 1 else 0; addlabel(upperrng,"upper range", color.green); addlabel(lowerrng,"lower range", color.red); # def srl = show_range_lines; # draw lines at x% within orb lines # plot dots for first bar timeframe plot hiperdots = if (srl and daytime) then orbupperper else na; plot loperdots = if (srl and daytime) then orblowerper else na; hiperdots.setpaintingStrategy(paintingStrategy.points); loperdots.setpaintingStrategy(paintingStrategy.pointS); hiperdots.setDefaultColor(color.violet); loperdots.setDefaultColor(color.violet); hiperdots.hidebubble(); loperdots.hidebubble(); # ..................................................... # add label if beyond orb range addlabel((close > perhigh),"above upper line", color.green); addlabel((close < perlow),"below lower line", color.red); # ..................................................... # plot dots for first bar timeframe plot hidots = if firstbar then perhigh else na; plot lodots = if firstbar then perlow else na; hidots.setpaintingStrategy(paintingStrategy.points); lodots.setpaintingStrategy(paintingStrategy.pointS); hidots.setDefaultColor(color.yellow); lodots.setDefaultColor(color.yellow); # plot line after first bar plot hiline = if !firstbar then perhigh else na; plot loline = if !firstbar then perlow else na; hiline.setpaintingStrategy(paintingStrategy.line); loline.setpaintingStrategy(paintingStrategy.line); hiline.setDefaultColor(color.yellow); loline.setDefaultColor(color.yellow); def afterabove = if (show_arrows and (close crosses above perhigh)) then 1 else 0; def afterbelow = if (show_arrows and (close crosses below perlow)) then 1 else 0; # plot arrows on crossover points def vfac5 = .0014; plot upline = if afterabove then min( low , (hiline * (1 - vfac5))) else na; plot dwnline = if afterbelow then max(high, (loline * (1 + vfac5))) else na; upline.setPaintingStrategy(paintingStrategy.ARROW_UP); dwnline.setPaintingStrategy(paintingStrategy.ARROW_down); upline.setDefaultColor(color.cyan); dwnline.setDefaultColor(color.cyan); upline.setlineWeight(4); dwnline.setlineWeight(4); upline.hideBubble(); dwnline.hideBubble(); #
Hi, I love this. Of course I started to customize it for me and I added a chart label that measured the gap between the High and the Low, sort of a ATR. Then (and this is where I really need your opinion on this) to have a second ORB at the 12:30 - 1:30 time, however it just doesn't seem to work, I'm sure it's me. I'm thinking much like a Anchored Vwap. We need to adjust our game for the afternoon. Does this make sense and if it does could you help with this code because for some reason the dots don't line up with the plotted lines and I noticed if I change the stock ticker sometimes it works (sort of) and other time it's way off. I was thinking to have a separate script for the morning (your original) and then a modified script for the afternoon. Here's the code:
#orbs_05_cln
#http://tos.mx/qJhPhgr
#Found at: https://usethinkscript.com/threads/...ns-after-stock-market-opens.20525/post-151022
# halcyonguy
# 2021-09
# ORB, opening range levels
def na = Double.NaN;
input timeframe = { t1min , t2min , t3min , t5min , t10min , t15min ,t60min, default t30min };
input show_ORB_label = yes;
input show_range_lines = no;
def srl = show_range_lines;
input orb_range_lines_pricepercent = 16;
# % of the diff of upper line - lower line
def olpp = orb_range_lines_pricepercent;
input show_arrows = yes;
def period = AggregationPeriod.day;
# open/close times (ET)
input start = 1230;
input end = 1600;
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;
def agg;
def per;
switch (timeframe) {
# add t1min , t2min , t3min , t4min ,
case t1min:
agg = AggregationPeriod.MIN;
per = 1;
case t2min:
agg = AggregationPeriod.two_MIN;
per = 2;
case t3min:
agg = AggregationPeriod.three_MIN;
per = 3;
#case t4min:
# agg = AggregationPeriod.FOUR_MIN;
# per = 4;
case t5min:
agg = AggregationPeriod.fIVE_MIN;
per = 5;
case t10min:
agg = AggregationPeriod.Ten_MIN;
per = 10;
case t15min:
agg = AggregationPeriod.FIFTEEN_MIN;
per = 15;
#case t20min:
# agg = AggregationPeriod.FIFTEEN_MIN;
# per = 20;
case t30min:
agg = AggregationPeriod.THIRTY_MIN;
per = 30;
case t60min:
agg = AggregationPeriod.hour;
per = 60;
#default:
#agg = aggregationPeriod.FIFTEEN_MIN;
}
addlabel(show_ORB_label, per + " ORB" , color.cyan);
# get candle width , seconds , timeframe
#def getaggmin = round(getaggregationPeriod()/60,0);
def getgg = getaggregationPeriod();
def getaggmin = round(getgg/60,0);
# test if agg time is > than chart time
def aggok = if (getaggmin*60) <= agg then 1 else 0;
def durationsec = per * 60;
def secondspassed = secondsfromTime(start);
# simulated firstbar , based on orb time
def firstbar = if secondspassed >= 0 and secondspassed < durationsec then 1 else 0;
#addchartbubble(yes,low,per + "" + firstbar + "" + agg);
def afterfirst = if ( daytime and !firstbar ) then 1 else 0;
# is this the first bar after open ?
def openbar = if secondspassed >= 0 and secondspassed <= getgg then 1 else 0;
def ehi = high(period = agg);
def elo = low(period = agg);
# looks at firstbar , which is orbtime , NOT bar[1]
def perhigh = if !daytime then na else if firstbar then ehi else perhigh[1];
def perlow = if !daytime then na else if firstbar then elo else perlow[1];
# .....................................................
# calc % tolerance levels within orb lines
# def olpp = orblines_pricepercent;
def linediff = perhigh - perlow;
def orbperamt = linediff * (olpp/100);
def orbupperper = perhigh - orbperamt;
def orblowerper = perlow + orbperamt;
def upperrng = if ( close < perhigh and close > orbupperper) then 1 else 0;
def lowerrng = if ( close > perlow and close < orblowerper) then 1 else 0;
#addlabel(upperrng,"upper range", color.green);
#addlabel(lowerrng,"lower range", color.red);
# def srl = show_range_lines;
# draw lines at x% within orb lines
# plot dots for first bar timeframe
plot hiperdots = if (srl and daytime) then orbupperper else na;
plot loperdots = if (srl and daytime) then orblowerper else na;
hiperdots.setpaintingStrategy(paintingStrategy.points);
loperdots.setpaintingStrategy(paintingStrategy.pointS);
hiperdots.setDefaultColor(color.violet);
loperdots.setDefaultColor(color.violet);
hiperdots.hidebubble();
loperdots.hidebubble();
# .....................................................
# add label if beyond orb range
#addlabel((close > perhigh),"above upper line", color.green);
#addlabel((close < perlow),"below lower line", color.red);
# .....................................................
# plot dots for first bar timeframe
plot hidots = if firstbar then perhigh else na;
plot lodots = if firstbar then perlow else na;
hidots.setpaintingStrategy(paintingStrategy.points);
lodots.setpaintingStrategy(paintingStrategy.pointS);
hidots.setDefaultColor(color.yellow);
lodots.setDefaultColor(color.yellow);
# plot line after first bar
plot hiline = if !firstbar then perhigh else na;
plot loline = if !firstbar then perlow else na;
hiline.setpaintingStrategy(paintingStrategy.line);
loline.setpaintingStrategy(paintingStrategy.line);
hiline.setDefaultColor(color.yellow);
loline.setDefaultColor(color.yellow);
def afterabove = if (show_arrows and (close crosses above perhigh)) then 1 else 0;
def afterbelow = if (show_arrows and (close crosses below perlow)) then 1 else 0;
# plot arrows on crossover points
def vfac5 = .0014;
plot upline = if afterabove then min( low , (hiline * (1 - vfac5))) else na;
plot dwnline = if afterbelow then max(high, (loline * (1 + vfac5))) else na;
upline.setPaintingStrategy(paintingStrategy.ARROW_UP);
dwnline.setPaintingStrategy(paintingStrategy.ARROW_down);
upline.setDefaultColor(color.cyan);
dwnline.setDefaultColor(color.cyan);
upline.setlineWeight(4);
dwnline.setlineWeight(4);
upline.hideBubble();
dwnline.hideBubble();
# END
#---------Added Chart Label that shows the difference between H+L
def diff = hiline - loline;
#AddLabel(1, "HLgap " + AsDollars(diff),
#if diff > 0.31 then Color.Green else if diff < 0.30 and diff > 0.20
# then Color.Yellow else color.light_gray);
AddLabel(1, "H>" + AsDollars(diff) + "<L",
if diff > 0.31 then Color.Green else if diff < 0.30 and diff > 0.20
then Color.Yellow else color.light_gray);
#orbs_05_cln
#http://tos.mx/qJhPhgr
#Found at: https://usethinkscript.com/threads/...ns-after-stock-market-opens.20525/post-151022
# halcyonguy
# 2021-09
# ORB, opening range levels
def na = Double.NaN;
input timeframe = { t1min , t2min , t3min , t5min , t10min , t15min ,t60min, default t30min };
input show_ORB_label = yes;
input show_range_lines = no;
def srl = show_range_lines;
input orb_range_lines_pricepercent = 16;
# % of the diff of upper line - lower line
def olpp = orb_range_lines_pricepercent;
input show_arrows = yes;
def period = AggregationPeriod.day;
# open/close times (ET)
input start = 1230;
input end = 1600;
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;
def agg;
def per;
switch (timeframe) {
# add t1min , t2min , t3min , t4min ,
case t1min:
agg = AggregationPeriod.MIN;
per = 1;
case t2min:
agg = AggregationPeriod.two_MIN;
per = 2;
case t3min:
agg = AggregationPeriod.three_MIN;
per = 3;
#case t4min:
# agg = AggregationPeriod.FOUR_MIN;
# per = 4;
case t5min:
agg = AggregationPeriod.fIVE_MIN;
per = 5;
case t10min:
agg = AggregationPeriod.Ten_MIN;
per = 10;
case t15min:
agg = AggregationPeriod.FIFTEEN_MIN;
per = 15;
#case t20min:
# agg = AggregationPeriod.FIFTEEN_MIN;
# per = 20;
case t30min:
agg = AggregationPeriod.THIRTY_MIN;
per = 30;
case t60min:
agg = AggregationPeriod.hour;
per = 60;
#default:
#agg = aggregationPeriod.FIFTEEN_MIN;
}
addlabel(show_ORB_label, per + " ORB" , color.cyan);
# get candle width , seconds , timeframe
#def getaggmin = round(getaggregationPeriod()/60,0);
def getgg = getaggregationPeriod();
def getaggmin = round(getgg/60,0);
# test if agg time is > than chart time
def aggok = if (getaggmin*60) <= agg then 1 else 0;
def durationsec = per * 60;
def secondspassed = secondsfromTime(start);
# simulated firstbar , based on orb time
def firstbar = if secondspassed >= 0 and secondspassed < durationsec then 1 else 0;
#addchartbubble(yes,low,per + "" + firstbar + "" + agg);
def afterfirst = if ( daytime and !firstbar ) then 1 else 0;
# is this the first bar after open ?
def openbar = if secondspassed >= 0 and secondspassed <= getgg then 1 else 0;
def ehi = high(period = agg);
def elo = low(period = agg);
# looks at firstbar , which is orbtime , NOT bar[1]
def perhigh = if !daytime then na else if firstbar then ehi else perhigh[1];
def perlow = if !daytime then na else if firstbar then elo else perlow[1];
# .....................................................
# calc % tolerance levels within orb lines
# def olpp = orblines_pricepercent;
def linediff = perhigh - perlow;
def orbperamt = linediff * (olpp/100);
def orbupperper = perhigh - orbperamt;
def orblowerper = perlow + orbperamt;
def upperrng = if ( close < perhigh and close > orbupperper) then 1 else 0;
def lowerrng = if ( close > perlow and close < orblowerper) then 1 else 0;
#addlabel(upperrng,"upper range", color.green);
#addlabel(lowerrng,"lower range", color.red);
# def srl = show_range_lines;
# draw lines at x% within orb lines
# plot dots for first bar timeframe
plot hiperdots = if (srl and daytime) then orbupperper else na;
plot loperdots = if (srl and daytime) then orblowerper else na;
hiperdots.setpaintingStrategy(paintingStrategy.points);
loperdots.setpaintingStrategy(paintingStrategy.pointS);
hiperdots.setDefaultColor(color.violet);
loperdots.setDefaultColor(color.violet);
hiperdots.hidebubble();
loperdots.hidebubble();
# .....................................................
# add label if beyond orb range
#addlabel((close > perhigh),"above upper line", color.green);
#addlabel((close < perlow),"below lower line", color.red);
# .....................................................
# plot dots for first bar timeframe
plot hidots = if firstbar then perhigh else na;
plot lodots = if firstbar then perlow else na;
hidots.setpaintingStrategy(paintingStrategy.points);
lodots.setpaintingStrategy(paintingStrategy.pointS);
hidots.setDefaultColor(color.yellow);
lodots.setDefaultColor(color.yellow);
# plot line after first bar
plot hiline = if !firstbar then perhigh else na;
plot loline = if !firstbar then perlow else na;
hiline.setpaintingStrategy(paintingStrategy.line);
loline.setpaintingStrategy(paintingStrategy.line);
hiline.setDefaultColor(color.yellow);
loline.setDefaultColor(color.yellow);
def afterabove = if (show_arrows and (close crosses above perhigh)) then 1 else 0;
def afterbelow = if (show_arrows and (close crosses below perlow)) then 1 else 0;
# plot arrows on crossover points
def vfac5 = .0014;
plot upline = if afterabove then min( low , (hiline * (1 - vfac5))) else na;
plot dwnline = if afterbelow then max(high, (loline * (1 + vfac5))) else na;
upline.setPaintingStrategy(paintingStrategy.ARROW_UP);
dwnline.setPaintingStrategy(paintingStrategy.ARROW_down);
upline.setDefaultColor(color.cyan);
dwnline.setDefaultColor(color.cyan);
upline.setlineWeight(4);
dwnline.setlineWeight(4);
upline.hideBubble();
dwnline.hideBubble();
# END
#---------Added Chart Label that shows the difference between H+L
def diff = hiline - loline;
#AddLabel(1, "HLgap " + AsDollars(diff),
#if diff > 0.31 then Color.Green else if diff < 0.30 and diff > 0.20
# then Color.Yellow else color.light_gray);
AddLabel(1, "H>" + AsDollars(diff) + "<L",
if diff > 0.31 then Color.Green else if diff < 0.30 and diff > 0.20
then Color.Yellow else color.light_gray);
Halcyonguy, I had found your ORB study after and have been using it. I find it much simpler to understand and less clutter. One thing I was working on is a PM ORB study, I have two charts one AM and the other PM where I just changed the time and color of the lines for identification. But I don't know if as valuable yet. So thanks for a concise Thinkscript!what you are asking for is an ORB study
https://usethinkscript.com/search/1840985/?q=orb&o=date
here is one i made
change the time to 15min
it draws an arrow when a line is crossed
Code:#orbs_05_cln #http://tos.mx/qJhPhgr # halcyonguy # 2021-09 # ORB, opening range levels def na = Double.NaN; input timeframe = { t1min , t2min , t3min , t5min , t10min , t15min , default t30min }; input show_ORB_label = yes; input show_range_lines = no; def srl = show_range_lines; input orb_range_lines_pricepercent = 16; # % of the diff of upper line - lower line def olpp = orb_range_lines_pricepercent; input show_arrows = yes; def period = AggregationPeriod.day; # open/close times (ET) input start = 0930; input end = 1600; def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0; def agg; def per; switch (timeframe) { # add t1min , t2min , t3min , t4min , case t1min: agg = AggregationPeriod.MIN; per = 1; case t2min: agg = AggregationPeriod.two_MIN; per = 2; case t3min: agg = AggregationPeriod.three_MIN; per = 3; #case t4min: # agg = AggregationPeriod.FOUR_MIN; # per = 4; case t5min: agg = AggregationPeriod.fIVE_MIN; per = 5; case t10min: agg = AggregationPeriod.Ten_MIN; per = 10; case t15min: agg = AggregationPeriod.FIFTEEN_MIN; per = 15; #case t20min: # agg = AggregationPeriod.FIFTEEN_MIN; # per = 20; case t30min: agg = AggregationPeriod.THIRTY_MIN; per = 30; #case t60min: # agg = AggregationPeriod.hOUR; # per = 60; #default: # agg = aggregationPeriod.FIFTEEN_MIN; } addlabel(show_ORB_label, per + " ORB" , color.cyan); # get candle width , seconds , timeframe #def getaggmin = round(getaggregationPeriod()/60,0); def getgg = getaggregationPeriod(); def getaggmin = round(getgg/60,0); # test if agg time is > than chart time def aggok = if (getaggmin*60) <= agg then 1 else 0; def durationsec = per * 60; def secondspassed = secondsfromTime(start); # simulated firstbar , based on orb time def firstbar = if secondspassed >= 0 and secondspassed < durationsec then 1 else 0; #addchartbubble(yes,low,per + "__" + firstbar + "__" + agg); def afterfirst = if ( daytime and !firstbar ) then 1 else 0; # is this the first bar after open ? def openbar = if secondspassed >= 0 and secondspassed <= getgg then 1 else 0; def ehi = high(period = agg); def elo = low(period = agg); # looks at firstbar , which is orbtime , NOT bar[1] def perhigh = if !daytime then na else if firstbar then ehi else perhigh[1]; def perlow = if !daytime then na else if firstbar then elo else perlow[1]; # ..................................................... # calc % tolerance levels within orb lines # def olpp = orblines_pricepercent; def linediff = perhigh - perlow; def orbperamt = linediff * (olpp/100); def orbupperper = perhigh - orbperamt; def orblowerper = perlow + orbperamt; def upperrng = if ( close < perhigh and close > orbupperper) then 1 else 0; def lowerrng = if ( close > perlow and close < orblowerper) then 1 else 0; addlabel(upperrng,"upper range", color.green); addlabel(lowerrng,"lower range", color.red); # def srl = show_range_lines; # draw lines at x% within orb lines # plot dots for first bar timeframe plot hiperdots = if (srl and daytime) then orbupperper else na; plot loperdots = if (srl and daytime) then orblowerper else na; hiperdots.setpaintingStrategy(paintingStrategy.points); loperdots.setpaintingStrategy(paintingStrategy.pointS); hiperdots.setDefaultColor(color.violet); loperdots.setDefaultColor(color.violet); hiperdots.hidebubble(); loperdots.hidebubble(); # ..................................................... # add label if beyond orb range addlabel((close > perhigh),"above upper line", color.green); addlabel((close < perlow),"below lower line", color.red); # ..................................................... # plot dots for first bar timeframe plot hidots = if firstbar then perhigh else na; plot lodots = if firstbar then perlow else na; hidots.setpaintingStrategy(paintingStrategy.points); lodots.setpaintingStrategy(paintingStrategy.pointS); hidots.setDefaultColor(color.yellow); lodots.setDefaultColor(color.yellow); # plot line after first bar plot hiline = if !firstbar then perhigh else na; plot loline = if !firstbar then perlow else na; hiline.setpaintingStrategy(paintingStrategy.line); loline.setpaintingStrategy(paintingStrategy.line); hiline.setDefaultColor(color.yellow); loline.setDefaultColor(color.yellow); def afterabove = if (show_arrows and (close crosses above perhigh)) then 1 else 0; def afterbelow = if (show_arrows and (close crosses below perlow)) then 1 else 0; # plot arrows on crossover points def vfac5 = .0014; plot upline = if afterabove then min( low , (hiline * (1 - vfac5))) else na; plot dwnline = if afterbelow then max(high, (loline * (1 + vfac5))) else na; upline.setPaintingStrategy(paintingStrategy.ARROW_UP); dwnline.setPaintingStrategy(paintingStrategy.ARROW_down); upline.setDefaultColor(color.cyan); dwnline.setDefaultColor(color.cyan); upline.setlineWeight(4); dwnline.setlineWeight(4); upline.hideBubble(); dwnline.hideBubble(); #
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
T | Draw a lines between two points | Questions | 2 | |
M | Draw high low wick high and low of a particular candle | Questions | 2 | |
S | draw a high and low line based on 3-4PM price action | Questions | 1 | |
![]() |
Wanted: Draw the high/low of the ORB on various futures markets | Questions | 2 | |
R | Draw Vertical Line for Awesome Oscillator | Questions | 5 |
Start a new thread and receive assistance from our community.
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.
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.