- ago
Curious about what I'm seeing. I'm literally using the Date Filter in Power Pack in Building Blocks to enter a trade based on a specific date to test this:

Buy if Date is >= 9/29/2022

Changing the Strategy Settings Basis Price from Market Close this Bar to Market Open Next Bar does not seem to change the Entry Price in Backtest Results Positions. It is always using an Entry Date of 9/30/2022 with the Opening Price of 9/30/2022. I'm confirming this by looking at the Chart tab.

Using symbol SPY for my test. Also, I have set Margin Factor == 1.30 and Max Open Pos == 1. Retain NSF Positions is Unchecked. Are the other settings.

When Strategy Settings Basis Price == Market Close this Bar I would have expected that Date Filter to use the Closing Price of 9/29/2022 or 9/30/2022 but definitely not the Open Price of 9/30/2022.

0
391
17 Replies

Reply

Bookmark

Sort
- ago
#1
There wasn't a gap on Sep 30 in SPY. You have a lot of margin (1.3) to take any trade. Thus, you won't see an effect of this option on this date - even if the position size was set to 100% equity. There's simply enough capital to take the trade.

But since you didn't tell anything about your position size, I wonder what are you expecting this option to do?
0
Cone8
 ( 25.44% )
- ago
#2
Please see Help (F1) > Strategy > Strategy Settings | Basis Price about how it's used.

Hint: It does not change the way a strategy enters a position - at least not directly.
0
- ago
#3
(Position size is just set to 100% of equity, and Margin Factor == 1.30)

Thanks. Sorry if my original question was unclear.

I would prefer if I could *never* have a backtest use an Opening Price in a backtest (Opening Prices on historical data are sometimes not the greatest from a realistic perspective).

Is there a setting to ensure that *only closing prices* are used in a backtest for both entry AND exit prices? I don't care whether it's the closing price of the signal bar OR the next day's closing price - just that it's a closing price.

Thanks!
0
- ago
#4
As both Cone and I suspected, you're looking in the wrong place. So your real question is answered in the website FAQ > "How can my strategy from Blocks enter or exit at close?"
0
- ago
#5
Thank you. In my humble opinion the UI does not make this clear. My .02. I appreciate that it's in the FAQ and other info is in the F1 help, but for the new user who hasn't read every single piece of content across various places that WL has this documented, it's pretty frustrating. Especially the variations between Blocks and C# capabilities. I understand the complexity, it's just frustrating, and I can clearly tell you're similarly frustrated with receiving these questions.

Sorry for the rant. Again just my .02 for someone who can really only use this software every now and then and am not living in it everyday. It really is great software, just now where I can spend all my time figuring out the nuances.
0
Glitch8
 ( 11.81% )
- ago
#6
We appreciate the feedback from the perspective of a new user! Eugene, let's try and put ourselves in a new user's place and temper our responses :D
0
Cone8
 ( 25.44% )
- ago
#7
@jtrader2020 - tips:

1. When you need more information about an option you're working with, strike the F1 key. Chances are the page that pops up with have an explanation or more info.

2. It sounds like you're not a fan of opening prices - and neither am I for any provider except Wealth-Data. Instead of the first full-lot trade after 09:30:00 that occurs on any exchange, the Wealth-Data open is the primary market opening print, which is the result of the opening auction. The result is that if you trade with the special Market On Open (MOO) order (see Preferences > Trading > Special Order Types), you will participate in the auction and receive the opening price on the primary market.

I don't know if that's enough to sway you, but for more information about the best end-of-day data for backtesting and trading, see https://www.wealth-data.com (Wealth-Data is free with WealthLab).
0
Glitch8
 ( 11.81% )
- ago
#8
Also consider the complications of trading based on closing price of the CURRENT bar.

- First of all, indicators can't even be calculated until the closing price is complete, and by then it's too late to place the order.

- If you decide to get a partial indicator calculation like maybe 10 minutes before the close, and then place your orders based on that, who's to say the market doesn't reverse and render your orders incorrect?

- Now imagine trying to do all of that when trading 100 symbols.

0
- ago
#9
Yes, I understand all of the gotchas with using closing prices on the same bar an indicator is computed, but consider something as simple as Buy at the Close of the Last Day of the Month and Hold through Day 3 of the following month? Not so simple to currently implement even using Date filters + the Order timing in Blocks. (not my real strategy, obviously, just a simple example of a calendar based, not indicator based, type of logic)

Also, as far as intraday goes and the price variation between say the closing price of current 1-hr bar vs the opening price of the next 1-hr bar is likely to be no more or less variable than using that opening price. I'm talking actual confidence interval probability based likelihood and my willingness to accept slight imprecision for the benefit of an order of magnitude greater simplicity. I know how to work around all this stuff, and I wish I knew C# as well as I know Python/R, but for now sadly I'm stuck with Blocks as I have no bandwidth to dive in the C# side of things.
0
Glitch8
 ( 11.81% )
- ago
#10
Understood - perhaps it's time to consider creating those AtClose Blocks for the PowerPack.
0
- ago
#11
That would be a great addition to PowerPack, IMO. Perhaps these Order Timing conditions could just be a Condition Block that could be dragged into the Buy at Market Block, for example.
0
- ago
#12
For now it's pretty easy to modify a finished Blocks strategy if you 1) open it as C# code and 2) apply the minimal tweak from the link in Post #4.
0
- ago
#13
Thanks for confirming that as a simple workaround, Eugene. Yes, I have done this and it *does* in fact work for me. It's definitely the approach I will take for now - Basically I have to finalize my strategy in Blocks and then just open it as a C# strategy to do the tweak. It doesn't really let me iterate on the strategy logic in Blocks after the MarketClose tweak is made in C# but that's fine for now.
0
Glitch8
 ( 11.81% )
- ago
#14
Eugene, this sounds like a valid use case for AtClose Blocks in the Power Pack, could you make it happen?

To be clear, I think the blocks should the titled:

"Buy Next Bar at Market Close"

to avoid possible confusion in users thinking they work on the current bar.

With these blocks you'd at least be able to more easily so something like:

Sell Next Bar at Market Close
- when the next bar is the last trading day of the week/day
0
- ago
#15
Thanks all for looking into adding this to Blocks.

@Glitch,
per your recommeded naming/implementation: Is it possible to support this both for Buys *and* Sells? (You specifically mentioned *Buy* in your description of the implementation, so I just wanted to check). E.g ""Sell Next Bar at Market Close"
0
- ago
#16
Sure, let's add them in next build.
0
- ago
#17
Added to PowerPack's upcoming B14.

QUOTE:
- when the next bar is the last trading day of the week/day

Just to clarify to any user interested: in Blocks based strategies, this (last/first trading day of week/month) is accomplished using the TradingDaysLeft indicator.
0

Reply

Bookmark

Sort