I have a script, this should be called every 5 minute only one time. And after strategy.entry should wait 30 second and check if it can be canceled.
My script looks so, but it does not work, as i wish.
//@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 in advance
Gül
question from:
https://stackoverflow.com/questions/65643772/strategy-exit-should-be-wait-after-strategy-entry 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…