- ago
Hello, I am in the process of migrating to Wealth Lab from a self-coded automated trading solution. If this topic has been discussed, please point to the correct thread.

Each day about 100–200 ticker symbols are loaded 15min before the market close. The then-current pre-close bar is appended to the historical bars. This series for each symbol is run against one of about 20 algorithms, using individual parameters. Backtesting used the comprehensive close, but over about a decade the use of 15min prior as today's close matches closely the backtest results.

Wealth Lab will offer valuable additional trading schedules that I don't have time to code myself. But my current algorithms are effective, and I wish to migrate them as closely as possible. Is it possible to do this using building blocks? I don't want to use 15min bars for the entire data input to the algorithm, just daily data with the the last bar being the pre-close value. I don't want to trade on the next open, either.

Most of my algorithms are as simple as possible (thus robust over a decade), some with just 1 or 2 parameters, so that building blocks would seem ideal. Alternately, is there a way to use building blocks, convert it to code, and then append a universal snippet of code instructing the algorithm to run 15min before the close, simultaneously retrieving and appending the current close to the historical date series?
0
275
19 Replies

Reply

Bookmark

Sort
ConeA
 ( 6.64% )
- ago
#1
Yes! Use the At-Close Processing feature of the Strategy Monitor.
Explained and demonstrated in the Build 99 Highlights Video: https://youtu.be/Z39A55OEudM

Also see F1 Help > Strategy Monitor topic for more details.

You'll need to give yourself probably 2 minutes or more to collect data for 200 symbols by polling for the Daily partial bar. Which broker do you use?
0
- ago
#2
Thank you, I will review the video. The current setup I use is only compatible with Interactive Brokers, but there are some other accounts such as Schwab that would be useful to trade as well. Currently, all the algorithms take at least 5min to complete prior to the market close.
0
- ago
#3
As some follow up questions, is this feature only available for sell and not buy orders?

When autotrading right before the close, is there a way to disable the subsequent analysis at the close?

In building blocks, when I use indicator compare to value, there is no option for bars ago (to combine with 1 bar in future). When I am able to use indicator compare to indicator, this does allow setting for 1 bar ago.
0
ConeA
 ( 6.64% )
- ago
#4
QUOTE:
is this feature only available for sell and not buy orders?
It's for Buy, Sell, and Cover. What gave you the impression that it was sell only?

QUOTE:
is there a way to disable the subsequent analysis at the close?
What analysis is that? This At-Close Processing is a Strategy Monitor feature only. There is no post processing of backtest results with visualizers, like in a Strategy Window.

QUOTE:
In building blocks, when I use indicator compare to value, there is no option for bars ago (to combine with 1 bar in future)
That one's a problem with the At-Close exit then because normally you can just add the "N Bars Ago" qualifier. But since you need the "1 Bar in Future" qualifier, you can't use both.

In this case for blocks, you'll need to use a Transformer Indicator OffsetInd. Add your indicator to OffsetInd, and set the "Offset bars" to the number of bars ago you want to test for.
0
- ago
#5
On the video there was mention only of this feature for closing positions.

The video noted that once the pre-close analysis was done (the decision to trade or not), a subsequent analysis would also imminently occur upon the close, allowing for trades to be placed for the next day’s open. If I don’t want to trade on the open I would need a way to disable this.
0
GlitchA
 ( 11.34% )
- ago
#6
If your strategy doesn't place orders for the next session open (market, limit, or stop orders) then you don't need to worry about it.

If your strategy does place these orders, then you want to override them and not place them? Hmmm, that's not supported, you'll just need to cancel those orders manually or deactivate the SM before it reaches that point. I mean, we can't keep adding options for every edge case otherwise things will get even more complicated than they already are.
0
ConeA
 ( 6.64% )
- ago
#7
The Strategy Monitor schedules the Next Run after the At-Close Signaling run. You can't stop the scheduling.
If you don't want it to run the regular scheduled run, just de-Activate it.
0
- ago
#8
Hello, I believe the building block specifies close, which would appear to prevent trading on a market open.

What is the best way to set up the building blocks so that the monitor can trade them as coded and match the backtest? Just do the 1 bar in future feature by itself?

Theoretically, the pre-close trade decision should be identical to the close decision, so that I would then not need to worry about conflicting trades 99+% of the time.
0
ConeA
 ( 6.64% )
- ago
#9
If your strategy only has At Close orders, then nothing (no trading actions) will happen on the other run.
0
- ago
#10
Hello, the blocks I will use for now will only be open and close trades at the close. In fact it would be quite interesting when and if the final, comprehensive close ever deviated enough that the preliminary close gave a 'wrong' signal.

As for fidelity between backtesting and actual trading, is there only the one way to set up the building block strategy so that I can autotrade with the same one I use to backtest?

I believe the indicated method is for the buy/sell next bar at market close with the '1 bar in future' added concurrently with 1 for 'How Many Bars ago'? Should I consistently do it exactly this way, or is there any variation?
0
ConeA
 ( 6.64% )
- ago
#11
Of course, use the same strategy. The only difference between backtesting and trading is that you get a signal when running At-Close Signaling for those blocks.

There will certainly be differences if your strategy depends on the actual closing price. At-Close Signaling gets the partial daily bar some seconds before the close. If the Close (or even the High and Low) differ at the actual close, you can get a different result.
0
ww58
- ago
#12
Does At-Close work with wealth-data? It's EOD afaik
0
ConeA
 ( 6.64% )
- ago
#13
Good question. Wealth-Data will return a partial bar, but it's delayed by several minutes. Consequently it's a bad choice for At-Close Signaling.

For Auto-trading, use your broker's feed for the Daily partial bar or another non-delayed service. That means for this trading purpose, that provider should be checked and in the Historical Provider list above Wealth-Data.



Keep in mind that it will take most providers 1 to 2 seconds to retrieve data for each symbol. IQFeed should be somewhat faster with parallel processing enabled.
1
- ago
#14
Thanks for all the input. I happened to notice in the Mar issue of TASC that the example used the '1 bar ahead' feature without selecting a 1 bar in the past on the 'PMA' indicator. If that exact example as printed were selected for live autotrading with at-close signaling, would trades go through properly, or must the 1 bar in the past also be added to the building blocks?

I will add in the past I found IB's data queries unreliable using the self-coded solution I have been using. I believe I am mainly using EODHD's delayed ticks and found trivial deviation for signals generated just prior to the close, even 10min prior to the close. But if IB data were reliable through Wealth Lab that could reduce deviations even further.
0
ConeA
 ( 6.64% )
- ago
#15
Re: the '1 bar ahead' feature without selecting a 1 bar in the past on the 'PMA' indicator.
I didn't see the Traders' Tip for that one yet (Glitch did it), but what do you mean about using 1 bar in the past? Got a picture?

Re: if IB data were reliable
"Them is fightin' words!" IB is slow, but it's not at all unreliable. Maybe the problem is the implementation?
0
- ago
#16
Here is the example from this month's issue. (I'm also testing to see if this image displays properly.)

0
- ago
#17
Here is a simplistic strategy (I meant to do 'lower than' on the sell block) using building blocks as in the TASC article. If above the moving median (using today's close as the last data point), then buy at that same today's close during backtesting. For live trading, buy 5 minutes (or other specified time) before the close, using a pre-close value for the last bar of the signal as well as the execution price.



The second image adds 'How many bars ago = 1'; but I worry this will cause the live trading to take yesterday's close, which would be stale and typically reduce the strategy return by at least a few APR points.



I gather the at-close live trading is a relatively new feature. When I had programmed my own code, it took me many months tediously to get all the +1, 0, or -1 offsets correct to match up the backtest to live trading. And so I am trying to debug this very carefully before I do all the building blocks. When implemented, Wealth Lab will be a great improvement in time spent and versatility over my old setup. Thanks again.
0
- ago
#18
By the way, on the subject of IB data, when I queried IB data, I would have excessively frequent fields with the dreaded '-1' output in various field and tired of writing endless error capture loops to re-query. I'll probably stick to EODHD or some other, since my algorithms don't appear to need hypercurrent data for the pre-close.
0
ConeA
 ( 6.64% )
- ago
#19
QUOTE:
I would have excessively frequent fields with the dreaded '-1' output in various field
I can't remember ever seeing a dreaded -1. Please send me a message with how to make that happen to info@wealth-lab.com. (You might be talking about a -1 error code? These are informational only and don't affect anything.)

Re: At-Close Signaling
Don't use Bars ago unless you want Bars ago! Sure, 1 bar ago would compare the current value of the indicator to the other indicator's value from 1 bar ago like it says in the block's Description.

The At-Close Signaling feature requests/adds a partial Daily bar to the BarHistory and treats it as if it were a complete end of the day, and then processes only At-Close signals. When the process is complete, the partial bar is removed and the regular Next Run is scheduled. The regular run will add the completed Daily bar to the BarHistory and process all other orders.
0

Reply

Bookmark

Sort