在 Pine 编辑器中可以吗?
Is it possible in Pine editor?
我最近在 tradingview 的 pine 编辑器中创建了一个脚本。
study("bota", overlay=true)
t = time("240", session.extended) // 1440=60*24 is the number of minutes in a whole day
is_first = na(t[1]) and not na(t) or t[1] < t
apertura = na
if is_first and barstate.isnew
apertura := open
else
apertura := apertura[1]
plot((apertura)+60, color=blue, linewidth=1, transp=20)
plot((apertura)-60, color=red, linewidth=1, transp=20)
其中执行时执行以下操作:https://www.tradingview.com/x/TmBHSzjj/
但我要找的是这个:https://www.tradingview.com/x/4rRH1FTf/
我想要的脚本是当四小时蜡烛开始时 (utc) 绘制两条线直到这四个小时结束(无论图表的时间如何)而不显示之前的蜡烛和线持续到最后,高于初始价格 60 美元(蓝线)和低于 60 美元(红线)。看一些论坛,好像是pine editor重新加载了上面所有的蜡烛,并根据加载的蜡烛修改了脚本。
这应该符合您的预期。
//@version=4
// Credits for timeframe functions: https://www.tradingview.com/script/Wvcqygsx-MTF-Oscillator-Framework-PineCoders/
study("bota", overlay=true)
i_tf = input("240", "Timeframe for lines", input.resolution)
i_offset_src = input(open, "Source to calculate offset from", input.source)
i_offset = input(60, "Offset value", input.float)
var line line_top = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.blue)
var line line_src = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.gray, style=line.style_dotted)
var line line_bot = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.red)
// ————— Converts current chart resolution into a float minutes value.
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
// ————— Returns resolution of _res string timeframe in minutes.
f_tfResInMinutes(_res) =>
// _res: resolution of any TF (in `timeframe.period` string format).
security(syminfo.tickerid, _res, f_resInMinutes())
var int tf_milliseconds = int(f_tfResInMinutes(i_tf) * 60 * 1000)
f_line_move(_line, _x, _y) =>
line.set_xy1(_line, _x, _y)
line.set_xy2(_line, _x + tf_milliseconds, _y)
[src,t] = security(syminfo.tickerid, i_tf, [i_offset_src,time], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
if (barstate.islast)
f_line_move(line_top, t, src + i_offset)
f_line_move(line_src, t, src)
f_line_move(line_bot, t, src - i_offset)
我最近在 tradingview 的 pine 编辑器中创建了一个脚本。
study("bota", overlay=true)
t = time("240", session.extended) // 1440=60*24 is the number of minutes in a whole day
is_first = na(t[1]) and not na(t) or t[1] < t
apertura = na
if is_first and barstate.isnew
apertura := open
else
apertura := apertura[1]
plot((apertura)+60, color=blue, linewidth=1, transp=20)
plot((apertura)-60, color=red, linewidth=1, transp=20)
其中执行时执行以下操作:https://www.tradingview.com/x/TmBHSzjj/
但我要找的是这个:https://www.tradingview.com/x/4rRH1FTf/
我想要的脚本是当四小时蜡烛开始时 (utc) 绘制两条线直到这四个小时结束(无论图表的时间如何)而不显示之前的蜡烛和线持续到最后,高于初始价格 60 美元(蓝线)和低于 60 美元(红线)。看一些论坛,好像是pine editor重新加载了上面所有的蜡烛,并根据加载的蜡烛修改了脚本。
这应该符合您的预期。
//@version=4
// Credits for timeframe functions: https://www.tradingview.com/script/Wvcqygsx-MTF-Oscillator-Framework-PineCoders/
study("bota", overlay=true)
i_tf = input("240", "Timeframe for lines", input.resolution)
i_offset_src = input(open, "Source to calculate offset from", input.source)
i_offset = input(60, "Offset value", input.float)
var line line_top = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.blue)
var line line_src = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.gray, style=line.style_dotted)
var line line_bot = line.new(na, na, na, na, xloc=xloc.bar_time, color=color.red)
// ————— Converts current chart resolution into a float minutes value.
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
// ————— Returns resolution of _res string timeframe in minutes.
f_tfResInMinutes(_res) =>
// _res: resolution of any TF (in `timeframe.period` string format).
security(syminfo.tickerid, _res, f_resInMinutes())
var int tf_milliseconds = int(f_tfResInMinutes(i_tf) * 60 * 1000)
f_line_move(_line, _x, _y) =>
line.set_xy1(_line, _x, _y)
line.set_xy2(_line, _x + tf_milliseconds, _y)
[src,t] = security(syminfo.tickerid, i_tf, [i_offset_src,time], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
if (barstate.islast)
f_line_move(line_top, t, src + i_offset)
f_line_move(line_src, t, src)
f_line_move(line_bot, t, src - i_offset)