如何在pine脚本中替换命令?

时间:2019-02-23 10:16:44

标签: algorithmic-trading pine-script

是否可以在pine脚本上进行设置,以便在提交新订单命令时将取消先前未执行的命令?

if secondbuycond and firstbuycond and (time >= testPeriodStart and time <= testPeriodStop)
    strategy.entry("buy", strategy.long, stop=((valuewhen(firstbuycond,open,0))*x))
    strategy.exit("Trailing Stop", "buy", trail_points= trailPoints, trail_offset= trailOffset, when= testType == 'Trail Points')

1 个答案:

答案 0 :(得分:0)

//@version=3
strategy("My Strategy", overlay=true)

limit_price = 0

ts = timestamp(2018, 11, 13, 0, 0)
if (time > ts)
    limit_price := 999

ts2 = timestamp(2018, 11, 22, 0, 0)

// here new price will be set to replace an order
if time > ts2
    limit_price := 988

strategy.entry("BUY", strategy.long, limit=limit_price)

可以用新的价格替换只再次输入一个条目,但是两个条目必须仅在价格上有所不同(因此订单ID和方向必须相同) 我在CHMF(每日分辨率)中测试了上述策略。