[英]strategy.exit should be wait after strategy.entry
我有一个脚本,应该每 5 分钟调用一次。 在 strategy.entry 之后应该等待 30 秒并检查是否可以取消。
我的脚本看起来如此,但它不起作用,如我所愿。
//@version=4
strategy("My Strategy", overlay=true)
// create a variable with time of exit
timeLong = 0.0
timeLong := nz(timeLong[1])
msToHours(timeMs) =>
timeMs / 1000
isMoreThan() =>
msToHours(time - timeLong) >= 30
// detect the exit
if strategy.position_size < strategy.position_size[1]
timeLong := time
if (time > timestamp(2021, 1, 9, 00, 00) )
strategy.entry("Long Entry", strategy.long, comment="Long")
// === STRATEGY RISK MANAGEMENT EXECUTION ===
// finally, make use of all the earlier values we got prepped
if isMoreThan()
strategy.close("Long Entry", comment="Exit")
timeLong := na
提前致谢
居尔
感谢您的回答,我更改了我的代码,
Thanks for your answer, i changed my code, //@version=4 strategy("My Strategy", overlay=true, calc_on_every_tick = true) // create a variable with time of long start timeLong = 0.0 timeLong:= nz(timeLong[1]) msToSeconds(timeMs) => timeMs / 1000 isMoreThan() => msToSeconds(timenow - timeLong) >= 30 if (timenow > timestamp(2021, 1, 9, 00, 00) ) and strategy.position_size == 0 strategy.entry("Long Entry", strategy.long, comment="Long") timeLong:= timenow if isMoreThan() and strategy.position_size > 0 strategy.close("Long Entry", comment="Exit") timeLong:= na
但它不像我希望的那样工作,它不会在买卖之间等待 30 秒。
我从我的警报中向您发送屏幕截图,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.