首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何翻转位置?strategy.close()和strategy.exit()

如何翻转位置?strategy.close()和strategy.exit()
EN

Stack Overflow用户
提问于 2020-05-26 03:57:00
回答 1查看 180关注 0票数 0

我有代码:

代码语言:javascript
复制
strategy(title="StackOverflowExample", overlay=true, slippage=200, commission_type=strategy.commission.percent, commission_value=0.2)
long=crossover(sma(close, 10), sma(close, 20))
close_condition=crossunder(sma(close, 10), sma(close, 20))
stl=strategy.position_avg_price *0.97
strategy.entry("long", true, 1, when = long) 
strategy.close("long" , when = close_condition) 
strategy.exit("exit", "long", stop=stl, trail_price=strategy.position_avg_price*1.04 ,trail_offset=close*0.03/syminfo.mintick)

如何在这两种情况下翻转位置?(strategy.close(),strategy.exit())

EN

回答 1

Stack Overflow用户

发布于 2020-05-29 18:43:12

奇怪的是,qty=2解决了这些案件。出口永远不会翻转位置。对于翻转,你需要相反的入口:

代码语言:javascript
复制
strategy(title="StackOverflowExample", overlay=true, slippage=200, commission_type=strategy.commission.percent, commission_value=0.2)
long=crossover(sma(close, 10), sma(close, 20))
close_condition=crossunder(sma(close, 10), sma(close, 20))
stl=strategy.position_avg_price *0.97
strategy.entry("long", true, 1, when = long) 
strategy.entry("short", false, 1, when = close_condition) 
...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62009799

复制
相关文章

相似问题

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