当执行另一个条件时,如何仅首次越过
我需要编写此指标: MFI不到20岁,然后越过20个(这是主要条件) 当RSI与RSIMA首次交叉时,出现了买信号,
我编写了此代码:
var sessionStart = false
if ta.crossover(mf,20)
sessionStart := true
var rsicross = false
if rsi < rsiMA or rsi > rsiMA or ta.crossunder(rsi,rsiMA)
rsicross := false
if ta.crossover(rsi,rsiMA)
rsicross := true
//====
buyCondition = sessionStart and rsicross
问题是:所有RSI RSIMA十字架都会给出购买信号,因为MFI MFI以前越过20个。 我需要在MFI交叉20之后,首先是RSI,RSIMA Crossing提供购买信号。 有人可以帮我吗,
谢谢
I need to write this indicator :
MFI be under 20 and then cross over 20 ( it is main condition)
the buy signals appears when first cross up of RSI to rsiMA
I write this code :
var sessionStart = false
if ta.crossover(mf,20)
sessionStart := true
var rsicross = false
if rsi < rsiMA or rsi > rsiMA or ta.crossunder(rsi,rsiMA)
rsicross := false
if ta.crossover(rsi,rsiMA)
rsicross := true
//====
buyCondition = sessionStart and rsicross
the problem that : all the rsi rsiMA crosses give buy signals because the main condition MFI crossed 20 before.
I need after MFI cross up 20 , just first rsi , rsiMA crossing give buy signals.
can someone help me please
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在购买条件发生时,您将不得不将买入条件重置为false。因此,在MF交叉发生之前,它不会再次提供购买条件。
You will have to reset the buyCondition back to false when buy condition has occured. So that it will not give buy condition again until mf crossover occurs.