Join useThinkScript to post your question to a community of 21,000+ developers and traders.
See if this helps. Option for a line, bubble, and/or label to display the open of the current day;Hello,
i'd like to create a label that tell daily open of the current day or a bubble on the right w/o the horizontal line.
i'm really new to this i've been starting to creating my own basic stuff but this is out of my league.
input showline = no;
def openPrice = (if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then open else openPrice[1]);
plot op = openPrice;
op.SetDefaultColor(Color.WHITE);
op.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
op.SetHiding(!showline);
input showbubble = yes;
input bubblemover = 4;
def b = bubblemover;
def b1 = b + 1;
AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), op[b], "O-" + AsText(op), color.white);
input showlabel = no;
AddLabel(showlabel, "Open-" + AsText(op), Color.WHITE);
My Dude! Awesome work again. Can you please incorporate this code into this as well so I can have RTH H/L, ETH H/L, and yesterday's RTH H/L. Also if you could put a toggle input for lines on the chart for all values that would be awesome too.See if this helps. Option for a line, bubble, and/or label to display the open of the current day;
Code:input showline = no; def openPrice = (if GetTime() crosses above RegularTradingStart(GetYYYYMMDD()) then open else openPrice[1]); plot op = openPrice; op.SetDefaultColor(Color.WHITE); op.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); op.SetHiding(!showline); input showbubble = yes; input bubblemover = 4; def b = bubblemover; def b1 = b + 1; AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), op[b], "O-" + AsText(op), color.white); input showlabel = no; AddLabel(showlabel, "Open-" + AsText(op), Color.WHITE);
#https://usethinkscript.com/threads/premarket-high-low-labels-for-thinkorswim.12660/
#halcyonguy
Declare Upper;
input timeframe1 = aggregationPeriod.DAY;
def dayhi = Round(high(period = timeframe1), 2);
def daylo = Round(low(period = timeframe1), 2);
def prevdayhi = dayhi[1];
def prevdaylo = daylo[1];
#Current Day H/L
#AddLabel(1, " ", Color.black);
AddLabel(1, "RTH H:" + dayhi, Color.GRAY);
AddLabel(1, "RTH L:" + daylo, Color.GRAY);
#AddLabel(1, " ", Color.black);
##Start ETH H/L
#bars after close to next day open
input start = 0930;
input end = 1600;
def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0);
def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0);
def pretime = p1 or p2;
def prehi = if !pretime[1] and pretime then high
else if pretime and high > prehi[1] then high
else prehi[1];
def prelo = if !pretime[1] and pretime then low
else if pretime and low < prelo[1] then low
else prelo[1];
#ETH H/L Labels
AddLabel(1, " ", Color.black);
AddLabel(1,"ETH H:" + prehi, if prehi < close then Color.GREEN else Color.RED);
AddLabel(1, "ETH L:" + prelo, if prelo < close then Color.GREEN else Color.RED);
##End ETH H/L
#Yesterdays RTH H/L
AddLabel(1, " ", Color.black);
AddLabel(1, "Yday RTH High:" + prevdayhi, if prevdayhi < close then Color.GREEN else Color.RED);
AddLabel(1, "Yday RTH Low:" + prevdaylo, if prevdaylo < close then Color.GREEN else Color.RED);
My Dude! Awesome work again. Can you please incorporate this code into this as well so I can have RTH H/L, ETH H/L, and yesterday's RTH H/L. Also if you could put a toggle input for lines on the chart for all values that would be awesome too.
When I run this code obviously it returns the wrong values on an EXT/ETH chart. Thank You!
This is what it should look like but with the (corrected) values lol.
Ruby:#https://usethinkscript.com/threads/premarket-high-low-labels-for-thinkorswim.12660/ #halcyonguy Declare Upper; input timeframe1 = aggregationPeriod.DAY; def dayhi = Round(high(period = timeframe1), 2); def daylo = Round(low(period = timeframe1), 2); def prevdayhi = dayhi[1]; def prevdaylo = daylo[1]; #Current Day H/L #AddLabel(1, " ", Color.black); AddLabel(1, "RTH H:" + dayhi, Color.GRAY); AddLabel(1, "RTH L:" + daylo, Color.GRAY); #AddLabel(1, " ", Color.black); ##Start ETH H/L #bars after close to next day open input start = 0930; input end = 1600; def p1 = (secondsfromTime(end) >= 0 and secondstillTime(2359) > 0); def p2 = (secondsfromTime(0000) >= 0 and secondstillTime(start) > 0); def pretime = p1 or p2; def prehi = if !pretime[1] and pretime then high else if pretime and high > prehi[1] then high else prehi[1]; def prelo = if !pretime[1] and pretime then low else if pretime and low < prelo[1] then low else prelo[1]; #ETH H/L Labels AddLabel(1, " ", Color.black); AddLabel(1,"ETH H:" + prehi, if prehi < close then Color.GREEN else Color.RED); AddLabel(1, "ETH L:" + prelo, if prelo < close then Color.GREEN else Color.RED); ##End ETH H/L #Yesterdays RTH H/L AddLabel(1, " ", Color.black); AddLabel(1, "Yday RTH High:" + prevdayhi, if prevdayhi < close then Color.GREEN else Color.RED); AddLabel(1, "Yday RTH Low:" + prevdaylo, if prevdaylo < close then Color.GREEN else Color.RED);
Ruby:declare upper; #RTH defined def rth = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and GetTime() <= RegularTradingEnd(GetYYYYMMDD()); #RTH Open def orth = if rth[1] == 0 and rth == 1 then open else orth[1]; #Highest High during RTH def hrth = if isnan(close) then hrth[1] else if rth[1] == 0 and rth == 1 then high else if rth[1] == 1 then Max(high, hrth[1]) else hrth[1]; #Close during RTH def crth = if rth[1] == 0 and rth == 1 then close else if rth[1] == 1 then close else crth[1]; #Lowerst Low durng RTH def lrth = if isnan(close) then lrth[1] else if rth[1] == 0 and rth == 1 then low else if rth[1] == 1 then Min(low, lrth[1]) else lrth[1]; #Extended Hours High def heth = if gettime() crosses below regularTradingEnd(getyyyYMMDD()) then high else if gettime()<regularTradingStart(getyyyYMMDD()) then Max(high, heth[1]) else heth[1]; #Extended Hours Low def leth = if gettime() crosses below regularTradingEnd(getyyyYMMDD()) then low else if gettime()<regularTradingStart(getyyyYMMDD()) then Min(low, leth[1]) else leth[1]; #Define Days 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) ; #Highs/Lows during lookback days input lookback = 1; def ph = if thisDay == lookback then hrth else ph[1];#today==1 is 1 days ago h,c,l def pc = if thisDay == lookback then crth else pc[1]; def pl = if thisDay == lookback then lrth else pl[1]; #Labels input showlabels = yes; addlabel(showlabels, "RTH O: " + orth, color.red); addlabel(showlabels, "RTH H: " + hrth, color.gray); addlabel(showlabels, "RTH L: " + lrth, color.gray); addlabel(showlabels, "ETH H: " + heth, color.red); addlabel(showlabels, "ETH L: " + leth, color.green); addlabel(showlabels, "YD RTH H: " + ph, color.red); addlabel(showlabels, "YD RTH L: " + pl, color.green); #Lines input showlines = yes; input showonexpansion = yes; plot od = if showonexpansion and !isnan(close) then double.nan else orth; od.SetDefaultColor(Color.red); od.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); od.SetHiding(!showlines); plot hd = if showonexpansion and !isnan(close) then double.nan else hrth; hd.SetDefaultColor(Color.gray); hd.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); hd.SetHiding(!showlines); plot ld = if showonexpansion and !isnan(close) then double.nan else lrth; ld.SetDefaultColor(Color.gray); ld.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); ld.SetHiding(!showlines); plot he = if showonexpansion and !isnan(close) then double.nan else heth; he.SetDefaultColor(Color.red); he.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); he.SetHiding(!showlines); plot le = if showonexpansion and !isnan(close) then double.nan else leth; le.SetDefaultColor(Color.green); le.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); le.SetHiding(!showlines); plot yh = if showonexpansion and !isnan(close) then double.nan else ph; yh.SetDefaultColor(Color.red); yh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); yh.SetHiding(!showlines); plot yl = if showonexpansion and !isnan(close) then double.nan else pl; yl.SetDefaultColor(Color.green); yl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); yl.SetHiding(!showlines); #Bubbles input showbubble = yes; input bubblemover = 4; def b = bubblemover; def b1 = b + 1; AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), od[b], "OD " + od, od.takevalueColor()); AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), hd[b], "HD " + hd, hd.takevalueColor()); AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), ld[b], "LD " + ld, ld.takevalueColor(), no); AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), he[b], "HE " + he, he.takevalueColor()); AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), le[b], "LE " + le, le.takevalueColor(), no); AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), yh[b], "HY " + yh, yh.takevalueColor()); AddChartBubble(showbubble and IsNaN(close[b]) and !IsNaN(close[b1]), yl[b], "LY " + yl, yl.takevalueColor(), no);
YOU da best! thank you for efforts fine sir, I've waited years for this code. Yes I'm old lol.Try this
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
I | How to record RTH and ETH for every single day? | Questions | 2 | |
H | Splitting volume profile into RTH and ETH | Questions | 6 | |
K | SCAN price crosses pre market high or during RTH | Questions | 1 | |
P | Need help with RTH script{} | Questions | 10 | |
G | RTH session - 3 equal parts, 130min each - HIGH /LOW /OPEN | Questions | 2 |
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.