首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我不知道为什么trading view不能对这段代码进行反向测试。

我不知道为什么trading view不能对这段代码进行反向测试。
EN

Stack Overflow用户
提问于 2020-11-25 03:28:01
回答 1查看 82关注 0票数 1

我已经在pine上创建了这段代码,我认为它可以工作,但它不能。根据他们的说法,我没有错误,但当我将代码添加到图中时,我无法看到它在哪里买卖。此外,当我尝试策略测试时,它不允许我对其进行回测。它不显示任何数据。

代码语言:javascript
复制
//@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")
EN

回答 1

Stack Overflow用户

发布于 2020-11-26 01:43:34

您可能忽略了这样一个事实:在'strategy.entry(id="enterbuy",long=true,stop=20,comment="BUY")‘上的stop= 20将以20的价格下单。另一件事是,正如Bjorn Mistiaen所说,这个脚本很少进行交易。你可能已经进行了一笔交易,但它并没有成交。看看你的交易清单。另外,不要忘记通过单击pine编辑器中的"add to chart“将脚本添加到图表中

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64993500

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档