I want to delay 5 seconds for my LONG & SHORT entries.
for example, if the longCondition
is true at 12:00:00, I want to execute LONG entry at 12:00:05
the same for Short entry: if the shortCondition
is true at 12:00:00, I want to execute SHORT entry at 12:00:05
Can anyone help me, please?
****** Code ******
//@version=5
strategy('My Strategy', overlay=true)
// Indicators
shortSMA = ta.sma(close, 10)
longSMA = ta.sma(close, 30)
rsi = ta.rsi(close, 14)
// Conditions
longCondition = ta.crossover(shortSMA, longSMA) and (rsi > 50)
shortCondition = ta.crossunder(shortSMA, longSMA) and (rsi < 50)
/// LONG
strategy.entry(long
, strategy.long, when=longCondition, comment=Entry Long
) //## How can i delay 5 seconds for this entry ???
strategy.close(long
, when=shortCondition, comment = Exit Long
)
/// SHORT
strategy.entry(short
, strategy.short, when = shortCondition, comment=Entry Short
) //## How can i delay 5 seconds for this entry ???
strategy.close(short
, when=longCondition, comment=Exit Short
)