简体   繁体   English

当条件满足时,使用循环显示两个或多个指示

[英]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.

相关问题 PineScript:一个接一个地满足两个条件时的Plotshape - PineScript: Plotshape when two conditions are met one after the other 满足两个条件时将两个指示器警报合并为一个警报 - combining two indicator alerts into one alert when both conditions are met Pine Script:当两个条件一个接一个满足时绘制标签 - Pine Script: Paint label when two conditions are met one after the other 满足条件时指示器中的背景颜色 - Background color in indicator when conditions are met Plot 形状一旦满足两个条件,但在满足 100 条后才重新绘制 - Plot shape once two conditions are met but don't repaint until it is met after 100 bars 当我的买入条件满足直到我的卖出条件满足时,如何 plot 一条水平线? - How to plot a horizontal line when my buy condition met till my sell conditions met? (任何人,拜托?我试着弄清楚但仍然卡住)满足多个条件时的策略进入 - (Anybody, please? I tried figuring it out but still stuck) Strategy Entry when Multiple Conditions are met 当不再满足条件时,我的 pinescript 策略不会取消进入和退出订单 - My pinescript strategy does not cancel the entry & exit orders when the conditions are no longer met 满足条件后如何重置 Pinescript valuewhen()? - How to reset Pinescript valuewhen() after conditions are met? 在 pine 脚本中通过具有多个“if”条件的 for 循环时出错 - Error when going through a for loop with multiple "if" conditions in pine script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM