- ago
I can't figure out how to search for this, so if this question has already been asked I would be thankful for a link to that answer.

I am interested in testing my personal system and one of my investment criteria is the results of a backtest to date, and I'd like to replicate that process to make backtesting more accurately reflect my processes.

The question is if I am testing a portfolio approach to my backtest, I only want to take a position that has a positive backtest result prior to the triggered signal. For instance, I want to invest only in stocks that have a win rate of 50%+ and a Profit Factor >2 over the last 10 years (weekly bars).

Is this possible with the blocks available? If not, is it possible to code?
0
221
10 Replies

Reply

Bookmark

Sort
Cone8
 ( 23.86% )
- ago
#1
You could do it in a C# Coded strategy (quite simply), but could only be done with blocks if someone created (coded) blocks for that purpose.

For both we have the Concierge Service for custom programming jobs and consulting.
0
- ago
#2
Thank you... I will get my materials together and reach out to your Concierge Service.

Have a great day!
1
- ago
#3
QUOTE:
I want to invest only in stocks that have a win rate of 50%+ and a Profit Factor >2 over the last 10 years (weekly bars).

Both metrics are computed by the Backtester after all the trading is completed, so these metrics wouldn't be available until Cleanup{] or BacktestComplete{} after Execute{} completed all its trades.

I have thought about having BacktestComplete (or even a Performance Visualizer) write selected performance metrics to disk. Then have the MyStrategy{} constructor read in that disk file so these metrics are available for the next day's run (and bars). Just understand, when you fold a numerical analysis problem back onto itself, it's possible you might encounter some non-reproducible results from a stability prospective. With that said, it can be done.

What I would do instead is complie a custom dataset of all the stocks that do well with the performance metrics you like, then trade only from that dataset. And I'm doing that now. To compile such a performance dataset, you can vote for the following feature request. https://www.wealth-lab.com/Discussion/Symbol-Rankings-tool-9116

---
Off topic, but there is an existing PosSizer that trades based based on the quality (positive slope) of the equity curve. But I haven't used it. There's a forum topic that discusses it (if you search for it).
0
Cone8
 ( 23.86% )
- ago
#4
@superticker,
Sure, if you want the metrics for a complete backtest, then you wait for the end of the test. But if you want to know the win rate (for example) for a symbol in any given moment, you can calculate that after every bar quite easily. You don't need a scorecard to do that yourself.
0
- ago
#5
A lot of this is over my head. Still, I'm just basically interested in creating a series of backtests based on what I've been doing in real life over the years: I look at a stock that passes some very rudimentary fundamental criteria and then consider a purchase when my indicator triggers if it has tested well over the past. In most cases, I am considering about a 20-year backtest of the single issue before purchase, as well as a quick calculation of where my indicator would signal a sell to determine how many shares to buy.

I have a little pop-up box on my chart that shows the backtesting results of each stock, ETF, or index I pull up so that part's not hard and already taken care of.

Where I want to step it up is to look at it from a portfolio perspective and pick some random points in time as start times... pick the stocks that trigger as they trigger in the percentages determined until the portfolio is filled and then sell as sells are triggered only to buy the next buy that is triggered and so on.

To me, this should be able to be automated enough to run a series of backtests of different lengths and different start dates to give me what I believe would be a more accurate picture of "system" performance versus "strategy" performance.

Not sure if all of this clarification helps, or just muddies the water, but that's what I'm working on trying to figure out.
0
- ago
#6
QUOTE:
consider a purchase ... if it has tested well over the past. ..., I am considering about a 20-year backtest of the single issue before purchase

Well, this is the issue. What is an acceptable N (#of trades) for calculating each merit metric? Do not think in terms of years, but think in terms of the minimum acceptable N value for calculating each merit metric.

A cleaver way to solve this is to inherit a Child Backtester from the main Backtester class so the Child has all the methods of the main Backtester plus it has a method to control the most recent N trades for each stock and passes only those trades up into the Positions collection for the ScoreCard to evaluate. Then you'll have all the performance metrics for the most recent N trades of each stock. Of course, you would want to be able to select your value of N.

Because of execution overhead, the Child Backtester should also take a "limited" ScoreCard object as a parameter because you only want to calculate the salient metrics that matter most to you, and nothing more. Also the Child Backtester may only want to calculate those metrics for Long trades (unless you're doing Short trades as well; i.e. Total trades).

If you make this a Feature Request, I'll vote for it.
0
- ago
#7
QUOTE:
For instance, I want to invest only in stocks that have a win rate of 50%+ and a Profit Factor >2 over the last 10 years (weekly bars).

Looks like a use case for StrategyRunner.
0
Cone8
 ( 23.86% )
- ago
#8
QUOTE:
Not sure if all of this clarification helps, or just muddies the water, but that's what I'm working on trying to figure out.
It certainly does. Programming requirements are everything. Initially, it sounded [to me] like you only wanted to filter symbols today by metric thresholds known a priori.

Now it sounds like a large backtest that runs series of backtests (multiple times within the larger backtest) and uses the latter's results for trading decisions.

superticker and Eugene have the right idea. The StrategyRunner (Post #7) is a class that the strategy would use run individual backtests (at some chosen interval), to determine if the symbol's metrics met the thresholds to be included in the main test.

Again, this could be implemented in blocks, but doing that probably at least doubles the job.
0
- ago
#9
@Cone: I've taken your advice and contacted you via the link and the email within that link. Thank you for recommending that.

How often do you check/respond to requests sent to that email?

Thanks, Jeff
0
- ago
#10
Hi Jeff,
I'll proceed to coding your C# strategy tomorrow.
0

Reply

Bookmark

Sort