问题描述
//@version=4
study("Pivot Points","Pivot Points",true)
timeframe = input("D",type = input.resolution)
// Returns the average number of current chart bars in the given target HTF resolution (this reflects the dataset's history).
f_avgDilationOf(_res) =>
// _res: resolution of any TF (in "timeframe.period" string format).
b = barssince(change(time(_res)))
cumTotal = cum(b == 0 ? b[1] + 2 : 0)
cumCount = cum(b == 0 ? 1 : 0)
cumTotal / cumCount
// Period change detection.
pChange(res) =>
change(time(res == 'Y' ? 'D' : res))
// Get some previous value from last HTF period.
tfclose = security(syminfo.tickerid,timeframe,close[1],lookahead = true)
tfopen = security(syminfo.tickerid,open[1],lookahead = true)
tfhigh = security(syminfo.tickerid,high[1],lookahead = true)
tflow = security(syminfo.tickerid,low[1],lookahead = true)
tdpp = (tfhigh + tflow + tfclose) / 3
tdr1 = tdpp + (tdpp - tflow)
tds1 = tdpp - (tfhigh - tdpp)
tdr2 = tdpp + (tfhigh - tflow)
tds2 = tdpp - (tfhigh - tflow)
tdr3 = tfhigh + (2 * (tdpp - tflow))
tds3 = tflow - (2 * (tfhigh - tdpp))
cdpp = (tfhigh + tflow + tfclose + tfopen) / 4
cdr1 = cdpp + (cdpp - tflow)
cds1 = cdpp - (tfhigh - cdpp)
cdr2 = cdpp + (tfhigh - tflow)
cds2 = cdpp - (tfhigh - tflow)
cdr3 = tfhigh + (2 * (cdpp - tflow))
cds3 = tflow - (2 * (tfhigh - cdpp))
// Verify if current charts bars are part of the last dilation of HTF.
lastBar = security(syminfo.tickerid,barstate.islast,lookahead = barmerge.lookahead_on)
// Get avg no of chart bars in one dilation of HTF.
dilation = round(f_avgDilationOf(timeframe))
timeDelta = time - time[1]
var line tdr1Line = na
var line tdppLine = na
var line tds1Line = na
var line tdr2Line = na
var line tds2Line = na
var line tdr3Line = na
var line tds3Line = na
var line cdr1Line = na
var line cdppLine = na
var line cds1Line = na
var line cdr2Line = na
var line cds2Line = na
var line cdr3Line = na
var line cds3Line = na
// Holds bar index where a new line is created.
var Bar = 0
if pChange(timeframe)
// Extend old line for the last bar before creating a new one.
line.set_xy2(tdr1Line,time,tdr1[1])
line.set_xy2(tdppLine,tdpp[1])
line.set_xy2(tds1Line,tds1[1])
line.set_xy2(tdr2Line,tdr2[1])
line.set_xy2(tds2Line,tds2[1])
line.set_xy2(tdr3Line,tdr3[1])
line.set_xy2(tds3Line,tds3[1])
line.set_xy2(cdr1Line,cdr1[1])
line.set_xy2(cdppLine,cdpp[1])
line.set_xy2(cds1Line,cds1[1])
line.set_xy2(cdr2Line,cdr2[1])
line.set_xy2(cds2Line,cds2[1])
line.set_xy2(cdr3Line,cdr3[1])
line.set_xy2(cds3Line,cds3[1])
// Save bar index on transition.
Bar := bar_index
// Create new line.
tdr1Line := line.new(time,tdr1,time + timeDelta,xloc.bar_time,color = color.new(#2ebd85,50),width = 1)
tdppLine := line.new(time,tdpp,color = #2196f3,width = 1)
tds1Line := line.new(time,tds1,color = #e0294a,width = 1)
tdr2Line := line.new(time,tdr2,width = 1)
tds2Line := line.new(time,tds2,width = 1)
tdr3Line := line.new(time,tdr3,width = 1)
tds3Line := line.new(time,tds3,width = 1)
cdr1Line := line.new(time,cdr1,width = 1)
cdppLine := line.new(time,cdpp,width = 1)
cds1Line := line.new(time,cds1,width = 1)
cdr2Line := line.new(time,cdr2,width = 1)
cds2Line := line.new(time,cds2,width = 1)
cdr3Line := line.new(time,cdr3,width = 1)
cds3Line := line.new(time,cds3,width = 1)
// Make type of the 2 `if` blocks the same.
float(na)
else
// We are not on a transition; prolong line until next transition.
line.set_xy2(tdr1Line,tdr1)
line.set_xy2(tdppLine,tdpp)
line.set_xy2(tds1Line,tds1)
line.set_xy2(tdr2Line,tdr2)
line.set_xy2(tds2Line,tds2)
line.set_xy2(tdr3Line,tdr3)
line.set_xy2(tds3Line,tds3)
line.set_xy2(cdr1Line,cdr1)
line.set_xy2(cdppLine,cdpp)
line.set_xy2(cds1Line,cds1)
line.set_xy2(cdr2Line,cdr2)
line.set_xy2(cds2Line,cds2)
line.set_xy2(cdr3Line,cdr3)
line.set_xy2(cds3Line,cds3)
float(na)
// If we are in the last bars of the HTF resolution's dilation,project line into the future with remaining bars in average no of bars in dilation.
if lastBar
line.set_xy2(tdr1Line,time + (timeDelta * (dilation - (bar_index - Bar))),cds3)
我试图在枢轴线(如图像)之间绘制背景填充,但是fill()函数不适用于line.new函数。有办法吗? 我试图在枢轴线(如图像)之间绘制背景填充,但是fill()函数不适用于line.new函数。有办法吗? 我试图在枢轴线(如图像)之间绘制背景填充,但是fill()函数不适用于line.new函数。有办法吗? 我试图在枢轴线(如图像)之间绘制背景填充,但是fill()函数不适用于line.new函数。有办法吗? 我试图在枢轴线(如图像)之间绘制背景填充,但fill()函数不适用于line.new函数。有办法吗? 我试图在枢轴线(如图像)之间绘制背景填充,但是fill()函数不适用于line.new函数。有办法吗? 我试图在枢轴线(如图像)之间绘制背景填充,但是fill()函数不适用于line.new函数。有办法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)