我如何无视连续买卖信号

发布于 2025-02-07 03:30:43 字数 489 浏览 0 评论 0原文

我正在使用一个指标,该指示器给出了用于上突破和较低突破的信号。问题在于,如果信号没有从上一个信号中更改,我想忽略上部或较低突破警报。如果从上部到较低发生变化,那么我想被提醒。如果有一段时间后有一个上部信号,则不会再有另一个上部信号。

我打算将图表上的最新信号绘制为等于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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2025-02-14 03:30:43

您正在本地范围中声明Direction,并尝试在全局范围中访问它。

将其声明在IF块之外,您很好。

UpBreak =  ta.crossover(src,upper-slope_ph*length)
LBreak = ta.crossunder(src,lower+slope_pl*length)

var Direction = 0

if (UpBreak)
    Direction := 1
if (LBreak)
    Direction := 0
plot(Direction)

请注意,您应该使用:=操作员重新分配值。

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.

UpBreak =  ta.crossover(src,upper-slope_ph*length)
LBreak = ta.crossunder(src,lower+slope_pl*length)

var Direction = 0

if (UpBreak)
    Direction := 1
if (LBreak)
    Direction := 0
plot(Direction)

Please note that, you should use the := operator to re-assign values.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文