var标志似乎不起作用,它一直在重置
我试图将VAR跨标志汇总在一起,以确定价格是否超过前几天的高度。
这是针对筛选器的,因此一旦我弄清楚此部分,将稍后添加进一步的安全请求,因此为什么在函数调用中。
我到目前为止的代码在下面;但是,它将在应该的第一个1500万条上返回真实,然后再保持真实,直到重置一天的重置为止,它将在接下来的15分钟栏上重置并重置为NAN。
我想要做的是保持真实,直到重置应发生,这是新的一天。
这样做的原因是,我希望进一步的条件也变得正确(尚未写),然后当两个条件设置为True时,输出最终条件。
rblx3()=>
rblxh=request.security("CAPITALCOM:RBLX", "D",high[1])//high of previous day.
rblx15=request.security("CAPITALCOM:RBLX", "15",high)//current high
var cross_flag_high = false
if ta.change(dayofweek)!=0
cross_flag_high:=false
if ta.cross(rblx15,rblxh) and not(cross_flag_high)
cross_flag_high := true
I'm trying to put together a var cross flag to determine if the price crosses above the previous days' high.
This is for a screener so further security requests will be added later once I have figured this part out, hence why it is in a function call.
The code I have so far is below; however, it will return true on the first 15m bar that it should, then rather than stay true until the reset at change of day, it resets on the next 15 minutes bar and resets to NaN.
What I want for it to do is stay true until the reset should happen which is a new day.
The reason for this is that I want a further condition to also become true (not yet wrote) and then when both conditions are set to true, output a final condition.
rblx3()=>
rblxh=request.security("CAPITALCOM:RBLX", "D",high[1])//high of previous day.
rblx15=request.security("CAPITALCOM:RBLX", "15",high)//current high
var cross_flag_high = false
if ta.change(dayofweek)!=0
cross_flag_high:=false
if ta.cross(rblx15,rblxh) and not(cross_flag_high)
cross_flag_high := true
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用
var
关键字在函数范围内,因此它将在每个函数调用上重新启动。您需要创建全局变量,并使用
var
关键字设置全局变量。问题在于函数无法设置全局变量,因此我们必须解决这个问题。您有两个我可以想到的选项:
选项1-函数将返回Cross_flag_high的值,并且返回值将保存为全局变量:
选项2-使用数组来
Your'e using the
var
keyword inside the scope of the function, and therefore it will restart on every function call.You'll need to create global variable and set the global variable with the
var
keyword. The problem is that functions can't set global variables, so we'll have to work around that.You have 2 options I can think of:
Option 1 - the function will return the value of cross_flag_high, and the return value will be saved as a global variable:
Option 2 - using an array in order to work around this issue: