我有代码:
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())
发布于 2020-05-29 18:43:12
奇怪的是,qty=2解决了这些案件。出口永远不会翻转位置。对于翻转,你需要相反的入口:
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)
...https://stackoverflow.com/questions/62009799
复制相似问题