微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Pine 脚本中的组合策略独立进入和关闭

如何解决Pine 脚本中的组合策略独立进入和关闭

我想尝试类似的策略

//@version=4
strategy(title="Breakout",overlay=true,default_qty_type = strategy.percent_of_equity,default_qty_value = 100,pyramiding = 1,precision=4)
short = input(10)
long = input(20)
start_year = input(2000)
start_month = input(1)
end_year = input(9999)
end_month = input(1)
start     = timestamp(start_year,start_month,1)  
finish    = timestamp(end_year,end_month,1)       
window()  => time >= start and time <= finish ? true : false

H = max(close,open)
L = min(close,open)
buy1 = crossover(H,highest(H[1],short))
sell1 = crossunder(L,lowest(L[1],short))
buy2 = crossover(H,long))
sell2 = crossunder(L,long))

strategy.entry(id="long1",long=true,when=buy1 and window(),comment="buy1") 
strategy.close("long1",when = sell1 and window(),comment="sell1")
strategy.entry(id="long2",when=buy2 and window(),comment="buy2") 
strategy.close("long2",when = sell2 and window(),comment="sell2")

这就像独立运行两个策略,但我想将它们结合起来看表现(每个条目是 50% 的权益)。我试过金字塔方法,但它只会触发buy1和sell1。有谁知道怎么做?谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。