Pine script 在脚本中生成交叉条件

Pine script 在脚本中生成交叉条件,pine-script,trading,crossover,Pine Script,Trading,Crossover,我想创建一个简单的交叉条件,我想在交叉时有一个买入卖出信号,我在没有ResourceTion的情况下尝试过,但我想在ResourceTion的情况下尝试,这样我就可以为我的VWMA设置不同的时间框架。这是我的代码,请编辑它,让我知道,这将是一个很大的帮助 // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © bhavi

我想创建一个简单的交叉条件,我想在交叉时有一个买入卖出信号,我在没有ResourceTion的情况下尝试过,但我想在ResourceTion的情况下尝试,这样我就可以为我的VWMA设置不同的时间框架。这是我的代码,请编辑它,让我知道,这将是一个很大的帮助

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

//@version=4
strategy(title="VWMA", shorttitle="VWMA", overlay=true)

len = input(33, "Length", minval=1)
src = input(close, "Source", type = input.source)
resolution = input(title="Resolution", type=input.resolution, defval="5")

outer = vwma(src, len)
ss1 = security(syminfo.tickerid, resolution, outer, gaps=true)
mm2 = plot(ss1, color=#3A6CA8)


length = input(20, "Length", minval=1)
srce = input(close, "Source", type = input.source)
res = input(title="Resolution", type=input.resolution, defval="15")

//ma = vwma(src, len)
//offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
//plot(ma, title="VWMA", color=#3A6CA8, offset = offset)

out = vwma(srce, length)
s1 = security(syminfo.tickerid, res, out, gaps=true)
m2 = plot(s1, color=#3A6CA8)

我对pinescrpit不太熟悉,所以我正在尽我最大的努力添加这个条件,但总是一个令人沮丧的人。所以我只需要在我的代码中添加一个条件。

嘿,爱德华,谢谢你回答这个问题,但这里的问题是,我需要两个决议的策略形式相同,在这里我需要一个条件以及一个信号,无论何时买入/卖出和卖空/回补。我可以像你在这里提到的那样,在学习形式上做同样的事情,但我不知道我被困在了战略部分,我想要这个解决方案,就像我可以为两个VWMA设定时间框架一样。看看你是否能帮我,这将是一个巨大的问题节省,无论如何,感谢你再次回答。我编辑了我的答案,请检查它,我添加了2 VWMA为正常分辨率,另2为MTF,交叉条件。我想从这里你会发现如果你需要的话,如何改变它。非常感谢你,爱德华,这节省了时间。是的,这正是我想弄明白的。再次感谢!非常感谢您的帮助。太好了,您还可以查看
security()
函数文档,它非常有用,可以用它做很多事情,如上面看到的MTF,或者访问任何符号。。。
//@version=4
study(title="VWMA", shorttitle="VWMA", overlay=true)

//vwma 1
len = input(9, "Length", minval=1)
src = input(close, "Source", type = input.source)
ma = vwma(src, len)
plot(ma, title="VWMA", color=color.blue)

//vwma 2
len2 = input(20, "Length", minval=1)
src2 = input(close, "Source", type = input.source)
ma2 = vwma(src2, len2)
plot(ma2, title="VWMA", color=color.yellow)


//cond
longcondition = crossover(ma, ma2)
plotshape(longcondition, size = size.small)

//MTF
t = input("240", type = input.resolution)
ma_mtf = security(syminfo.tickerid, t, ma)
ma2_mtf = security(syminfo.tickerid, t, ma2)
plot(ma_mtf, title="VWMA MTF", color=color.red)
plot(ma2_mtf, title="VWMA MTF", color=color.aqua)

//cond MTF
longcondition_mtf = crossover(ma_mtf, ma2_mtf)
plotshape(longcondition_mtf, size = size.small, color = color.fuchsia)