如何解决FOR LOOP,用于用特定公式绘制 2 条水平线
For 循环问题按照公式打印 2 条水平线。
当证券、价格/收盘值发生变化时,必须按照上述公式自动删除旧行并用新行替换
//@version=4
study("g",overlay=true)
float g_90 = 0
float g_90_1 = 0
for g_90 = 0 to 1000000 // 1000000 can be any infinite number
g_90_1 = g_90 + 1 // second variable is 1 value above previous variable g_90
g_90_return = 4*(g_90*g_90) + 7*(g_90) + 4 //assign a variable g_90_return; to the formula1 = 4*(g_90*g_90) + 7*(g_90) + 4 to plot a horizontal line
g_90_1_return = 4*(g_90_1*g_90_1) + 7*(g_90_1) + 4 //assign a variable g_90_1_return; to the formula2 = 4*(g_90_1*g_90_1) + 7*(g_90_1) + 4 with second variable to plot another horizontal line
if( (g_90_return < close) and ( g_90_1_return > close) ) // if close > formula1 and close < formula2,draw both the hroizontal lines; as long as price is contained within them
hline(g_90_return,color = color.blue,linewidth= 4)
hline(g_90_1_return,linewidth= 4)
else
g_90 := g_90 + 1 // run loop again with incremental value
解决方法
hline()
不能在 for
循环中使用。您可以使用 line.new()
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。