How to buy tomorrow at open?

Posted By: frutza

How to buy tomorrow at open? - 06/01/23 19:58

During backtesting, it seems that the enterLong() or enterShort() functions enter trades at the CLOSE of the next day (after a buy or sell signal was generated today by whatever strategy is used).
How can I enter a trade at the OPEN of the next day?

Thank you in advance! Any answer and/or example is highly appreciated, as I couldn't find anything in the manual or this forum.
Posted By: vicknick

Re: How to buy tomorrow at open? - 06/02/23 03:19

Maybe you could run tick() once at the end of each bar? This will trigger the function upon the next incoming price tick (which should be the open of the new bar).
Posted By: frutza

Re: How to buy tomorrow at open? - 06/04/23 21:06

Sound interesting, although a bit complicated. Can you please provide a code example? Thank you, much appreciated!
Posted By: Mishiwaka

Re: How to buy tomorrow at open? - 06/05/23 09:21

Hard to say without seeing a code, but my suggestion will be to go to the lower timeframes and apply something like
if (hour(0)==0) cycle, but anyway if a signal would not be generated before the day opening that will be no deal.
Posted By: jcl

Re: How to buy tomorrow at open? - 06/05/23 14:16

You need normally no complex code. For simply entering at the next bar open, set Fill = 3.

https://zorro-project.com/manual/en/fill.htm
Posted By: frutza

Re: How to buy tomorrow at open? - 06/06/23 02:26

Thank you all for your replies. Interesting, and much appreciated!

JCL, thank you for coming to the rescue. Fill = 3 is EXACTLY what I was looking for. Does this work the same on any bars, or only on daily bars? I couldn't figure out the answer by reading the page you indicated. Thanks in advance!
© 2024 lite-C Forums