我如何无视连续买卖信号
我正在使用一个指标,该指示器给出了用于上突破和较低突破的信号。问题在于,如果信号没有从上一个信号中更改,我想忽略上部或较低突破警报。如果从上部到较低发生变化,那么我想被提醒。如果有一段时间后有一个上部信号,则不会再有另一个上部信号。
我打算将图表上的最新信号绘制为等于1的信号,如果是较低的信号,则将其绘制为0。然后,我可以寻找对该图的更改,以确定状态的变化。
我是新手,所以请原谅我的平均代码。目前,这是我的目前:
UpBreak = ta.crossover(src,upper-slope_ph*length)
LBreak = ta.crossunder(src,lower+slope_pl*length)
if (UpBreak)
Direction = 1
if (LBreak)
Direction = 0
plot(Direction)
我收到一条错误消息未确定的标识符“方向”。我如何声明此变量,并且有一种更简单的方法可以实现我追求的结果?
I am using an indicator that gives signals that are for an upper breakout and a lower breakout. The problem is that I would like to disregard an upper or lower breakout alert if the signal has not changed from the previous signal. If there is a change from upper to lower then I want to be alerted. Not if there is an upper signal followed by another upper signal some time later.
I was planning to plot the most recent signal on a chart as equal to 1 if it was an upper signal or to 0 if it was a lower signal. Then I could look for a change to this plot to determine the change in state.
I am a Newbie so please excuse my average code. Here is what I have at the moment:
UpBreak = ta.crossover(src,upper-slope_ph*length)
LBreak = ta.crossunder(src,lower+slope_pl*length)
if (UpBreak)
Direction = 1
if (LBreak)
Direction = 0
plot(Direction)
I get an error message Undeclared Identifier "Direction". How do I declare this variable and is there an easier way to achieve the result that I am after?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在本地范围中声明
Direction
,并尝试在全局范围中访问它。将其声明在IF块之外,您很好。
请注意,您应该使用
:=
操作员重新分配值。You are declaring
Direction
in the local scope and trying to access it in the global scope.Declare it outside of the if blocks and you are good.
Please note that, you should use the
:=
operator to re-assign values.