pine-script - 解决OCHL上执行代码的问题
问题描述
如您所知,在回测期间,代码仅在蜡烛关闭时执行,这对于某些回测来说根本不好。
有没有人可以解决这个问题?
我有个主意
例如,我们想在一分钟的时间范围内测试策略但是我们在一秒的时间范围内运行代码并将一分钟的时间范围数据与一秒的时间进行比较,这样我们就非常接近了到那个目标。
类似于以下代码:
//@version=4
strategy("projheie hal moshkel bozorg", overlay=true)
function() =>
rsiTfOt=rsi(close, 14)
co = crossover(rsiTfOt, 30)
cu = crossover(rsiTfOt, 70)
[co, cu]
[co, cu] = security(syminfo.tickerid, "60", function())
if (co)
strategy.entry("RsiLE", strategy.long, comment="RsiLE")
if (cu)
strategy.entry("RsiSE", strategy.short, comment="RsiSE")
但是这个代码有一个逻辑错误请指导我谁找到了这个想法的解决方案
解决方案
也许这可以帮助:
//@version=4
strategy("projheie hal moshkel bozorg", overlay=true)
length = input( 14 )
overSold = input( 30 )
overBought = input( 70 )
price = close
vrsi = rsi(price, length)
co = crossover(vrsi, overSold)
cu = crossunder(vrsi, overBought)
[buy, sell] = security(syminfo.tickerid, "60", [co, cu], lookahead = true)
if (buy)
strategy.entry("RsiLE", strategy.long, comment="RsiLE")
if (sell)
strategy.entry("RsiSE", strategy.short, comment="RsiSE")
推荐阅读
- android - 如何停止在 kotlin 中每次启动应用程序时收到通知?
- docker - docker-compose中服务的概念和容器的概念有什么关系?
- spring-boot - Spring Boot Test MockMvc 获取自定义标头值
- python-3.x - 由于缺少 DLL 文件,CuPy 导入失败,尽管它出现在我的目录中
- git - 如何保护大量孤立的 Git 提交?
- python - Python for Everyone 第 11 章练习 2 'float' 对象不可调用
- javascript - Mongoose 过期未设置-getIndexes 中未显示过期
- java - 为什么我会收到此错误“令牌上的语法错误”;“,{此令牌后预期”
- python - 为什么即使它与 if 缩进相同,else 也会出现语法错误?
- c# - Selenium,如何在 C# 中获取类的最后一个元素