To add a delay in "Pivot Reversal Strategy" between Long / Short exit and Long / Short entry in Tradingview-Alert

I would like to trade with the Pivot Reversal Strategy. The pin script is structured so that the long exit is also the short entry and vice versa. But for the bot to run, I need to switch from long to short at the same time, and to do this, I need to add a delay

Can someone rewrite the script for me so that I have this delay? - I'm happy to pay for it. Unfortunately, I have no idea how to write a PineCode. Here is the pin code:

// @ version = 4


strategy("Pivot Reversal Strategy", overlay = true)

leftBars = input(4)

rightBars = input(2)

swh = pivothigh(leftBars, rightBars)

swl = pivotlow(leftBars, rightBars)

swh_cond = not na(swh)

hprice = 0.0

hprice: = swh_cond ? swh : hprice[1]

le = false

le: = swh_cond ? true : (le[1] and high > hprice ? false : le[1])

if (le)

  strategy.entry("PivRevLE", strategy.long, comment = "PivRevLE", stop = hprice + syminfo.mintick)

swl_cond = not na(swl)

lprice = 0.0

lprice: = swl_cond ? swl : lprice[1]

se = false

se: = swl_cond ? true : (se[1] and low < lprice ? false : se[1])

if (se)

  strategy.entry("PivRevSE", strategy.short, comment = "PivRevSE", stop = lprice - syminfo.mintick)

//plot(strategy.equity, title = "equity", color = color.red, linewidth = 2, style = plot.style_areabr)



Read more here: https://stackoverflow.com/questions/64910692/to-add-a-delay-in-pivot-reversal-strategy-between-long-short-exit-and-long

Content Attribution

This content was originally published by Anderias at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: