Skip to content

Instantly share code, notes, and snippets.

@denistex
Created June 3, 2020 18:06
Show Gist options
  • Save denistex/f3428d7906c3f7eaf8e5279a8eb67ce7 to your computer and use it in GitHub Desktop.
Save denistex/f3428d7906c3f7eaf8e5279a8eb67ce7 to your computer and use it in GitHub Desktop.
StackOverflow Answer
//@version=4
// https://stackoverflow.com/questions/62162866/problem-plotting-line-at-price-coordinates/62165505
study("Sessions",overlay=true)
t1 = timestamp("GMT", year, month, dayofmonth, 0, 00, 00)
t2 = timestamp("GMT-5", year, month, dayofmonth, 0, 00, 00)
backLook = 86400000 * 1.5
displayCondition = timeframe.isdwm == false and (time > timenow - backLook)
vline(BarIndex, Color, LineStyle, LineWidth) => // Verticle Line, 54 lines maximum allowable per indicator
return = line.new(BarIndex, low, BarIndex, high, xloc.bar_index, extend.both, Color, LineStyle, LineWidth)
drawPrice(price) =>
x = bar_index
y = price
txt = tostring(price)
label.new(x, price, txt)
// y position is always wrong, the label text displays the correct price though
line.new(x1=t2, y1=y, color=#ec4069, x2=time + 86400000, y2=y,xloc=xloc.bar_time)
// ny open
if(time == t2 and displayCondition)
vline(bar_index, #ec4069, line.style_solid, 1)
if(time == t2 and displayCondition)
drawPrice(open)
// gmt open
if(time == t1 and displayCondition)
vline(bar_index, #000000, line.style_solid, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment