我已经在 pine 上创建了这个代码,虽然它可以工作,但它没有。根据他们的说法,我没有错误,但是当我将代码添加到图表时,我无法看到它在哪里买卖。此外,当我尝试策略测试时,它不允许我对其进行回测。它不显示任何数据。
//@version=4
strategy("Bushiri project",default_qty_type=strategy.percent_of_equity, default_qty_value=2, pyramiding=5, initial_capital=1000, overlay=true)
// MTF analysis
len = input(8, minval=1, title="Length")
src = input(close, title="Source")
out = sma(src, len)
res = input(title="Resolution", type=input.resolution, defval="1D")
s1 = security(syminfo.tickerid, res, out, gaps=true)
plot(s1, color=color.blue)
len2 = input(21, minval=1, title="Length2")
src2 = input(close, title="Source2")
out2 = sma(src, len2)
res2 = input(title="Resolution2", type=input.resolution, defval="1D")
s2 = security(syminfo.tickerid, res2, out2, gaps=true)
plot(s2, color=color.yellow)
//Ema inputs
fastemaLength= input(50, title="EMA Length", minval=1, maxval=200)
slowemaLength= input(200, title="EMA Length", minval=1, maxval=200)
//values
fastemaVal=ema(close, fastemaLength)
slowemaVal=ema(close, slowemaLength)
//plot values
plot(fastemaVal, title="EMA", color=color.red, transp=2)
plot(slowemaVal, title="EMA", color=color.green, transp=2)
// Entry requirement
dcross= s1>s2
ecross=crossover(fastemaVal, slowemaVal)
if(ecross and dcross)
strategy.entry(id="enterbuy", long=true, stop=20, comment="BUY")
//exit requirement
dcross1=s1>s2
ecross1=crossunder(fastemaVal, slowemaVal)
if(ecross1 and dcross1)
strategy.close(id="enterbuy", comment="EXIT")