Hey @SleepyZ
So when EXThrs is selected, the TO line reports 0 ? I think if possible even with RTH or EXT selected, it should always plot the current rth open (TO). Hoping you can adjust that.
Also, turning off the plot doesn't seem to remove it. In addition, would love to be able to change the colors of the ETH and ETL, if possible.
Thanks!!
View attachment 21665
As mentioned above the RTHopen only appears in the code when you are using RTHrs mode to avoid it duplicating when both modes are on the same chart. I assumed you always used both modes on the same chart.
1. The following allows you to control the display of the rthropen at input showrthrsopenplot = yes;.
2. So if you are loading both modes on one chart, set the one of the loads input showrthrsopenplot = no
3. In the following you can change the colors of all lines/bubbles at the same place, at the input screen, global colors.
4. When you are using the script in EXThrs mode, change the colors at the input screen below or if you want to universally change it, then do it in the fulll code v1a below under the #colors section
Code:#Colors DefineGlobalColor("TO", Color.WHITE); DefineGlobalColor("PL", Color.RED); DefineGlobalColor("PH", Color.GREEN); DefineGlobalColor("PC", Color.YELLOW); DefineGlobalColor("EH", Color.CYAN); DefineGlobalColor("EL", Color.MAGENTA);
Full Revised code v1a
Code:#Previous_Day_HighLowClose_RTHrs_ExtHrs_Sessions_for_Futures_v1a #[email protected] #Modified by Sleepyz #Extended Lines across chart #Added Today's RTH open #Added Mode choice between RTHrs v EXTrs Sessions #Exthrs mode only works on TODAY's Premarket (1800 - 929) for futures input showrthrsopenplot = yes; input agg = {default DAY, WEEK, MONTH}; input mode = {default RTHrs, EXTHrs}; input extend_lines_across_chart = yes; input rthbegin = 0930; input rthend = 1600; input extend = 1800; input showBubbles = no; input showValuesInBubbles = yes; input showLabels = yes; input showValuesInLabels = yes; plot todayrthOpen; plot prevClose; plot prevLow; plot prevHigh; def NA = Double.NaN; def bn = BarNumber(); def exp = IsNaN(close); def rth = SecondsFromTime(rthbegin) > - 0 and SecondsFromTime(rthend) <= 0; def start = GetDayOfWeek(GetYYYYMMDD()); def period = if agg == agg.MONTH then GetMonth() else if agg == agg.WEEK then GetWeek() else GetYYYYMMDD(); def count = if !IsNaN(close) and period != period[1] then count[1] + 1 else count[1]; def cond = HighestAll(count) - count; ################# RTH Open def rthopen = if (GetDay() == GetLastDay() or exp) and SecondsFromTime(rthbegin) == 0 then open else rthopen[1]; todayrthOpen = if extend_lines_across_chart == yes then HighestAll(rthopen) else if exp then rthopen else NA; ################# close def extclose = close(period = agg)[1]; def rthclose = CompoundValue(1, if cond == 1 and SecondsFromTime(rthend) == 0 then close[1] else rthclose[1], close); def hpdclose = if mode == mode.RTHrs and GetDay() == GetLastDay() then rthclose[1] else if mode == mode.EXTHrs and GetDay() == GetLastDay() then close("period" = agg)[1] else hpdclose[1]; prevClose = if extend_lines_across_chart == yes and mode == mode.RTHrs then HighestAll(hpdclose) else if exp and mode == mode.RTHrs then hpdclose else NA; ################# Low def extlowtoday = if cond[1] == 1 and cond == 0 then low else if cond == 0 and GetTime() < RegularTradingStart(GetYYYYMMDD()) then Min(low, extlowtoday[1]) else extlowtoday[1]; def rthlowday = CompoundValue(1, if cond[1] == 2 then Double.NaN else if cond == 1 and SecondsFromTime(rthbegin) == 0 then low else if cond >= 1 and rth == 1 and low < rthlowday[1] then low else rthlowday[1], low); def rthlowweek = if cond == 1 then if start[1] != 1 and start == 1 then NA else if start == 1 and SecondsFromTime(rthbegin) == 0 then low else if start >= 1 and rth and low < rthlowweek[1] then low else rthlowweek[1] else NA; def rthlowmon = if cond == 1 then if cond[1] == 2 and cond == 1 then NA else if start == 1 and SecondsFromTime(rthbegin) == 0 then low else if start >= 1 and rth and low < rthlowmon[1] then low else rthlowmon[1] else NA; def hpdlow = if mode == mode.RTHrs and agg == agg.DAY then HighestAll(if IsNaN(close[-1]) then rthlowday else NA) else if mode == mode.RTHrs and agg == agg.WEEK then LowestAll(if cond == 1 then rthlowweek else NA) else if mode == mode.RTHrs and agg == agg.MONTH then LowestAll(if cond == 1 then rthlowmon else NA) else if mode == mode.EXTHrs then HighestAll(if isnan(close[-1]) then extlowtoday else NA) else hpdlow[1]; prevLow = if extend_lines_across_chart == yes then hpdlow else if exp then HighestAll(hpdlow) else NA; ################# High def exthightoday = if cond == 0 and cond[1] == 1 then high else if cond==0 and GetTime() < RegularTradingStart(GetYYYYMMDD()) then Max(high, exthightoday[1]) else exthightoday[1]; def rthhighday = CompoundValue(1, if cond == 1 and SecondsFromTime(rthbegin) == 0 then high else if cond == 1 and rth then Max(high, rthhighday[1]) else rthhighday[1], high); def rthhighweek = if cond == 1 then if start[1] != 1 and start == 1 then Double.NaN else if start == 1 and SecondsFromTime(rthbegin) == 0 then high else if start >= 1 and rth and high > rthhighweek[1] then high else rthhighweek[1] else NA; def rthhighmon = if cond == 1 then if cond[1] == 2 and cond == 1 then Double.NaN else if start == 1 and SecondsFromTime(rthbegin) == 0 then high else if start >= 1 and rth and high > rthhighmon[1] then high else rthhighmon[1] else NA; def hpdhigh = if mode == mode.RTHrs and agg == agg.DAY then HighestAll(if IsNaN(close[-1]) then rthhighday else NA) else if mode == mode.RTHrs and agg == agg.WEEK then HighestAll(if cond == 1 then rthhighweek else NA) else if mode == mode.RTHrs and agg == agg.MONTH then HighestAll(if cond == 1 then rthhighmon else NA) else if mode == mode.EXTHrs then HighestAll(if IsNaN(close[-1]) then exthightoday else Double.NaN) else hpdhigh[1]; prevHigh = if extend_lines_across_chart == yes then hpdhigh else if exp then HighestAll(hpdhigh) else NA; #Labels AddLabel(showLabels, mode, Color.WHITE); AddLabel(showLabels, if mode == mode.EXTHrs then "TODAY's PREMKT" else "PREV " + agg, Color.LIGHT_GRAY); AddLabel(showLabels and showrthrsopenplot, if showValuesInLabels then "RO $" + todayrthOpen else "TO", todayrthOpen.TakeValueColor()); AddLabel(showLabels, (if showValuesInLabels and mode == mode.EXTHrs then "H $" + exthightoday else if showValuesInLabels and mode == mode.RTHrs then "H $" + prevHigh else "H"), if mode == mode.EXTHrs then GlobalColor("EH") else GlobalColor("PH")); AddLabel(showLabels, (if showValuesInLabels and mode == mode.EXTHrs then "L $" + extlowtoday else if showValuesInLabels then "L $" + prevLow else "L"), if mode == mode.EXTHrs then GlobalColor("EL") else GlobalColor("PL")); AddLabel(showLabels, (if showValuesInLabels and mode == mode.RTHrs then "RPC $" + prevClose else ""), GlobalColor("PC")); #Bubbles input bubblemover = 1; def b = bubblemover; def b1 = b + 1; AddChartBubble(showBubbles and showrthrsopenplot and IsNaN(close[b]) and !IsNaN(close[b1]) , todayrthOpen[b], if showValuesInBubbles then "TO $" + todayrthOpen[b] else "TO", GlobalColor("TO"), yes); AddChartBubble(showBubbles and IsNaN(close[b]) and !IsNaN(close[b1]) , prevClose[b], (if showValuesInBubbles then if mode == mode.EXTHrs then "" else "RPC $" + prevClose[b] else if mode == mode.RTHrs then "RC" else ""), GlobalColor("PC"), yes); AddChartBubble(showBubbles and IsNaN(close[b]) and !IsNaN(close[b1]) , prevLow[b], (if showValuesInBubbles then if mode == mode.EXTHrs then "ETL $" + prevLow[b] else "RPL $" + prevLow[b] else if mode == mode.RTHrs then "RPL" else "ETL"), if mode == mode.EXTHrs then GlobalColor("EL") else GlobalColor("PL"), yes); AddChartBubble(showBubbles and IsNaN(close[b]) and !IsNaN(close[b1]) , prevHigh[b], (if showValuesInBubbles then if mode == mode.EXTHrs then "ETH $" + prevHigh[b] else "RPH $" + prevHigh[b] else if mode == mode.RTHrs then "RPH" else "ETH"), if mode == mode.EXTHrs then GlobalColor("EH") else GlobalColor("PH"), yes); #Colors DefineGlobalColor("TO", Color.WHITE); DefineGlobalColor("PL", Color.RED); DefineGlobalColor("PH", Color.GREEN); DefineGlobalColor("PC", Color.YELLOW); DefineGlobalColor("EH", Color.CYAN); DefineGlobalColor("EL", Color.MAGENTA); todayrthOpen.SetHiding(!showrthrsopenplot); todayrthOpen.AssignValueColor(GlobalColor("TO")); prevLow.AssignValueColor(if mode == mode.EXTHrs then GlobalColor("EL") else GlobalColor("PL")); prevHigh.AssignValueColor(if mode == mode.EXTHrs then GlobalColor("EH") else GlobalColor("PH")); prevClose.AssignValueColor(GlobalColor("PC")); prevLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); prevHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); prevClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); #
Last edited: