我期望的pine-script crossunder don'
我在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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在上次条件检查中,您有一个错误的变量名称。您设置
exitshortConditiond
,然后您对exitlongconditiond
进行检查。您的代码:
You have a mistyped variable name in your last condition check. You set
exitShortConditiond
, then you are checking againstexitLongConditiond
.Your code: