简体   繁体   English

循环 plot? 松脚本

[英]Loop plot? Pine Script

I have a script that looks back to a user selected [range] then calculates a simple accumulation of a specific volume based on the range and then plots them in what I would consider a "mini plot" based only on that range.我有一个脚本,可以回顾用户选择的 [范围],然后根据范围计算特定体积的简单累积,然后将它们绘制在我认为仅基于该范围的“迷你图”中。

The problem I have is all the bars on a chart are a printed receipts of the current bar and can not be overwritten.我遇到的问题是图表上的所有条形图都是当前条形图的打印收据,不能被覆盖。

range = user input value to represent lookback period range = 代表回溯期的用户输入值

So my solution was to calculate the volume of the desired bar back via [range] and plot that value over that bar by offsetting the plot by the same [range] and only showing that single printed bar by show_last=1.所以我的解决方案是通过 [范围] 和 plot 计算所需柱的体积,通过将 plot 偏移相同的 [范围] 并仅通过 show_last=1 显示单个打印的柱。

I then repeat the plot function by moving the series forward 1 [range-1] and offsetting the new plot candle by 1 [range-1]然后我重复 plot function 通过将系列向前移动 1 [range-1] 并将新的 plot 蜡烛偏移 1 [range-1]

My issue now is given that the 'range' is selected by the user, I would like to loop the plot function for a repeated duration as defined by 'range' rather than having to write out every new plot individually in script.现在我的问题是用户选择了“范围”,我想循环 plot function 按照“范围”定义的重复持续时间,而不必在脚本中单独写出每个新的 Z32FA6E1B78A9D4028953。

My attempts at doing a for loop with plot within that have failed.我尝试在其中使用 plot 进行 for 循环失败了。

Ideas?想法?

short_off = current_volume + past_volume
range_add = range

plot(short_off[range_add], offset= -(range_add), show_last= 1,  ...)

plot(short_off[range_add-1], offset= -(range_add-1), show_last= 1,  ...)

plot(short_off[range_add-2], offset= -(range_add-2), show_last= 1,  ...)

plot(short_off[range_add-3], offset= -(range_add-3), show_last= 1,  ...)

plot(short_off[range_add-4], offset= -(range_add-4), show_last= 1,  ...)

plot(short_off[range_add-5], offset= -(range_add-5), show_last= 1,  ...)

plot(short_off[range_add-6], offset= -(range_add-6), show_last= 1,  ...)

plot(short_off[range_add-7], offset= -(range_add-7), show_last= 1,  ...)

plot(short_off[range_add-8], offset= -(range_add-8), show_last= 1,  ...)

plot(short_off[range_add-9], offset= -(range_add-9), show_last= 1,  ...)

plot(short_off[range_add-10], offset= -(range_add-10), show_last= 1,  ...)```



So this simple code shows the same result as yours.因此,这个简单的代码显示的结果与您的相同。 Why don't you just use the show_last parameter?为什么不直接使用show_last参数?

//@version=5
indicator("My Script", overlay=true)
short_off = close*2
range_add = input(10)
plot(short_off, show_last=range_add)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM