0

The strategy is simply this.

Buy, 11/21/2022, 10.00 Sell, 11/23/2022, 11.00

So it simply buys on the 21st at $10, and sells on the 23rd at $11.

I will repeat this for other dates, but if I could just get that simple two-line strategy to work, I think I could easily repeat it.

I have searched extensively but could not find an example.

OahuRE
  • 66
  • 9

1 Answers1

0

You can use timestamp to do this :

AnneeDepart = input.int(2022, title='Start Year', minval=2020, step=1, group='Plage d\exécution')
MoisDepart = input.int(11, title='Start Month', minval=1, maxval=12, step=1, group='Plage d\exécution')
JourDepart = input.int(21, title='Start Day', minval=1, maxval=31, step=1, group='Plage d\exécution')
HeureDepart = input.int(10, title='Start Hour', minval=0, maxval=23, step=1, group='Plage d\exécution')
AnneeFin = input.int(2022, title='End Year', minval=2021, step=1, group='Plage d\exécution')
MoisFin = input.int(11, title='End Month', minval=1, maxval=12, step=1, group='Plage d\exécution')
JourFin = input.int(23, title='End Day', minval=1, maxval=31, step=1, group='Plage d\exécution')
HeureFin = input.int(10, title='End Hour', minval=0, maxval=23, step=1, group='Plage d\exécution')

if strategy.opentrades == 0 // No open order
    if time >= timestamp(syminfo.timezone, AnneeDepart, MoisDepart, JourDepart, HeureDepart, 0)
         strategy.entry("Long", strategy.long, limit=10)

if strategy.opentrades != 0
     if time >= timestamp(syminfo.timezone, AnneeFin, MoisFin, JourFin, HeureFin, 0)
          strategy.exit("Exit", "Long")
G.Lebret
  • 2,826
  • 2
  • 16
  • 27