简体   繁体   English

为什么第二个'if'的内容从未执行过?

[英]Why the contents of the second 'if' never executed?

I think it needs to work but does not.我认为它需要工作,但没有。 Please help me find out why?请帮我找出原因? Thank you谢谢

//@version=5
strategy("Week High Low - Buy Strategy")

thisyear = year(timenow)
thisweek = weekofyear(timenow)
lastweekhigh = request.security(syminfo.tickerid, 'W', high[1], barmerge.gaps_off, barmerge.lookahead_on)
lastweeklow = request.security(syminfo.tickerid, 'W', low[1], barmerge.gaps_off, barmerge.lookahead_on)
halfline = (lastweekhigh + lastweeklow) / 2

buysignal = false
if close < halfline and close > lastweeklow
    i = 1
    while year[i] == thisyear and weekofyear[i] == thisweek
        if close[i] > lastweekhigh
            buysignal := true
            break
        i += 1

strategy.entry("long", strategy.long, 1, when = buysignal)

如果 close < halfline and close > lastweeklow ,使用 "or" 除了使用 "and" ,几个星期面临同样的错误==

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

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