TonXas
New member
Any way to put the WT label underneath the bottom left of the range box?
Code:
# inputs
input orStartTime = 1700;
input orEndTime = 0100;
input period = AggregationPeriod.FOUR_HOURS;
input showOnlyToday = no;
input showOnlyToday_boxes = yes;
input showCloud = yes;
input showboxes = yes;
input showMidpoint = yes;
input useAlerts = yes;
input useTradeSignals = no;
input day_of_week = {default Sunday};
# constants
def na = Double.NaN;
def hi = high(period = period);
def lo = low(period = period);
DefineGlobalColor("Cloud", Color.GRAY);
# opening range time logic
def overnight = orStartTime > orEndTime;
def pastORstart = SecondsFromTime(orStartTime) >= 0;
def beforeORend = SecondsTillTime(orEndTime) > 0;
def isOR =
(overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
def isOR2 =
(overnight and (pastORstart or beforeORend)) or (!overnight and (pastORstart and beforeORend));
#def isOr = SecondsTillTime(orEndTime) > 0 and SecondsFromTime(orStartTime) >= 0;
def today = (!showOnlyToday or GetDay() == GetLastDay()) and !IsNaN(close);
def today2 = (!showOnlyToday_boxes or GetDay() == GetLastDay()) and !IsNaN(close);
# opening range levels logic
def orhi =
if orhi[1] == 0
or !isOR[1]
and isOR
then hi
else if isOR
and hi > orhi[1]
then hi
else orhi[1];
def orlo =
if orlo[1] == 0
or !isOR[1]
and isOR
then lo
else if isOR
and lo < orlo[1]
then lo
else orlo[1];
# opening range levels logic
def orhi2 =
if orhi2[1] == 0
or !isOR2[1]
and isOR2
then hi
else if isOR2
and hi > orhi2[1]
then hi
else orhi2[1];
def orlo2 =
if orlo2[1] == 0
or !isOR2[1]
and isOR2
then lo
else if isOR2
and lo < orlo2[1]
then lo
else orlo2[1];
# plots
plot orh = if today < 1 then na else orhi;
plot orl = if today < 1 then na else orlo;
plot orm = if !isOR then (orh + orl) / 2 else na;
def orh2 = if today2 < 1 then na else orhi2;
def orl2 = if today2 < 1 then na else orlo2;
orm.SetHiding(!showMidpoint);
def range = orhi - orlo;
plot SHH25 = orh2 + .0025;
plot SHH50 = orh2 + .005;
plot SHL25 = orl2 - .0025;
plot SHL50 = orl2 - .005;
SHH25.Hide();
SHL25.Hide();
SHH50.Hide();
SHL50.Hide();
AddCloud(if showCloud and isOR then orh else na, if showCloud and isOR then orl else na, GlobalColor("cloud"), GlobalColor("cloud"));
AddCloud(if !showboxes then na else SHH50, SHH25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
AddCloud(if !showboxes then na else SHL50, SHL25, color1 = GlobalColor("Cloud"), color2 = GlobalColor("Cloud"));
# look and feel
orh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orl.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
orm.SetPaintingStrategy(PaintingStrategy.DASHES);
orh.SetDefaultColor(Color.WHITE);
orl.SetDefaultColor(Color.WHITE);
orm.SetDefaultColor(Color.WHITE);
plot highBreak = useTradeSignals and !isOR and close crosses above orh;
plot highBreaklow = useTradeSignals and !isOR and close crosses below orh;
plot lowBreak = useTradeSignals and !isOR and close crosses below orl;
plot lowBreakhigh = useTradeSignals and !isOR and close crosses above orl;
plot midhighbreak = useTradeSignals and !isOR and close crosses above orm;
plot midlowbreak = useTradeSignals and !isOR and close crosses below orm;
highBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
highBreaklow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
lowBreakhigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midhighbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
midlowbreak.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
highBreak.SetDefaultColor(Color.DARK_GREEN);
lowBreak.SetDefaultColor(Color.DARK_RED);
midhighbreak.SetDefaultColor(Color.DARK_GREEN);
midlowbreak.SetDefaultColor(Color.DARK_RED);
Alert(useAlerts and highBreak, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and highBreaklow, "ORH Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreak, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and lowBreakhigh, "ORL Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midhighbreak, "ORM Breakout", "alert type" = Alert.BAR, sound = Sound.Ding);
Alert(useAlerts and midlowbreak, "ORM Breakdown", "alert type" = Alert.BAR, sound = Sound.Ding);
AddLabel(close > 0, Concat( "WT: ", (orhi - orlo) * 10000), Color.CYAN);
#plot WT = if today == (orhi - orlo) then orlo - (3 * TickSize()) else Double.NaN;
#AddChartBubble(close > 0, Concat( "WT: ", (orhi - orlo)*10000), Color.cyan);