![](/img/trans.png)
[英]how to write a buy or sell trigger after a number of bars meet condition which in my case is 2 renko bars above a certain EMA
[英]I want to write a code for a buy condition: closing price has been rising for the last 5 bars
假设我的策略是购买过去 5 根柱线一直上涨的股票。
我会写这样的东西:
longCondition = (close > close[1]) and (close[1] > close[2]) and (close[2] > close[3]) and (close[3] > close[4]) and (close[4] > close[5])
但是,我觉得有一种更简单的方法可以通过使用自动更新的变量来对此进行编码。 不过我不太确定。 我该如何改进?
您可以使用内置函数rising()
和falling()
例如
longCondition = rising(close, 5)
https://www.tradingview.com/pine-script-reference/v4/#fun_rising
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.