在价格坐标处绘制线的问题
Problem plotting line at price coordinates
我正在写一个简单的指标显示垂直和
水平线。
垂直线应以纽约开盘价绘制
我从时间戳比较中得到,但是 y 坐标线
是不正确的。非常感谢任何帮助,因为我现在正在苦苦挣扎。
//@version=4
study("Sessions",overlay=true, scale=scale.none)
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, -1000, BarIndex, 1000, 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)
问题的原因是'No Scale'模式。为了禁用该模式并解决问题,请从 study 调用中删除 scale 参数:
study("Sessions",overlay=true)
我正在写一个简单的指标显示垂直和 水平线。 垂直线应以纽约开盘价绘制 我从时间戳比较中得到,但是 y 坐标线 是不正确的。非常感谢任何帮助,因为我现在正在苦苦挣扎。
//@version=4
study("Sessions",overlay=true, scale=scale.none)
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, -1000, BarIndex, 1000, 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)
问题的原因是'No Scale'模式。为了禁用该模式并解决问题,请从 study 调用中删除 scale 参数:
study("Sessions",overlay=true)