提取符号信息时区数据
Extract Symbol Info Timezone Data
晚上,
我正在尝试根据 GMTOffset 输出对各种 selected 时间输入进行编码。但我还不是很清楚。
如何正确配置 time_int_01 以在 GMTOffset 输出更改时更改?
任何指导将不胜感激。
//@version=4
study("Initial Balance Testing GMT", overlay=true)
var int GMTOffset = hour(timenow) - hour(timenow, "GMT")
time_int_minus5 = input("1900-2000:1234567", "Asia IB Range", input.session)
time_int_minus4 = input("2000-2100:1234567", "Asia IB Range", input.session)
time_int_minus3 = input("2100-2200:1234567", "Asia IB Range", input.session)
time_int_minus2 = input("2200-2300:1234567", "Asia IB Range", input.session)
time_int_minus1 = input("2300-0000:1234567", "Asia IB Range", input.session)
time_int_0 = input("0000-0100:1234567", "Asia IB Range", input.session)
time_int_01 = time_int_minus5
if GMTOffset == 0
time_int_0 := time_int_01
if GMTOffset == -1
time_int_minus1 := time_int_01
if GMTOffset == -2
time_int_minus2 := time_int_01
if GMTOffset == -3
time_int_minus3 := time_int_01
if GMTOffset == -4
time_int_minus4 := time_int_01
if GMTOffset == -5
time_int_minus5 := time_int_01
// Asia START //
//////////////////////////////////// Initial Balance Asia Start
//time_int_01 = input("0000-0100:1234567", "Asia IB Range", input.session)
in_time_int_01 = time(timeframe.period, time_int_01)
var highe_01 = 0.0
var lowe_01 = 10e10
if in_time_int_01
if not in_time_int_01[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
plotAsia = plot(highe_01, title=" Asia IB High", color=color.white, linewidth=1, style=plot.style_linebr)
//////////////////////////////////// Initial Balance Asia Finish
#############更新 22/02/2021 @ 12:15############
原脚本是根据 00:00 到 01:00 的初始平衡时间。
当在 UTC = 0 符号上查看时,IB 排成一行并按预期从 01:00 开始。
请看下面以BTCUSD为例:
但是当在非 UTC = 0 的交易品种上使用指标时,它会不对齐。以下示例显示 GBPNZD - FSCM UTC - 5
我想要查看 GMTOffset 的代码,读取输出编号和 select 不同的输入时间。
示例:
GMTOffset = 0 那么输入将是“input("0000-0100:1234567", "Asia IB Range", input.session)"
GMTOffset = -5 那么输入将是“time_int_minus5 = input(“1900-2000:1234567”, “Asia IB Range”, input.session)”
################# 24/02/2021 @ 11:00 ################# ####
我似乎无法理解为什么我可以让 time_int_01 根据 GMTOffset 的输出将其输入更新为 "in_time_int_01 = time(timeframe.period, time_int_01)".
//@version=4
study("Initial Balance Testing GMT", overlay=true)
var int GMTOffset = hour(timenow) - hour(timenow, "GMT")
var string time_int_01 = na
if GMTOffset == 0
time_int_01 := input("2300-0000:1234567", "Asia IB Range", input.session)
if GMTOffset == -1
time_int_01 := input("2300-0000:1234567", "Asia IB Range", input.session)
if GMTOffset == -2
time_int_01 := input("2200-2300:1234567", "Asia IB Range", input.session)
if GMTOffset == -3
time_int_01 := input("2100-2200:1234567", "Asia IB Range", input.session)
if GMTOffset == -4
time_int_01 := input("2000-2100:1234567", "Asia IB Range", input.session)
if GMTOffset == -5
time_int_01 := input("1900-2000:1234567", "Asia IB Range", input.session)
// Asia START //
//////////////////////////////////// Initial Balance Asia Start
//time_int_0 = input("0000-0100:1234567", "Asia IB Range", input.session)
in_time_int_01 = time(timeframe.period, time_int_01)
var highe_01 = 0.0
var lowe_01 = 10e10
if in_time_int_01
if not in_time_int_01[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
plotAsia = plot(highe_01, title=" Asia IB High", color=color.white, linewidth=1, style=plot.style_linebr)
//////////////////////////////////// Initial Balance Asia Finish
比约恩,
感谢您的意见,因为我的目标是更新下面的脚本,我看不出如何使用您提供的代码来做到这一点。
https://uk.tradingview.com/script/30iJncRa-Initial-Balance-Markets-Time-Zones/
时区可以取自变量syminfo.timezone
。
您不能从变量 syminfo.timezone
中导出整数,因为它是一个字符串。
然而,可以计算当前交易品种的 GMT 偏移整数,如下所示:
//@version=4
study("TimeZone", "TZ", true)
var int GMTOffset = hour(timenow) - hour(timenow, "GMT")
if barstate.islast
label.new(bar_index, close, "GMT Offset = " + tostring(GMTOffset), yloc=yloc.abovebar)
产生:
编辑:回应。
我做了一个快速的小模型,回答了我如何理解你的问题。它收集交易品种第一个小时的最高价,并绘制该值直到下一个交易日的第一个小时之后。
//@version=4
study("Initial Balance Testing GMT", "IB", overlay=true)
var int ONE_HOUR = 60*60*1000
var int IB_length = input(1, "IB Lengh in hours", minval=1)
var int cutoff_time = na
var float hh = na
var float hh_plot = na
var bool in_IB = na
if change(time('D'))
cutoff_time := time + (IB_length * ONE_HOUR)
hh := 0 // reset highest high
in_IB := time < cutoff_time
if in_IB
hh := max(high, hh)
else
hh_plot := hh
plot(hh_plot, color=color.yellow)
bgcolor(in_IB ? color.yellow : na) // Give IB range a background color
晚上,
我正在尝试根据 GMTOffset 输出对各种 selected 时间输入进行编码。但我还不是很清楚。
如何正确配置 time_int_01 以在 GMTOffset 输出更改时更改?
任何指导将不胜感激。
//@version=4
study("Initial Balance Testing GMT", overlay=true)
var int GMTOffset = hour(timenow) - hour(timenow, "GMT")
time_int_minus5 = input("1900-2000:1234567", "Asia IB Range", input.session)
time_int_minus4 = input("2000-2100:1234567", "Asia IB Range", input.session)
time_int_minus3 = input("2100-2200:1234567", "Asia IB Range", input.session)
time_int_minus2 = input("2200-2300:1234567", "Asia IB Range", input.session)
time_int_minus1 = input("2300-0000:1234567", "Asia IB Range", input.session)
time_int_0 = input("0000-0100:1234567", "Asia IB Range", input.session)
time_int_01 = time_int_minus5
if GMTOffset == 0
time_int_0 := time_int_01
if GMTOffset == -1
time_int_minus1 := time_int_01
if GMTOffset == -2
time_int_minus2 := time_int_01
if GMTOffset == -3
time_int_minus3 := time_int_01
if GMTOffset == -4
time_int_minus4 := time_int_01
if GMTOffset == -5
time_int_minus5 := time_int_01
// Asia START //
//////////////////////////////////// Initial Balance Asia Start
//time_int_01 = input("0000-0100:1234567", "Asia IB Range", input.session)
in_time_int_01 = time(timeframe.period, time_int_01)
var highe_01 = 0.0
var lowe_01 = 10e10
if in_time_int_01
if not in_time_int_01[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
plotAsia = plot(highe_01, title=" Asia IB High", color=color.white, linewidth=1, style=plot.style_linebr)
//////////////////////////////////// Initial Balance Asia Finish
#############更新 22/02/2021 @ 12:15############
原脚本是根据 00:00 到 01:00 的初始平衡时间。 当在 UTC = 0 符号上查看时,IB 排成一行并按预期从 01:00 开始。
请看下面以BTCUSD为例:
但是当在非 UTC = 0 的交易品种上使用指标时,它会不对齐。以下示例显示 GBPNZD - FSCM UTC - 5
我想要查看 GMTOffset 的代码,读取输出编号和 select 不同的输入时间。
示例: GMTOffset = 0 那么输入将是“input("0000-0100:1234567", "Asia IB Range", input.session)" GMTOffset = -5 那么输入将是“time_int_minus5 = input(“1900-2000:1234567”, “Asia IB Range”, input.session)”
################# 24/02/2021 @ 11:00 ################# ####
我似乎无法理解为什么我可以让 time_int_01 根据 GMTOffset 的输出将其输入更新为 "in_time_int_01 = time(timeframe.period, time_int_01)".
//@version=4
study("Initial Balance Testing GMT", overlay=true)
var int GMTOffset = hour(timenow) - hour(timenow, "GMT")
var string time_int_01 = na
if GMTOffset == 0
time_int_01 := input("2300-0000:1234567", "Asia IB Range", input.session)
if GMTOffset == -1
time_int_01 := input("2300-0000:1234567", "Asia IB Range", input.session)
if GMTOffset == -2
time_int_01 := input("2200-2300:1234567", "Asia IB Range", input.session)
if GMTOffset == -3
time_int_01 := input("2100-2200:1234567", "Asia IB Range", input.session)
if GMTOffset == -4
time_int_01 := input("2000-2100:1234567", "Asia IB Range", input.session)
if GMTOffset == -5
time_int_01 := input("1900-2000:1234567", "Asia IB Range", input.session)
// Asia START //
//////////////////////////////////// Initial Balance Asia Start
//time_int_0 = input("0000-0100:1234567", "Asia IB Range", input.session)
in_time_int_01 = time(timeframe.period, time_int_01)
var highe_01 = 0.0
var lowe_01 = 10e10
if in_time_int_01
if not in_time_int_01[1]
highe_01 := high
lowe_01 := low
else
highe_01 := max(high, highe_01)
lowe_01 := min(low, lowe_01)
plotAsia = plot(highe_01, title=" Asia IB High", color=color.white, linewidth=1, style=plot.style_linebr)
//////////////////////////////////// Initial Balance Asia Finish
比约恩, 感谢您的意见,因为我的目标是更新下面的脚本,我看不出如何使用您提供的代码来做到这一点。
https://uk.tradingview.com/script/30iJncRa-Initial-Balance-Markets-Time-Zones/
时区可以取自变量syminfo.timezone
。
您不能从变量 syminfo.timezone
中导出整数,因为它是一个字符串。
然而,可以计算当前交易品种的 GMT 偏移整数,如下所示:
//@version=4
study("TimeZone", "TZ", true)
var int GMTOffset = hour(timenow) - hour(timenow, "GMT")
if barstate.islast
label.new(bar_index, close, "GMT Offset = " + tostring(GMTOffset), yloc=yloc.abovebar)
产生:
编辑:回应
//@version=4
study("Initial Balance Testing GMT", "IB", overlay=true)
var int ONE_HOUR = 60*60*1000
var int IB_length = input(1, "IB Lengh in hours", minval=1)
var int cutoff_time = na
var float hh = na
var float hh_plot = na
var bool in_IB = na
if change(time('D'))
cutoff_time := time + (IB_length * ONE_HOUR)
hh := 0 // reset highest high
in_IB := time < cutoff_time
if in_IB
hh := max(high, hh)
else
hh_plot := hh
plot(hh_plot, color=color.yellow)
bgcolor(in_IB ? color.yellow : na) // Give IB range a background color