TradingView Pine Script多止盈时max_drawdown与max_runup计算疑问
关于TradingView Pine Script中
strategy.max_drawdown与strategy.max_runup的计算逻辑疑问 我理解最大回撤(max_drawdown)和最大回升(max_runup)的定义,但无法理解TradingView Pine Script中strategy.max_drawdown和strategy.max_runup的计算逻辑,官方文档在多止盈退出场景下的计算说明似乎不准确。
测试代码
//@version=5 strategy("StratTest", overlay=true, precision = 10, initial_capital=1000, default_qty_type=strategy.fixed, default_qty_value=100, commission_type=strategy.commission.cash_per_contract, commission_value=0.033) var float limit = na var float stop = na var float tp1 = na var float tp2 = na if bar_index == 860 limit := math.round_to_mintick(close + 10 * syminfo.mintick) stop := math.round_to_mintick(high + 70 * syminfo.mintick) tp1 := math.round_to_mintick(low - 20 * syminfo.mintick) tp2 := math.round_to_mintick(low - 200 * syminfo.mintick) strategy.entry("Entry", strategy.short, limit=limit) strategy.exit("Exit/1", "Entry", stop=stop, limit=tp1, qty_percent = 50) strategy.exit("Exit/2", "Entry", stop=stop, limit=tp2, qty_percent = 50) plotchar(strategy.max_drawdown, "max_drawdown", '', location.top, color=color.yellow) plotchar(strategy.max_runup, "max_runup", '', location.top, color=color.yellow) plotchar(strategy.opentrades.max_drawdown(0), "opentrades.max_drawdown(0)", '', location.top, color.gray) plotchar(strategy.opentrades.max_runup(0), "opentrades.max_runup(0)", '', location.top, color.gray) plotchar(strategy.closedtrades.max_drawdown(0), "closedtrades.max_drawdown(0)", '', location.top, color.white) plotchar(strategy.closedtrades.max_drawdown(1), "closedtrades.max_drawdown(1)", '', location.top, color.white) plotchar(strategy.closedtrades.max_runup(0), "closedtrades.max_runup(0)", '', location.top, color.white) plotchar(strategy.closedtrades.max_runup(1), "closedtrades.max_runup(1)", '', location.top, color.white)
测试场景与疑问
将该策略在CAPITALCOM:GBPJPY 15分钟周期运行时,strategy.max_drawdown显示为6.00;无佣金时该值为3.45。我的计算过程如下:
- 初始权益1000,以152.873卖出100手,该K线行情顺序为开盘→最高→最低→收盘,低点权益1005,高点权益997.3,对应回升5、回撤2.7,与平台结果一致。
- 在152.8买回50手,该K线行情顺序为开盘→最高→最低→收盘,高点权益1001.2,止盈执行后剩余仓位在低点权益为1007.6,此时最大回撤仍为2.7,回升变为7.6,与平台结果一致。
- 在152.969买回剩余50手,该K线行情顺序为开盘→最低→最高→收盘,低点权益1005.85,止盈执行后权益为998.85,我认为最大回撤仍为2.7、回升为7.6,但平台显示回撤为3.45,想了解该数值的计算逻辑。
(注:附带有佣金和无佣金时的交易列表截图、问题场景截图)
内容的提问来源于stack exchange,提问作者Adam Wallner
相关产品推荐
相关产品推荐

