[R-SIG-Finance] Entry + exit on the same bar? allowMagicalThinking?

Brian G. Peterson br|@n @end|ng |rom br@verock@com
Wed Jun 22 13:53:21 CEST 2022

quantstrat will not allow you to enter and exit on the same bar.  

you need to open a position, generate a new signal, and send a new

hourly data is widely available with a reasonable history, often for
free.  use better data.

Brian G. Peterson
ph: +1.773.459.4973
im: bgpbraverock

On Tue, 2022-06-21 at 22:06 +0000, Mike wrote:
> I like to backtest this strategy on EOD data:
> 1. If a long/short signal occurs on day 0 (signal day) then
>   enter long/short on day 1 if the price exeeds signal day's high
>   (long) or drops below signal day's low (short).
> 2. On execution of the entry order issue 2 exit orders combined by
>   OCO:
>   a. Stop loss at x% of entry price
>   b. MOC of entry day (later I also like to backtest longer periods)
> So the basic strategy holds the stock/asset for one day only (=one
> bar).
> Is there a way to exit on the entry bar anyway?
> How would I to this by setting allowMagicalThinking=T?
> Or can I trigger entry and the 2 exit orders by the same sigcol?
> Would I have to make the entry rule non-path-dependent to have it
> executed before the exit rule?
> Mike
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R
> questions should go.

More information about the R-SIG-Finance mailing list