在Pine脚本中更改图表位置

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

change chart position in pine script

问题

我可以帮您将图表位置向下移动20像素。以下是您的代码的翻译部分:

colorRibbon = roc11 > 0 ? color.rgb(255, 255 - 255/10*countBear, 255 - 255/10*countBear) : color.rgb(255 - 255/10*countBull, 255, 255 - 255/10*countBull)
colorRibbonA = roc11 > 0 ? color.rgb(255, 255 - 255/10*countBear, 255 - 255/10*countBear, 70) : color.rgb(255 - 255/10*countBull, 255, 255 - 255/10*countBull, 70)

frameColor = roc11 > 0 ? color.rgb(0, 255, 0) : color.rgb(255, 0, 0)

if barstate.islast
    info = table.new(position.top_right, 2, 2, bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2)
    table.cell(info, 0, 0, '当前趋势:', text_color = chart.fg_color)
    table.cell(info, 1, 0, roc11 > 0 ? '牛市' : '熊市', text_color = roc11 > 0 ? color.green : color.rgb(224, 0, 0), text_font_family = font.family_monospace, text_size = size.large)
    table.cell(info, 0, 1, roc11 > 0 ? '逆转熊市概率:' : '逆转牛市概率:', text_color = chart.fg_color)
    table.cell(info, 1, 1, roc11 > 0 ? str.tostring(countBear*10) + '%' : str.tostring(countBull*10) + '%', text_color = chart.fg_color)

希望这有助于您调整图表的位置。

英文:

i have a chart for showing bull trend or bear trend. but i need to change chart position little down from top like 20px. can you help me guys? here is the code

colorRibbon  = roc11 > 0 ? color.rgb(255,255 - 255/10*countBear,255 - 255/10*countBear) : color.rgb(255 - 255/10*countBull,255,255 - 255/10*countBull)
colorRibbonA = roc11 > 0 ? color.rgb(255,255 - 255/10*countBear,255 - 255/10*countBear,70) : color.rgb(255 - 255/10*countBull,255,255 - 255/10*countBull,70)

frameColor = roc11 > 0 ? color.rgb(0,255,0) : color.rgb(255,0,0)


if barstate.islast
    info = table.new(position.top_right,2,2,bgcolor = colorRibbonA,frame_color = frameColor, frame_width = 2)
    table.cell(info,0,0,'Current Trend:',text_color = chart.fg_color)
    table.cell(info,1,0,roc11 > 0 ? 'Bull' : 'Bear',text_color = roc11 > 0 ? color.green : color.rgb(224, 0, 0), text_font_family = font.family_monospace,text_size = size.large)
    table.cell(info,0,1,roc11 > 0 ? 'Reversal Bear Probability:' : 'Reversal Bull Probability:',text_color = chart.fg_color)
    table.cell(info,1,1,roc11 > 0 ? str.tostring(countBear*10) + '%' : str.tostring(countBull*10) + '%',text_color = chart.fg_color)

答案1

得分: 1

最简单的方法就是在顶部添加一个空白单元格。所有的背景和边框颜色都是透明的。然后在单元格中填充你的图表颜色。我在下面这样做了,希望这符合你的需求。

如果 barstate.islast
    info = table.new(position.top_right,2,3,bgcolor = color.new(color.white,100),frame_color = color.new(color.white,100))
    table.cell(info,0,0,'')
    table.cell(info,0,1,'当前趋势:',text_color = chart.fg_color)
    table.cell(info,1,1,roc11 > 0 ? '多头' : '空头',text_color = roc11 > 0 ? color.green : color.rgb(224, 0, 0), bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2, text_font_family = font.family_monospace,text_size = size.large)
    table.cell(info,0,2,roc11 > 0 ? '逆转空头概率:' : '逆转多头概率:',text_color = chart.fg_color, bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2)
    table.cell(info,1,2,roc11 > 0 ? str.tostring(countBear*10) + '%' : str.tostring(countBull*10) + '%',text_color = chart.fg_color, bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2)
英文:

Easiest way to do that is to just add a blank cell at the top. With all transparent background and border colors. Then color your chart in the cells. I did that below, hopefully it's what you're looking for.

if barstate.islast
    info = table.new(position.top_right,2,3,bgcolor = color.new(color.white,100),frame_color = color.new(color.white,100))
    table.cell(info,0,0,'')
    table.cell(info,0,1,'Current Trend:',text_color = chart.fg_color)
    table.cell(info,1,1,roc11 > 0 ? 'Bull' : 'Bear',text_color = roc11 > 0 ? color.green : color.rgb(224, 0, 0), bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2, text_font_family = font.family_monospace,text_size = size.large)
    table.cell(info,0,2,roc11 > 0 ? 'Reversal Bear Probability:' : 'Reversal Bull Probability:',text_color = chart.fg_color, bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2)
    table.cell(info,1,2,roc11 > 0 ? str.tostring(countBear*10) + '%' : str.tostring(countBull*10) + '%',text_color = chart.fg_color, bgcolor = colorRibbonA, frame_color = frameColor, frame_width = 2)

huangapple
  • 本文由 发表于 2023年5月22日 22:54:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76307433.html
匿名

发表评论

匿名网友

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

确定