如何在松树脚本中替换订单?

问题描述 投票:1回答:1

是否有一个选项可以在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')
algorithmic-trading pine-script
1个回答
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中测试了上面的策略,即每日分辨率。

© www.soinside.com 2019 - 2024. All rights reserved.