Simulate trading shortly after market open with daily bars

Posted By: MegaTanker

Simulate trading shortly after market open with daily bars - 09/07/21 20:40

Using daily bars, I want to simulate running a script somewhere shortly after the market open, so the open price is the last thing the script processes and then it enters/exits near this price as well (With much more slippage).

Fill = 3 lets me delay entries until the next price quote but if using this method the script would have to assume the next day's open is equal to the previous close but it trades stocks where gaps can be huge between the last close and the current open.

Is there any way to do this?
Posted By: Smon

Re: Simulate trading shortly after market open with daily bars - 09/09/21 16:28

Maybe BarOffset could help you, but I think it changes the D1 bars completely. You could go to a lower bar period and use Timeframe

The most robust implementation I found is

Code
TimeFrame = frameSync(1440 / BarPeriod);

//do your D1 stuff here, like
//PricesD1 = series(priceOpen());

TimeFrame = 1;

//make your trades here
Posted By: Petra

Re: Simulate trading shortly after market open with daily bars - 09/10/21 16:07

The obvious way to do that is intraday bars but if you have only eod bars you can use Fill = 3 but get the price from priceOpen(-1). You also need the PEEK flag.
© 2024 lite-C Forums