派恩止损?

发布于 2025-01-19 15:44:31 字数 646 浏览 3 评论 0原文

我想在每个条目上设置停止损失。如果价格与入口价格下降2%,

//@version=5
strategy(title="Test ", calc_on_every_tick=false)

haHandle=ticker.heikinashi(syminfo.tickerid)
haOpen=request.security(haHandle,timeframe.period,open)
haClose=request.security(haHandle,timeframe.period,close)
haDeltaAbs=haClose-haClose[1]
haDeltaRel=haDeltaAbs/haClose[1]*100
haEntryCondition = haDeltaRel > 0 and haDeltaRel[1] < 0
strategy.entry("trade", strategy.long, when = haEntryCondition, stop = ????)
strategy.close("trade", when = ta.falling(haClose, 1))    
plot(na, "Zero line", color.gray)

但在Pine文档中没有关于如何使用此“停止”参数的迹象,这至少是设置停止损失的正确论点吗?

此致

I would like to set a stop loss on each of my entries. The stop loss would triger if the price goes down by 2% from the entry price

//@version=5
strategy(title="Test ", calc_on_every_tick=false)

haHandle=ticker.heikinashi(syminfo.tickerid)
haOpen=request.security(haHandle,timeframe.period,open)
haClose=request.security(haHandle,timeframe.period,close)
haDeltaAbs=haClose-haClose[1]
haDeltaRel=haDeltaAbs/haClose[1]*100
haEntryCondition = haDeltaRel > 0 and haDeltaRel[1] < 0
strategy.entry("trade", strategy.long, when = haEntryCondition, stop = ????)
strategy.close("trade", when = ta.falling(haClose, 1))    
plot(na, "Zero line", color.gray)

But there is no indications in Pine documentation on how to use this "stop" argument, is it at least the right argument for setting a stop-loss ?

Best regards

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

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

发布评论

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

评论(1

在风中等你 2025-01-26 15:44:31

您应该为此使用straging.exit()

sl_per = input.float(2.0) * 0.01
sl_price = strategy.position_avg_price * (1 - sl_per)

if (strategy.position_size > 0)
    strategy.exit("SL", "trade", stop=sl_price)

You should use strategy.exit() for that.

sl_per = input.float(2.0) * 0.01
sl_price = strategy.position_avg_price * (1 - sl_per)

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