如何为所有先前的枢轴点添加标签

huangapple go评论61阅读模式
英文:

How to give all previous pivot points labels

问题

这是您的Pinescript代码,您想要在之前的枢轴点上显示标签。要实现这一点,您需要更改plotshape函数的show_last参数,以便在所有枢轴点上显示标签。这是您可以尝试的代码更改:

plotshape(vPP, color=na, text="Std_PP", textcolor=color.new(#ffffff, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)
plotshape(vR1, color=na, text="Std_R1", textcolor=color.new(#aef6ff, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)
plotshape(vR2, color=na, text="Std_R2", textcolor=color.new(#14b6df, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)
plotshape(vR3, color=na, text="Std_R3", textcolor=color.new(#6164ff, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)
plotshape(vS1, color=na, text="Std_S1", textcolor=color.new(#ff88a5, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)
plotshape(vS2, color=na, text="Std_S2", textcolor=color.new(#ff6309, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)
plotshape(vS3, color=na, text="Std_S3", textcolor=color.new(#ff0000, 0), location=location.absolute, show_last=0, title="Fibonacci Text, don't change", offset=-1)

show_last参数的值更改为0将在所有枢轴点上显示标签,而不仅仅是最后一个。希望这可以帮助您实现您想要的效果。

英文:

I have this Script calculating Pivot points in V5 Pinescript:

//@version=5

indicator(title='Pivot Point', shorttitle='Pivot Point', overlay=true)
timeframe = input('D', title='Timeframe')
width = input.int(2, minval=1)
xHigh  = request.security(syminfo.ticker,timeframe, high[1], barmerge.gaps_off, barmerge.lookahead_on)
xLow   = request.security(syminfo.ticker,timeframe, low[1], barmerge.gaps_off, barmerge.lookahead_on)
xClose = request.security(syminfo.ticker,timeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on)
xOpen = request.security(syminfo.ticker, timeframe, open[1], barmerge.gaps_off, barmerge.lookahead_on)

X = close
vBC = close
vPP = close
vTC = close
vR1 = close
vS1 = close
vR2 = close
vS2 = close
vR3 = close
vS3 = close
vR4 = close
vS4 = close

vPP := (xHigh + xLow + xClose) / 3
vBC := (xHigh + xLow) / 2.0
vTC := vPP - vBC + vPP
vR1 := vPP + vPP - xLow
vS1 := vPP - (xHigh - vPP)
vR2 := vPP + xHigh - xLow
vS2 := vPP - (xHigh - xLow)
vR3 := xHigh + 2 * (vPP - xLow)
vS3 := xLow - 2 * (xHigh - vPP)

plot(vTC, color=color.new(#ffffff, 0), title='TC', style=plot.style_circles, linewidth=width)
plot(vPP, color=color.new(#ffffff, 0), title='PP', style=plot.style_circles, linewidth=width)
plot(vBC, color=color.new(#ffffff, 0), title='BC', style=plot.style_circles, linewidth=width)
plot(vS1, color=color.new(#ff88a5, 0), title='S1', style=plot.style_circles, linewidth=width)
plot(vS2, color=color.new(#ff6309, 0), title='S2', style=plot.style_circles, linewidth=width)
plot(vS3, color=color.new(#ff0000, 0), title='S3', style=plot.style_circles, linewidth=width)
plot(vR1, color=color.new(#aef6ff, 0), title='R1', style=plot.style_circles, linewidth=width)
plot(vR2, color=color.new(#14b6df, 0), title='R2', style=plot.style_circles, linewidth=width)
plot(vR3, color=color.new(#6164ff, 0), title='R3', style=plot.style_circles, linewidth=width)
plotshape(vPP, color=na, text="Std_PP", textcolor=color.new(#ffffff, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)
plotshape(vR1, color=na, text="Std_R1", textcolor=color.new(#aef6ff, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)
plotshape(vR2, color=na, text="Std_R2", textcolor=color.new(#14b6df, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)
plotshape(vR3, color=na, text="Std_R3", textcolor=color.new(#6164ff, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)
plotshape(vS1, color=na, text="Std_S1", textcolor=color.new(#ff88a5, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)
plotshape(vS2, color=na, text="Std_S2", textcolor=color.new(#ff6309, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)
plotshape(vS3, color=na, text="Std_S3", textcolor=color.new(#ff0000, 0), location=location.absolute, show_last=1, title="Fibonacci Text, don't change", offset=-1)

My Script only show the labels for the last pivot only, I wanted the script to give label also to the previous pivot, How can I do this? i tried to change the show_last number but it didn't work well, it just gives a bunch of overlay texts in the last pivots

Example of Current Pivot:

如何为所有先前的枢轴点添加标签

Without Show last:

如何为所有先前的枢轴点添加标签

答案1

得分: 1

你可以删除plotshape(它只是标题,会绘制大量信息)。
然后你会看到所有的pivot点。

以下是你在4小时时间框架中的每日pivot的示例:

indicator(title='Pivot Point', shorttitle='Pivot Point', overlay=true)
timeframe = input('D', title='Timeframe')
width = input.int(2, minval=1)
xHigh  = request.security(syminfo.ticker,timeframe, high[1], barmerge.gaps_off, barmerge.lookahead_on)
xLow   = request.security(syminfo.ticker,timeframe, low[1], barmerge.gaps_off, barmerge.lookahead_on)
xClose = request.security(syminfo.ticker,timeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on)
xOpen = request.security(syminfo.ticker, timeframe, open[1], barmerge.gaps_off, barmerge.lookahead_on)

X = close
vBC = close
vPP = close
vTC = close
vR1 = close
vS1 = close
vR2 = close
vS2 = close
vR3 = close
vS3 = close
vR4 = close
vS4 = close

vPP := (xHigh + xLow + xClose) / 3
vBC := (xHigh + xLow) / 2.0
vTC := vPP - vBC + vPP
vR1 := vPP + vPP - xLow
vS1 := vPP - (xHigh - vPP)
vR2 := vPP + xHigh - xLow
vS2 := vPP - (xHigh - xLow)
vR3 := xHigh + 2 * (vPP - xLow)
vS3 := xLow - 2 * (xHigh - vPP)

plot(vTC, color=color.new(#ffffff, 0), title='TC', style=plot.style_circles, linewidth=width)
plot(vPP, color=color.new(#ffffff, 0), title='PP', style=plot.style_circles, linewidth=width)
plot(vBC, color=color.new(#ffffff, 0), title='BC', style=plot.style_circles, linewidth=width)
plot(vS1, color=color.new(#ff88a5, 0), title='S1', style=plot.style_circles, linewidth=width)
plot(vS2, color=color.new(#ff6309, 0), title='S2', style=plot.style_circles, linewidth=width)
plot(vS3, color=color.new(#ff0000, 0), title='S3', style=plot.style_circles, linewidth=width)
plot(vR1, color=color.new(#aef6ff, 0), title='R1', style=plot.style_circles, linewidth=width)
plot(vR2, color=color.new(#14b6df, 0), title='R2', style=plot.style_circles, linewidth=width)
plot(vR3, color=color.new(#6164ff, 0), title='R3', style=plot.style_circles, linewidth=width)

注:如果你取消注释最后几行,你会得到标题。

英文:

You can delete the plotshape (it is just title and will draw a lot of information).
And then you will see your all your pivot.

Here an example of your daily pivot in a 4 hours timeframe :

如何为所有先前的枢轴点添加标签

the code :

//@version=5

indicator(title='Pivot Point', shorttitle='Pivot Point', overlay=true)
timeframe = input('D', title='Timeframe')
width = input.int(2, minval=1)
xHigh  = request.security(syminfo.ticker,timeframe, high[1], barmerge.gaps_off, barmerge.lookahead_on)
xLow   = request.security(syminfo.ticker,timeframe, low[1], barmerge.gaps_off, barmerge.lookahead_on)
xClose = request.security(syminfo.ticker,timeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on)
xOpen = request.security(syminfo.ticker, timeframe, open[1], barmerge.gaps_off, barmerge.lookahead_on)

X = close
vBC = close
vPP = close
vTC = close
vR1 = close
vS1 = close
vR2 = close
vS2 = close
vR3 = close
vS3 = close
vR4 = close
vS4 = close

vPP := (xHigh + xLow + xClose) / 3
vBC := (xHigh + xLow) / 2.0
vTC := vPP - vBC + vPP
vR1 := vPP + vPP - xLow
vS1 := vPP - (xHigh - vPP)
vR2 := vPP + xHigh - xLow
vS2 := vPP - (xHigh - xLow)
vR3 := xHigh + 2 * (vPP - xLow)
vS3 := xLow - 2 * (xHigh - vPP)

plot(vTC, color=color.new(#ffffff, 0), title='TC', style=plot.style_circles, linewidth=width)
plot(vPP, color=color.new(#ffffff, 0), title='PP', style=plot.style_circles, linewidth=width)
plot(vBC, color=color.new(#ffffff, 0), title='BC', style=plot.style_circles, linewidth=width)
plot(vS1, color=color.new(#ff88a5, 0), title='S1', style=plot.style_circles, linewidth=width)
plot(vS2, color=color.new(#ff6309, 0), title='S2', style=plot.style_circles, linewidth=width)
plot(vS3, color=color.new(#ff0000, 0), title='S3', style=plot.style_circles, linewidth=width)
plot(vR1, color=color.new(#aef6ff, 0), title='R1', style=plot.style_circles, linewidth=width)
plot(vR2, color=color.new(#14b6df, 0), title='R2', style=plot.style_circles, linewidth=width)
plot(vR3, color=color.new(#6164ff, 0), title='R3', style=plot.style_circles, linewidth=width)
//plotshape(vPP, color=na, text="Std_PP", textcolor=color.new(#ffffff, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
//plotshape(vR1, color=na, text="Std_R1", textcolor=color.new(#aef6ff, 0), location=location.absolute,  title="Fibonacci Text, don't change", offset=-1)
//plotshape(vR2, color=na, text="Std_R2", textcolor=color.new(#14b6df, 0), location=location.absolute,  title="Fibonacci Text, don't change", offset=-1)
//plotshape(vR3, color=na, text="Std_R3", textcolor=color.new(#6164ff, 0), location=location.absolute,  title="Fibonacci Text, don't change", offset=-1)
//plotshape(vS1, color=na, text="Std_S1", textcolor=color.new(#ff88a5, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
//plotshape(vS2, color=na, text="Std_S2", textcolor=color.new(#ff6309, 0), location=location.absolute,  title="Fibonacci Text, don't change", offset=-1)
//plotshape(vS3, color=na, text="Std_S3", textcolor=color.new(#ff0000, 0), location=location.absolute,  title="Fibonacci Text, don't change", offset=-1)

NB : if you uncomment the lasts lines, you have the title :
如何为所有先前的枢轴点添加标签

答案2

得分: 0

在会话开始时,使用以下布尔函数来过滤每个时间段的文本:

barstate_start_session() =>
    if timeframe.period == "240" and ((hour(time, syminfo.timezone) == 02))
        true
    else if timeframe.period == "180" and ((hour(time, syminfo.timezone) == 01))
        true
    else if timeframe.period == "120" and ((hour(time, syminfo.timezone) == 22))
        true
    else if timeframe.period == "60" and ((hour(time, syminfo.timezone) == 2))
        true
    else if timeframe.period == "45" and ((hour == 1 and minute == 0))
        true
    else if timeframe.period == "30" and ((hour == 0 and minute == 0))
        true
    else if timeframe.period == "15" and ((hour == 23 and minute == 0) or barstate.islast) 
        true
    else if timeframe.period == "5" and ((hour == 22 and minute == 0) or barstate.islast)
        true
    else if timeframe.period == "3" and ((hour == 22 and minute == 0) or barstate.islast)
        true
    else if timeframe.period == "1" and ((hour == 22 and minute == 0) or barstate.islast)
        true
    else
        false

这将用于在每个点上筛选文本,因此当应用到plotshape时非常有效:

plotshape(barstate_start_session() ? vR1 : na, color=na, text="Std_R1", textcolor=color.new(#aef6ff, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vR2 : na, color=na, text="Std_R2", textcolor=color.new(#14b6df, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vR3 : na, color=na, text="Std_R3", textcolor=color.new(#6164ff, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vS1 : na, color=na, text="Std_S1", textcolor=color.new(#ff88a5, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vS2 : na, color=na, text="Std_S2", textcolor=color.new(#ff6309, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vS3 : na, color=na, text="Std_S3", textcolor=color.new(#ff0000, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)

注意:布尔函数是根据我的本地时间(GMT+7)进行自定义的。

英文:

After a workaround I am able to make this happen, on a beginning of a session with this boolean functions for every timeframes:

barstate_start_session() =>
    if timeframe.period == "240" and ((hour(time, syminfo.timezone) == 02))
        true
    else if timeframe.period == "180" and ((hour(time, syminfo.timezone) == 01))
        true
    else if timeframe.period == "120" and ((hour(time, syminfo.timezone) == 22))
        true
    else if timeframe.period == "60" and ((hour(time, syminfo.timezone) == 2))
        true
    else if timeframe.period == "45" and ((hour == 1 and minute == 0))
        true
    else if timeframe.period == "30" and ((hour == 0 and minute == 0))
        true
    else if timeframe.period == "15" and ((hour == 23 and minute == 0) or barstate.islast) 
        true
    else if timeframe.period == "5" and ((hour == 22 and minute == 0) or barstate.islast)
        true
    else if timeframe.period == "3" and ((hour == 22 and minute == 0) or barstate.islast)
        true
    else if timeframe.period == "1" and ((hour == 22 and minute == 0) or barstate.islast)
        true
    else
        false

this will filter the text appearing for every dots, and hence this is all good when you apply it to the plotshape:

plotshape(barstate_start_session() ? vR1 : na, color=na, text="Std_R1", textcolor=color.new(#aef6ff, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vR2 : na, color=na, text="Std_R2", textcolor=color.new(#14b6df, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vR3 : na, color=na, text="Std_R3", textcolor=color.new(#6164ff, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vS1 : na, color=na, text="Std_S1", textcolor=color.new(#ff88a5, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vS2 : na, color=na, text="Std_S2", textcolor=color.new(#ff6309, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)
plotshape(barstate_start_session() ? vS3 : na, color=na, text="Std_S3", textcolor=color.new(#ff0000, 0), location=location.absolute, title="Fibonacci Text, don't change", offset=-1)

NOTE: the boolean functions is accustomized to my local time (GMT+7)

如何为所有先前的枢轴点添加标签

huangapple
  • 本文由 发表于 2023年6月9日 14:03:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76437600.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定