Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am noticing that when I run the strategy performance report on many of my strategies in easylanguage, the manual maxbarsback setting I use can change the equity performance, even though in all cases the settings are far higher than the number of bars back the strategies actually need to reference. I want an accurate backtest, so what are everyone's thoughts?
if PctChg <= PctChgThreshold1 and PctChgOrder = 0 then begin
buy ("PctChg") 1 contracts next bar at market;
PctChgOrder = 1;
end;
if PctChg > PctChgThreshold2 and PctChgOrder = 1 then begin
sell 1 contracts from entry ("PctChg") next bar at market;
PctChgOrder = 0;
end;
Here I was backtesting to 1998 on the ES hour chart. If my manual maxbarsback setting is 10,000 or 15,000 or 20,000 or 50,000 etc. I get slightly different performance results even though my length is only 146.
Can you help answer these questions from other members on NexusFi?
Of course, the bar settings in the item: maxbarsback, correspond to the number of bars (10,000 or 15,000 or 20,000 etc...) that are excluded before the software (Tradestation or Multicharts) starts to calculate the strategy;
in fact the signals will start (and appear) after the number of bars indicated in: maxbarsback:
You can see the associated maxbarsback settings for a set of strategies I have been working on, with the largest parameter being a Length of 3,000 for one of the strategies. Why does the maxbarsback setting change the performance of the strategy set since 1998 if the largest strategy only references 3,000 bars?
Why does the maxbarsback setting change the performance of the strategy set since 1998 if the largest strategy only references 3,000 bars?
Because the number set in the: MaxBarsBack corresponds to the number of bars excluded from the strategy, therefore, the strategy starts to work after 5,000 or 10,000 or 20,000 bars and therefore the results change because the first 5,000 bars (or 10,000 or 20,000 bars, etc...) are not considered.
Looking at the Equity, you will see that the first image set at 5,000 has 3,000 Trade Numbers, while the last Equity set at 100,000 has 600 Trade Numbers.
Why does the maxbarsback setting change the performance of the strategy set since 1998 if the largest strategy only references 3,000 bars?
Because aren't 3,000 bars, but are 3,000 Trade Numbers (3,000 signals between buy, sell, sellshort, buytocover); the bars are more than 100,000 otherwise if you set the Maxbarsback to 100,000, you would have no buy or sell signal.
To compare different strategies and evaluate them with backtests with the same characteristics, you can set the backtest with a certain period (e.g. from 1998 to 2019) and the MaxBarsBack always the same for each backtest (e.g. 5,000 bars).
The classic method to evaluate strategies is to perform a first backtest in a set period (e.g. from 1998 to 2019) and after obtaining a first optimization of the parameters, perform another backtest in a new period (e.g. from January 2020 to date) to check the validity of the previous backtest.
If the results obtained in the various backtests are interesting, it will be necessary to carry out for a few months the so-called: paper trading in real time, to verify the robustness of the strategy.
Better still, divide the backtest into 3 parts: example from 1998 to 2008, from 2009 to 2019 and from January 2020 to date,
then, perform the first backtest from 1998 to 2008, and then after having optimized the parameters of the first backtest, perform the other 2 backtests with those optimized parameters (always with the same MaxBarsBack for each backtest) to check if the results of the strategy are quite constant.
A professional example to evaluate a strategy is the following:
I still don't understand. In the first example I gave, the maximum length was 146 and the total trade number since 1998 with a MaxBarsBack of 146 was about 450. (Under 146 and it says no trades were made.) But look at what happens when I start increasing the MaxBarsBack setting...
Also, to be clear, this is the "maximum number of bars study will reference" setting in the General tab of the Edit Strategies/Properties for All... window. Correct? Are there any other settings I need to pay attention to here?
Ok everyone, I've had a new thought about what might be going on here. Does the MaxBarsBack basically determine after what period of bars the study/strategy will begin working? Because from the starting point, it has to let that many bars pass before the indicators become active, since I'm telling it to have a max reference of that many bars back, even if the actual number of bars used by any indicator is way less than the MaxBarsBack setting?
That's right in fact, in the images set from 146 to 5,000, the number of trades made is about 450, but in the following images, from 10,000 to 100,000, the number of trades made decreases from 400 to 60, because increasing considerably the number of MaxBarsBack (the number of bars excluded from the test), also decreases the number of trades made.
However, you should always set the MaxBarsBack with the number of bars as close as possible to the maximum number set in the Strategy (example: PctChgLength(146), MaxBarsBack 150) to use the maximum number of your historical data.