[英]Using Loop to show two or more indication when conditions will met
I want to create an alert.我想创建一个警报。 My indicator should show an alert when the first indicator shows a signal and if the second indicator shows two or more time signals in that time.当第一个指示器显示信号时,如果第二个指示器在那个时间显示两个或更多时间信号,我的指示器应该显示警报。
My script work fine when i use only to show one time indication当我只用于显示一次指示时,我的脚本工作正常
alertcondition(bsignal == true and long == true, title="Buy Signal generated", message="Buy Signal generated")
But i need to show indication every time when the condition is met so i search it on google and use this while loop, but its not working... Error show " Syntax error at input 'true'. "但是每次满足条件时我都需要显示指示,所以我在谷歌上搜索它并使用这个 while 循环,但它不起作用......错误显示“输入'true'时的语法错误。 ”
a = bsignal
b = long
while true
if (a == true) and (b == true)
alertcondition(true, title="Buy Signal generated", message="Buy Signal generated")
else
alertcondition(false)
Please suggest what should i do?请建议我该怎么办? Thanks in advance提前致谢
If you need to trigger an alert in a loop, you should use the alert()
function. alertcondition()
cannot be called in a local scope.如果需要循环触发alert,应该使用alert()
function。alertcondition alertcondition()
不能在本地调用 scope。
However, I am not sure if you need a loop.但是,我不确定您是否需要循环。 Your script will be executed on each bar and you will have access to historical data.您的脚本将在每个柱上执行,您将可以访问历史数据。 You can check if a condition was true
some time ago with the ta.barssince()
function. Or you can use the history referencing operator .您可以使用ta.barssince()
function 检查条件是否为true
。或者您可以使用历史引用运算符。 This way you can check historical data and avoid a loop.这样就可以查看历史数据,避免循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.