Home

zhangyiqun

Thoughts, stories and ideas.

翻译 2014年以前 スーパーマリオ 关于

06 Jun 2021
Tradingview/Pine script 策略测试

用 Tradingview Pine 简单写个策略,模拟在流动性泛滥时卖出,在市场恐慌时买入。

strategy("moving average cross")

ema20 = ema(close,20)
ema200 = ema(close,200)

long = ema20 < ema200 
short = ema20 / ema200 > 1.1

start = timestamp(1980,6,1,0,0)
end = timestamp(2021,6,1,0,0)

if time >= start and time <= end
    strategy.entry("Long", strategy.long, 1000.0, when = long)
    strategy.entry("Short", strategy.short, 1000.0, when = short)

strategy.close("Long", when = short)
strategy.close("Short", when = long)

IMG_0122

IMG_0122

IMG_0122

脚本地址:https://www.tradingview.com/script/1ACtlH0J-moving-average-cross

如果只是简单的测试,这个工具也不错 https://www.portfoliovisualizer.com/backtest-portfolio

IMG_0122

翻译 2014年以前 スーパーマリオ 关于