0

我只想绘制当前价格在两个枢轴之间的那些枢轴,即 r4 和 r3,所以如果价格开始交易低于 r3;它应该填充 r3 & r2

我尝试了下面的代码但没有用。

-- 尝试过的代码

a = (close <= dR4)
b = (close >= dR3)
c = (close <= dR3)
d = (close >= dR2)
e = (close <= dR2)
f = (close >= dR1)
flat_bottom = close
plot ((a and b) ? flat_bottom : na, title="", linewidth=1, color=color.blue, style=plot.style_circles)

--- 来自这里的实际代码

//@version=4
 
study(title="Pivot CPR", shorttitle="CPR Pivot:", overlay=true)
pivottimeframe = input(title="Pivot Resolution", defval="D", options=["D", "W", "M"])
dp = input(true, title="Display Floor Pivots")
hl = input(true, title="Display M, W, D Highs/Lows")

//dp in the prefix implies daily pivot calculation
dpopen = security(syminfo.tickerid, pivottimeframe, open[1], barmerge.gaps_off, barmerge.lookahead_on)
dphigh = security(syminfo.tickerid, pivottimeframe, high[1], barmerge.gaps_off, barmerge.lookahead_on)
dplow = security(syminfo.tickerid, pivottimeframe, low[1], barmerge.gaps_off, barmerge.lookahead_on)
dpclose = security(syminfo.tickerid, pivottimeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on)
dprange = dphigh - dplow
 
//Expanded Floor Pivots Formula
pivot = (dphigh + dplow + dpclose) / 3.0
bc = (dphigh + dplow) / 2.0
tc = pivot - bc + pivot
r1 = pivot * 2 - dplow
r2 = pivot + dphigh - dplow
r3 = r1 + dphigh - dplow
r4 = r3 + r2 - r1
s1 = pivot * 2 - dphigh
s2 = pivot - (dphigh - dplow)
s3 = s1 - (dphigh - dplow)
s4 = s3 - (s1 - s2)
 
//m,w,d in the prefix implies monthly, weekly and daily
mhigh = security(syminfo.tickerid, "M", high[1], lookahead=barmerge.lookahead_on)
mlow = security(syminfo.tickerid, "M", low[1], lookahead=barmerge.lookahead_on)
whigh = security(syminfo.tickerid, "W", high[1], lookahead=barmerge.lookahead_on)
wlow = security(syminfo.tickerid, "W", low[1], lookahead=barmerge.lookahead_on)
dhigh = security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
dlow = security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
dclose =  security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on) 
 
//Plotting
plot(dp and pivot ? pivot : na, title="Pivot", color=#FF007F, style=plot.style_cross, transp=0)
plot(dp and bc ? bc : na, title="BC", color=color.blue, style=plot.style_cross, transp=0)
plot(dp and tc ? tc : na, title="TC", color=color.blue, style=plot.style_cross, transp=0)
plot(dp and r1 ? r1 : na, title="R1", color=color.green, style=plot.style_cross, transp=0)
plot(dp and r2 ? r2 : na, title="R2", color=color.green, style=plot.style_cross, transp=0)
plot(dp and r3 ? r3 : na, title="R3", color=color.green, style=plot.style_cross, transp=0)
plot(dp and r4 ? r4 : na, title="R4", color=color.green, style=plot.style_cross, transp=0)
plot(dp and s1 ? s1 : na, title="S1", color=color.red, style=plot.style_cross, transp=0)
plot(dp and s2 ? s2 : na, title="S2", color=color.red, style=plot.style_cross, transp=0)
plot(dp and s3 ? s3 : na, title="S3", color=color.red, style=plot.style_cross, transp=0)
plot(dp and s4 ? s4 : na, title="S4", color=color.red, style=plot.style_cross, transp=0)
4

0 回答 0