取首签松脚本

发布于 2025-01-12 20:14:34 字数 900 浏览 0 评论 0原文

我一直在尝试在版本 2 中进行构建登录。但是,这在版本 4 中执行。 有人可以在版本 2 中帮我解决这个问题吗?非常感谢

在此处输入图像描述

// Determine currently LONG or SHORT
isLong = nz(isLong[1], false)
isShort = nz(isShort[1], false)

// Buy or Sell only if the buy signal is triggered and not already long or short
buySignal = not isLong and buy
sellSignal = not isShort and sell

if (buySignal)
    isLong := true
    isShort := false

if (sellSignal)
    isLong := false
    isShort := true
    
plotshape(series=buySignal, text='Buy', style=shape.labelup, location=location.belowbar, offset=0, color=#009688, textcolor=#ffffff, size=size.small)

plotshape(series=sellSignal, text='Sell', style=shape.labeldown, location=location.abovebar, offset=0, color=#F44336, textcolor=#ffffff, size=size.small)

I've been trying for the build sign in version 2. However this is getting executed in version 4.
Can someone help me with this in version 2? Thank you so much

enter image description here

// Determine currently LONG or SHORT
isLong = nz(isLong[1], false)
isShort = nz(isShort[1], false)

// Buy or Sell only if the buy signal is triggered and not already long or short
buySignal = not isLong and buy
sellSignal = not isShort and sell

if (buySignal)
    isLong := true
    isShort := false

if (sellSignal)
    isLong := false
    isShort := true
    
plotshape(series=buySignal, text='Buy', style=shape.labelup, location=location.belowbar, offset=0, color=#009688, textcolor=#ffffff, size=size.small)

plotshape(series=sellSignal, text='Sell', style=shape.labeldown, location=location.abovebar, offset=0, color=#F44336, textcolor=#ffffff, size=size.small)

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

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

发布评论

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

评论(1

转瞬即逝 2025-01-19 20:14:34

将您的脚本升级到 v5 并删除 isShort,您不需要它。

//@version=5
indicator("My script", overlay=true)

_sma = ta.sma(close, 9)

buy = ta.crossover(close, _sma)
sell = ta.crossunder(close, _sma)

// Determine currently LONG or SHORT
var isLong = false

// Buy or Sell only if the buy signal is triggered and not already long or short
buySignal = not isLong and buy
sellSignal = isLong and sell

if (buySignal)
    isLong := true

if (sellSignal)
    isLong := false

plot(_sma)
plotshape(series=buySignal, text='Buy', style=shape.labelup, location=location.belowbar, offset=0, color=#009688, textcolor=#ffffff, size=size.small)
plotshape(series=sellSignal, text='Sell', style=shape.labeldown, location=location.abovebar, offset=0, color=#F44336, textcolor=#ffffff, size=size.small)

输入图片此处描述

Upgrade your script to v5 and get rid of isShort, you don't need it.

//@version=5
indicator("My script", overlay=true)

_sma = ta.sma(close, 9)

buy = ta.crossover(close, _sma)
sell = ta.crossunder(close, _sma)

// Determine currently LONG or SHORT
var isLong = false

// Buy or Sell only if the buy signal is triggered and not already long or short
buySignal = not isLong and buy
sellSignal = isLong and sell

if (buySignal)
    isLong := true

if (sellSignal)
    isLong := false

plot(_sma)
plotshape(series=buySignal, text='Buy', style=shape.labelup, location=location.belowbar, offset=0, color=#009688, textcolor=#ffffff, size=size.small)
plotshape(series=sellSignal, text='Sell', style=shape.labeldown, location=location.abovebar, offset=0, color=#F44336, textcolor=#ffffff, size=size.small)

enter image description here

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