我不能在Trading View上对Comodities数据进行回测。我不知道这是不是很常见,还是只有我这么想?
回测代码在股票,密码,外汇上工作良好,但不是期货,如NO1!简单地在反向测试中不显示任何数据。但是如果我画图,它仍然会显示出来。
有人知道为什么吗?它只是不受支持吗?
//@version=4
strategy("SMA", overlay=true, default_qty_type = strategy.percent_of_equity,
default_qty_value=99, initial_capital=10000, currency=currency.USD)
strategy.risk.allow_entry_in(strategy.direction.long)
fast = input(defval=15, title="fast", type = input.integer)
slow = input(defval=28, title="slow", type = input.integer)
SMA_fast = sma(close, fast)
SMA_slow = sma(close, slow)
start = timestamp(2020, 1, 30, 0, 0)
p1 = plot(SMA_fast, title="fast", color= SMA_fast>=SMA_slow ? color.orange: SMA_fast<=SMA_slow ? color.black: color.black, linewidth=2)
p2 = plot(SMA_slow, title="slow", color=color.blue, linewidth=2)
fill(p1, p2, color = SMA_fast>=SMA_slow ? color.orange : color.blue, transp = 30)
longCondition = crossover(SMA_fast, SMA_slow)
if (longCondition) and time > start
strategy.entry("Long", strategy.long)
alert("BUY (" + tostring(close) + ")", alert.freq_once_per_bar_close)
shortCondition = crossunder(SMA_fast, SMA_slow)
if (shortCondition) and time > start
strategy.entry("Short", strategy.short)
alert("SELL (" + tostring(close) + ")", alert.freq_once_per_bar_close)发布于 2021-03-01 06:39:31
银牌和金牌的每份合同都超过10,000美元,并且您的initial_capital设置为10,000。要么尝试一种期货合约,每份合约低于10,000美元,比如标准普尔500指数ES1!,要么增加你的初始资本。
由于杠杆的原因,我通常使用期货合约,而不是股权的%。
你不需要重写你的代码,当你想在期货上测试你的策略时,只需点击你的策略的设置齿轮图标,然后点击Properties。您可以在设置屏幕中将初始资本和订单大小设置更改为Contracts。
https://stackoverflow.com/questions/66410971
复制相似问题