较低 TF 上未显示每日分辨率数据
我下面的脚本似乎在除 5 分钟或更短时间之外的所有时间范围内都能正常工作。当 5 分钟或更短时,每日分辨率打印 NaN。当 TF 较高时(例如 10 分钟以上),它可以提供预期值。我不明白为什么它在 5 分钟或更少的 TF 上不起作用。任何建议将不胜感激。
//@version=4
study("SQN MTF Table", overlay=true)
len = input(100, minval=1, title="Period")
cell_bearv = input(#800000,'Bear Volatile' ,group='Style Settings')
cell_bearq = input(#FF0000,'Bear Quiet' ,group='Style Settings')
cell_neutral = input(#FFD700,'Neutral' ,group='Style Settings')
cell_bullq = input(#008000,'Bull Quiet' ,group='Style Settings')
cell_bullv = input(#0000FF,'Bull Volatile' ,group='Style Settings')
txt_col = input(color.black,'Text/Frame Color',group='Style Settings')
cell_transp = input(0,'Cell Transparency',minval=0,maxval=100,group='Style Settings')
sqn_time1 = "5"
sqn_time2 = "10"
sqn_time3 = "15"
sqn_time4 = "30"
sqn_time5 = "60"
sqn_time6 = "240"
sqn_time7 = "D"
intra_sqn(R)=>
c = security(syminfo.tickerid, R, close[1], barmerge.lookahead_off)
d = security(syminfo.tickerid, R, close, barmerge.lookahead_on)
close_diff = d/c-1
Stdev = stdev(close_diff,len)
_sma = security(syminfo.tickerid, R, sma(close_diff,len))
((_sma*sqrt(len))/Stdev)
vsi1 = intra_sqn(sqn_time1)
vsi2 = intra_sqn(sqn_time2)
vsi3 = intra_sqn(sqn_time3)
vsi4 = intra_sqn(sqn_time4)
vsi5 = intra_sqn(sqn_time5)
vsi6 = intra_sqn(sqn_time6)
vsi7 = intra_sqn(sqn_time7)
var perfTable = table.new(position.bottom_right, 10, 8, border_width = 1, frame_width = 5)
f_fillCell(_table, _column, _row, _value, _timeframe, _size) =>
_c_color = _value <-1.7? cell_bearv : _value >=-1.7 and _value <-0.6? cell_bearq : _value
>=-0.6 and _value <=0.6? cell_neutral : _value >0.6 and _value <=1.7? cell_bullq : _value
>1.7? cell_bullv : color.gray
_cellText = tostring(_value, "0.00") + "\n" + _timeframe
table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color, cell_transp),
text_color = txt_col, text_size = size.auto, width = 5)
if barstate.islast and (timeframe.multiplier>= 1 and timeframe.multiplier <5 and
timeframe.isminutes==true)
f_fillCell(perfTable, 0, 0, vsi1, sqn_time1, _size)
f_fillCell(perfTable, 1, 0, vsi2, sqn_time2, _size)
f_fillCell(perfTable, 2, 0, vsi3, sqn_time3, _size)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 5 and timeframe.multiplier <10 and
timeframe.isminutes==true)
f_fillCell(perfTable, 1, 0, vsi2, sqn_time2, _size)
f_fillCell(perfTable, 2, 0, vsi3, sqn_time3, _size)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 10 and timeframe.multiplier <15 and
timeframe.isminutes==true)
f_fillCell(perfTable, 2, 0, vsi3, sqn_time3, _size)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 15 and timeframe.multiplier <30 and
timeframe.isminutes==true)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 30 and timeframe.multiplier <60 and
timeframe.isminutes==true)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 60 and timeframe.multiplier <240 and
timeframe.isminutes==true)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 240 and timeframe.isminutes==true)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
I have the following script below that seems to work fine on all timeframes except 5mins or less. When on 5mins or less the daily resolution prints a NaN. When on a higher TF (example 10min+), it provides the expected value. I can't figure out why it does not work on the 5min or less TF's. Any suggestions would be greatly appreciated.
//@version=4
study("SQN MTF Table", overlay=true)
len = input(100, minval=1, title="Period")
cell_bearv = input(#800000,'Bear Volatile' ,group='Style Settings')
cell_bearq = input(#FF0000,'Bear Quiet' ,group='Style Settings')
cell_neutral = input(#FFD700,'Neutral' ,group='Style Settings')
cell_bullq = input(#008000,'Bull Quiet' ,group='Style Settings')
cell_bullv = input(#0000FF,'Bull Volatile' ,group='Style Settings')
txt_col = input(color.black,'Text/Frame Color',group='Style Settings')
cell_transp = input(0,'Cell Transparency',minval=0,maxval=100,group='Style Settings')
sqn_time1 = "5"
sqn_time2 = "10"
sqn_time3 = "15"
sqn_time4 = "30"
sqn_time5 = "60"
sqn_time6 = "240"
sqn_time7 = "D"
intra_sqn(R)=>
c = security(syminfo.tickerid, R, close[1], barmerge.lookahead_off)
d = security(syminfo.tickerid, R, close, barmerge.lookahead_on)
close_diff = d/c-1
Stdev = stdev(close_diff,len)
_sma = security(syminfo.tickerid, R, sma(close_diff,len))
((_sma*sqrt(len))/Stdev)
vsi1 = intra_sqn(sqn_time1)
vsi2 = intra_sqn(sqn_time2)
vsi3 = intra_sqn(sqn_time3)
vsi4 = intra_sqn(sqn_time4)
vsi5 = intra_sqn(sqn_time5)
vsi6 = intra_sqn(sqn_time6)
vsi7 = intra_sqn(sqn_time7)
var perfTable = table.new(position.bottom_right, 10, 8, border_width = 1, frame_width = 5)
f_fillCell(_table, _column, _row, _value, _timeframe, _size) =>
_c_color = _value <-1.7? cell_bearv : _value >=-1.7 and _value <-0.6? cell_bearq : _value
>=-0.6 and _value <=0.6? cell_neutral : _value >0.6 and _value <=1.7? cell_bullq : _value
>1.7? cell_bullv : color.gray
_cellText = tostring(_value, "0.00") + "\n" + _timeframe
table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color, cell_transp),
text_color = txt_col, text_size = size.auto, width = 5)
if barstate.islast and (timeframe.multiplier>= 1 and timeframe.multiplier <5 and
timeframe.isminutes==true)
f_fillCell(perfTable, 0, 0, vsi1, sqn_time1, _size)
f_fillCell(perfTable, 1, 0, vsi2, sqn_time2, _size)
f_fillCell(perfTable, 2, 0, vsi3, sqn_time3, _size)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 5 and timeframe.multiplier <10 and
timeframe.isminutes==true)
f_fillCell(perfTable, 1, 0, vsi2, sqn_time2, _size)
f_fillCell(perfTable, 2, 0, vsi3, sqn_time3, _size)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 10 and timeframe.multiplier <15 and
timeframe.isminutes==true)
f_fillCell(perfTable, 2, 0, vsi3, sqn_time3, _size)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 15 and timeframe.multiplier <30 and
timeframe.isminutes==true)
f_fillCell(perfTable, 3, 0, vsi4, sqn_time4, _size)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 30 and timeframe.multiplier <60 and
timeframe.isminutes==true)
f_fillCell(perfTable, 4, 0, vsi5, sqn_time5, _size)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 60 and timeframe.multiplier <240 and
timeframe.isminutes==true)
f_fillCell(perfTable, 5, 0, vsi6, sqn_time6, _size)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
else if barstate.islast and (timeframe.multiplier>= 240 and timeframe.isminutes==true)
f_fillCell(perfTable, 6, 0, vsi7, sqn_time7, _size)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论