NexusFi: Find Your Edge


Home Menu

 





MaxBarsBack changes performance report


Discussion in EasyLanguage Programming

Updated
    1. trending_up 4,520 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 14 attachments




 
Search this Thread

MaxBarsBack changes performance report

  #1 (permalink)
Devin Sheets
Salem, Oregon
 
Posts: 10 since Jun 2020
Thanks Given: 0
Thanks Received: 2

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?

Here is an example code:

inputs:
Price(Close);

variables:
PctChgLength(146),
PctChgThreshold1(2),
PctChgThreshold2(3),
PctChg(0),
PctChgOrder(0);

PctChg = 100 * PercentChange(Price, PctChgLength);

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.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Quantum physics & Trading dynamics
The Elite Circle
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #2 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

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:

https://financestrategysystem.com/easylanguage-tutorial-max-bars-back/

Maximum Number of Bars Study Will Reference Setting

Reply With Quote
  #3 (permalink)
Devin Sheets
Salem, Oregon
 
Posts: 10 since Jun 2020
Thanks Given: 0
Thanks Received: 2


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?

Attached Thumbnails
Click image for larger version

Name:	5000.png
Views:	230
Size:	94.6 KB
ID:	301696   Click image for larger version

Name:	10000.png
Views:	206
Size:	104.6 KB
ID:	301697   Click image for larger version

Name:	20000.png
Views:	212
Size:	106.4 KB
ID:	301698   Click image for larger version

Name:	40000.png
Views:	201
Size:	107.6 KB
ID:	301699   Click image for larger version

Name:	80000.png
Views:	211
Size:	128.7 KB
ID:	301700   Click image for larger version

Name:	100000.png
Views:	194
Size:	109.6 KB
ID:	301701  
Reply With Quote
  #4 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

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.

Reply With Quote
  #5 (permalink)
Devin Sheets
Salem, Oregon
 
Posts: 10 since Jun 2020
Thanks Given: 0
Thanks Received: 2

I don't understand. But regardless, what setting should I use to have an accurate backtest?

Reply With Quote
Thanked by:
  #6 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

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:

[img]https://i.postimg.cc/k4YkPkDC/Test-per-Trading-System.jpg[/img]

There are excellent books to explore the valuation of Trading Systems:

- The Evaluation and Optimization of Trading Strategies (Robert Pardo)

- Trading Systems 2nd edition: A new approach to system development and portfolio optimisation (E. Tomasini-U. Jaekle)

- Trading System that Work (Thomas Stridsman)

- The Ultimate Trading Guide (G. Pruitt, J. Hill)

- Building Winning Trading Systems with Tradestation - 2a ed (G. Pruitt, J. Hill);

In these last 3 books, there are the complete Easylanguage codes of different Trading Systems.

Reply With Quote
  #7 (permalink)
Devin Sheets
Salem, Oregon
 
Posts: 10 since Jun 2020
Thanks Given: 0
Thanks Received: 2


Shaban View Post
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.

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?

Attached Thumbnails
Click image for larger version

Name:	146.png
Views:	205
Size:	104.1 KB
ID:	301713   Click image for larger version

Name:	500.png
Views:	201
Size:	105.2 KB
ID:	301714   Click image for larger version

Name:	1000.png
Views:	201
Size:	103.9 KB
ID:	301715   Click image for larger version

Name:	5000.png
Views:	196
Size:	103.8 KB
ID:	301716   Click image for larger version

Name:	10000.png
Views:	218
Size:	101.1 KB
ID:	301717   Click image for larger version

Name:	50000.png
Views:	197
Size:	115.9 KB
ID:	301718   Click image for larger version

Name:	100000.png
Views:	206
Size:	96.4 KB
ID:	301719   Click image for larger version

Name:	Screen Shot 2020-06-14 at 5.48.41 AM.png
Views:	205
Size:	26.4 KB
ID:	301720  
Reply With Quote
  #8 (permalink)
Devin Sheets
Salem, Oregon
 
Posts: 10 since Jun 2020
Thanks Given: 0
Thanks Received: 2

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?

Reply With Quote
  #9 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

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.

P.S: You have a PM.

Reply With Quote
  #10 (permalink)
Devin Sheets
Salem, Oregon
 
Posts: 10 since Jun 2020
Thanks Given: 0
Thanks Received: 2


Nice, thanks. I appreciate everyone's patience with me. This was a very helpful forum.

Reply With Quote




Last Updated on June 14, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts