我不知道为什么交易视图不能回测这个代码



我在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")

您可能忽略了这样一个事实,即在"strategy.entry(id="enterbuy";,long=true,stop=20,comment="如果你在eurusd上尝试这个,你永远不会进行交易,因为价格从未达到20的价格。另一件事是,正如比约恩·米斯蒂安所说,这个剧本很少进行交易。策略进入的条件很少发生(特别是dcross和dcross1(,ecross1和dcross2都必须为true才能结束交易。你可能已经进行了一笔交易,但交易没有结束。看看你的交易清单。也不要忘记通过点击"将脚本添加到图表中;添加到图表中";在松树编辑

最新更新