milood
milood

Reputation: 1

How to delay alerts generated in pine script

I send two Alert at the same time in one minute timeframe I want to make a 3seconds delay between two signals

//@version=5
strategy('Strat with time delay', overlay=true)


ma = ta.sma(close, 100)
goLong = ta.crossover(close, ma)
goShort = ta.crossunder(close, ma)




plot(ma, 'MA', goLong ? color.lime : color.red)

if goShort and strategy.position_size > 0
    strategy.close(id='Enter Long')

if goLong and strategy.position_size < 0
    strategy.close(id='Enter Short')



if goLong
    strategy.entry('Enter Long', strategy.long)



if goShort
    strategy.entry('Enter Short', strategy.short)

The following solution did not work properly : link

Upvotes: 0

Views: 1584

Answers (1)

Dave
Dave

Reputation: 865

Maybe this could help https://www.pinecoders.com/faq_and_code/#how-can-i-implement-a-time-delay-between-orders

You can use this to implement a 3 seconds delay between 2 events

Upvotes: 0

Related Questions