Prev HLC on Expansion Indicator for ThinkOrSwim

Welkin

Active member
VIP
I like to find ways to remove clutter from the charts so I came up with this. Figured others might find it appealing as well. Plots previous day's high, low and close, as well as the current days open on expansion. these values are taken from the daily aggregation.

l7aR37M.png


Code:
#[email protected]
def NA = Double.NaN;

input agg = AggregationPeriod.DAY;
input showOnlyLastPeriod = no;
input showBubbles = yes;
input showValuesInBubbles = yes;
input spaceBetween = 1;
plot currentOpen;
plot prevDayClose;
plot prevDayLow;
plot prevDayHigh;
def exp = IsNaN(close[spaceBetween]);

currentOpen = if exp then open("period"=agg) else NA;
prevDayClose = if exp then close("period"=agg)[1] else NA;
prevDayLow = if exp then low("period"=agg)[1] else NA;
prevDayHigh = if exp then high("period"=agg)[1] else NA;

AddChartBubble(showBubbles, if IsNaN(currentOpen[1]) and !IsNaN(currentOpen) then currentOpen else NA, if showValuesInBubbles then "CurrOpen $"+currentOpen else "CurrOpen", Color.WHITE, yes);
AddChartBubble(showBubbles, if IsNaN(prevDayClose[1]) and !IsNaN(prevDayClose) then prevDayClose else NA, if showValuesInBubbles then "PrevClose $"+prevDayClose else "PrevClose", Color.YELLOW, yes);
AddChartBubble(showBubbles, if IsNaN(prevDayLow[1]) and !IsNaN(prevDayLow) then prevDayLow else NA, if showValuesInBubbles then "PrevLow $"+prevDayLow else "PrevLow", Color.RED, yes);
AddChartBubble(showBubbles, if IsNaN(prevDayHigh[1]) and !IsNaN(prevDayHigh) then prevDayHigh else NA, if showValuesInBubbles then "PrevHigh $"+prevDayHigh else "PrevHigh", Color.GREEN, yes);

currentOpen.SetDefaultColor(Color.WHITE);
prevDayLow.SetDefaultColor(Color.RED);
prevDayHigh.SetDefaultColor(Color.GREEN);
prevDayClose.SetDefaultColor(Color.YELLOW);
currentOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
prevDayLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
prevDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
prevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:

BenTen

Administrative
Staff
VIP
This is an interesting way of doing it. I usually have mine right on the current day. Having it on expansion makes the chart cleaner.
 

BenTen

Administrative
Staff
VIP
@Swingtrade You can use the script below for that.

Code:
# Previous HLC as Labels
# Assembled by BenTen at UseThinkScript.com

input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod)[1];
def high = high(period = aggregationPeriod)[1];
def low = low(period = aggregationPeriod)[1];

AddLabel(yes, Concat("Prev Close = ", close), color.orange);
AddLabel(yes, Concat("Prev High = ", high), color.orange);
AddLabel(yes, Concat("Prev Low = ", low), color.orange);
 

Gator

New member
Hi, I like the indicator on the chart expansion. I also like the text above the indicator lines. Is there a way to add the text as a feature of the study?
Thanks, Gary
 

Welkin

Active member
VIP
Hi, I like the indicator on the chart expansion. I also like the text above the indicator lines. Is there a way to add the text as a feature of the study?
Thanks, Gary
sorry the text in the image was manually added, but I added chart bubbles to the script for you and they can be toggled on or off in the study settings:
Code:
#[email protected].com
def NA = Double.NaN;

input agg = AggregationPeriod.DAY;

input showOnlyLastPeriod = no;
input showBubbles = yes;
input showValuesInBubbles = yes;
input spaceBetween = 1;
plot currentOpen;
plot prevDayClose;
plot prevDayLow;
plot prevDayHigh;
def exp = IsNaN(close[spaceBetween]);

currentOpen = if exp then open("period"=agg) else NA;
prevDayClose = if exp then close("period"=agg)[1] else NA;
prevDayLow = if exp then low("period"=agg)[1] else NA;
prevDayHigh = if exp then high("period"=agg)[1] else NA;

AddChartBubble(showBubbles, if IsNaN(currentOpen[1]) and !IsNaN(currentOpen) then currentOpen else NA, if showValuesInBubbles then "CurrOpen $"+currentOpen else "CurrOpen", Color.WHITE, yes);
AddChartBubble(showBubbles, if IsNaN(prevDayClose[1]) and !IsNaN(prevDayClose) then prevDayClose else NA, if showValuesInBubbles then "PrevClose $"+prevDayClose else "PrevClose", Color.YELLOW, yes);
AddChartBubble(showBubbles, if IsNaN(prevDayLow[1]) and !IsNaN(prevDayLow) then prevDayLow else NA, if showValuesInBubbles then "PrevLow $"+prevDayLow else "PrevLow", Color.RED, yes);
AddChartBubble(showBubbles, if IsNaN(prevDayHigh[1]) and !IsNaN(prevDayHigh) then prevDayHigh else NA, if showValuesInBubbles then "PrevHigh $"+prevDayHigh else "PrevHigh", Color.GREEN, yes);

currentOpen.SetDefaultColor(Color.WHITE);
prevDayLow.SetDefaultColor(Color.RED);
prevDayHigh.SetDefaultColor(Color.GREEN);
prevDayClose.SetDefaultColor(Color.YELLOW);
currentOpen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
prevDayLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
prevDayHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
prevDayClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:

jcga1981

Member
Hello @Welkin is there the possibility of extending the maximum, minimum, closing and opening lines until the beginning of the session?
I really like how the text appears in the print, however in thinkorswim it appears in the form of a cloud ... can it be left as it appears in the print?
Thank you!
 

Similar threads

Top