我期望的pine-script crossunder don'

发布于 2025-01-18 22:48:04 字数 1567 浏览 1 评论 0原文

我在EntershortCondition上遇到了这个问题。 当关闭值在下行下方交叉时,我希望退出短信号。

长位置,我没有问题,但是在较短的情况下(镜面到较长的状态),当近距离上线近距离交叉时,我有一个出口信号。我不明白。我为此疯狂。

有人可以帮我吗?

这是我尝试使用此Pine脚本的代码

// This source code is subject to the terms of the Mozilla Public License 2.0 at ``https://mozilla.org/MPL/2.0/
// © pret71

//@version=4
strategy("Intraday Forex Strategy", overlay=true)

length = input(20, minval=1)
smaPeriod  = input(defval = 60, title = "SMA Period", type = input.integer)
lower = lowest(length)[1]
upper = highest(length)[1]
basis = avg(upper, lower)
plot(basis, "Basis", color=#FF6A00)
u = plot(upper, "Upper", color=#0094FF)
l = plot(lower, "Lower", color=#0094FF)
mySma=sma(close,smaPeriod)

plot(mySma, "Basis", color=color.red)

//verifico che incaso long sma50 (mySma) sia crescente e in caso short decrescente
confirmLongCondition = iff(mySma[25]>mySma[50] and mySma[0]>mySma[25],true,false)
confirmShortCondition = iff(mySma[25]<mySma[50] and mySma[0]<mySma[25],true,false)

enterLongCondition = crossunder(close,lower) and confirmLongCondition //and (lower>mySma)
if (enterLongCondition)
    strategy.entry("LongEntry", strategy.long)

enterShortCondition = crossover(close,upper) and confirmShortCondition //and (upper<mySma)
if (enterShortCondition)
    strategy.entry("ShortEntry", strategy.short)

exitLongConditiond = crossover(close,upper)
if (exitLongConditiond)
    strategy.close("LongEntry")

exitShortConditiond = crossunder(close,lower)
if (exitLongConditiond)
    strategy.close("ShortEntry")

,但它不起作用

I have this problem with enterShortCondition.
I'd want exit short signal when close value is cross under the lower line.

With long position I have no problem but with short condition (it's specular to long condition) I have an exit signals when close prize cross over upper line. I don't understand. I'm crazy with this.

Someone could me help me, please?

Here it is the code

// This source code is subject to the terms of the Mozilla Public License 2.0 at ``https://mozilla.org/MPL/2.0/
// © pret71

//@version=4
strategy("Intraday Forex Strategy", overlay=true)

length = input(20, minval=1)
smaPeriod  = input(defval = 60, title = "SMA Period", type = input.integer)
lower = lowest(length)[1]
upper = highest(length)[1]
basis = avg(upper, lower)
plot(basis, "Basis", color=#FF6A00)
u = plot(upper, "Upper", color=#0094FF)
l = plot(lower, "Lower", color=#0094FF)
mySma=sma(close,smaPeriod)

plot(mySma, "Basis", color=color.red)

//verifico che incaso long sma50 (mySma) sia crescente e in caso short decrescente
confirmLongCondition = iff(mySma[25]>mySma[50] and mySma[0]>mySma[25],true,false)
confirmShortCondition = iff(mySma[25]<mySma[50] and mySma[0]<mySma[25],true,false)

enterLongCondition = crossunder(close,lower) and confirmLongCondition //and (lower>mySma)
if (enterLongCondition)
    strategy.entry("LongEntry", strategy.long)

enterShortCondition = crossover(close,upper) and confirmShortCondition //and (upper<mySma)
if (enterShortCondition)
    strategy.entry("ShortEntry", strategy.short)

exitLongConditiond = crossover(close,upper)
if (exitLongConditiond)
    strategy.close("LongEntry")

exitShortConditiond = crossunder(close,lower)
if (exitLongConditiond)
    strategy.close("ShortEntry")

I try to use this pine script but it doesn't work

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

淡淡の花香 2025-01-25 22:48:04

在上次条件检查中,您有一个错误的变量名称。您设置exitshortConditiond,然后您对exitlongconditiond进行检查。

您的代码:

exitLongConditiond = crossover(close,upper)
if (exitLongConditiond)
    strategy.close("LongEntry")

exitShortConditiond = crossunder(close,lower)
if (**exitLongConditiond**)
    strategy.close("ShortEntry")

You have a mistyped variable name in your last condition check. You set exitShortConditiond, then you are checking against exitLongConditiond.

Your code:

exitLongConditiond = crossover(close,upper)
if (exitLongConditiond)
    strategy.close("LongEntry")

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