0
Follow
0
Followers
strategy(title = "获取开多信号,进入多头仓位", pyramding = 5)
if longCondition and strategy.position_size <= 0
strategy.entry("开多", strategy.long, when = lowLong, amount = amount, comment = "多头开仓")
if strategy.position_size > 0 and lowShort
strategy.close_all("平多", comment = "多头平仓")
求助小小梦,这段代码是我的策略执行代码。我想实现的是,当触发longCondition信号且触发了小级别多头信号就开一次仓,然后触发小级别空头信号就一次性平仓,类似马丁。但是写完回测的时候发现这么写只能触发第一次开仓,因为开完之后就不满足仓位小于等于0了,怎么调整比较合适呢?因为同时还有个空头的策略,如何写能互不干扰?

如图下方的指标,比如绿线指标金叉就是我的longCondition信号,4个绿色箭头位置是lowLong信号,红色箭头是lowShort信号,如何才能实现绿色剪头金叉就连续入场开多呢?感谢大大❤️❤️
Related Recommendations
Inventor Quant Workflow FAQ (Continuously Updated)Financial Magic Zone Global KOL RecruitmentFAQ Summary (Updating...)PINE Language Introductory Tutorial of FMZ QuantPrimary Tutorial of Strategy Writing with FMZ Quant Trading Platform (Must Read)Getting Started with FMZ Quant Trading Platform (Must Read)MyLanguage DocFMZ PINE Script DocNotes & Explanation of Futures Reverse Doubling Algorithm StrategySolutions to Obtaining Docker Http Request Message
Comment
All comments (3)
第一个问题,如果要忽略pyramding参数,可以把下单函数strategy.entry改成strategy.order,这个order函数就忽略加仓次数限制的。其它和entry函数一样。
strategy(title = "获取开多信号,进入多头仓位")
if longCondition and strategy.position_size >= 0
strategy.order("开多", strategy.long, when = lowLong, amount = amount, comment = "多头开仓")
if strategy.position_size > 0 and lowShort
strategy.close_all("平多", comment = "多头平仓")
这样看看行不行。
4 years ago
- 1
