有偿

创建于: 2023-09-22 01:58:16, 更新于:
comments   4
hits   619

求一个 pine 语言的马丁策略,能在 Trading 上运行的

更多内容
全部留言
avatar of 发明者量化-小小梦
发明者量化-小小梦
```pine //@version=5 indicator("Martingale Strategy", overlay=true) // 初始仓位大小 initialPositionSize = input(1, title="初始仓位大小") // 加倍倍数 martingaleMultiplier = input(2, title="加倍倍数") // 止损百分比 stopLossDiff = input(2000, title="止损价差") // 盈利百分比 takeProfitDiff = input(2000, title="止盈价差") currentPositionSize = strategy.position_size buySignal = false // 盈利止盈 if (close - strategy.position_avg_price >= takeProfitDiff) strategy.close_all() // 止损加倍 if (close - strategy.position_avg_price <= -stopLossDiff) currentPositionSize := currentPositionSize * martingaleMultiplier buySignal := true if currentPositionSize == 0 buySignal := true currentPositionSize := initialPositionSize // 买入逻辑 strategy.order("Buy", strategy.long, currentPositionSize, when=buySignal) ``` 仅供参考,马丁策略有风险。
2023-09-22 10:48:34
avatar of 发明者量化-小小梦
发明者量化-小小梦
不客气。
2023-09-22 14:01:04
avatar of 梦想身价八位数
梦想身价八位数
感谢梦总
2023-09-22 12:36:19