Questions tagged [back-testing]

( in Quantitative Finance, AI, ML, ... ) A systematic approach to put a System-under-Test [ SuT ] into a state, where historical data ( a known part of both the evolution of inputs and the eco-system responses ) are used & fed into a SuT so as to review it's behaviour in-vitro ( as opposed to a forward-testing )

( in Quantitative Finance, AI, ML, Technical Cybernetics, Modelling ... )

Back-testing

is a systematic approach to put a System-under-Test [ SuT ] into a state, where historical data ( as a known part of both the evolution of inputs and the eco-system responses ) are used & fed into a SuT so as to review it's behaviour in-vitro ( as opposed to a forward-testing ).


Strengths & Weaknesses

The concept of back-testing relies on an a-priori belief ( a proof of which is left on the reader ) that the SuT does not intervene with the environment's generalised dynamics.

In other words, back-testing assumes that the SuT does not influence the future evolution moves ( the very steps that were recorded in the Historical Data, that are being fed into the SuT during the flow of back-testing ) that the outer ecosystem, surrounding the SuT, actually undertook in the past.


Tools

Strategy Tester, Quantopian, Quant Modeller, Quant Strat, AmiBroker, TradingView, MultiCharts
and many more


Historical Data

Quandl, Olsen Data, Dukas Copy, Yahoo! Finance, Google
and many more

255 questions
2
votes
1 answer

Pinescript, trailing stop loss repaints

Why does a simple Trailing Stop Loss in pinescript repaint this hugely? I am doing some backtesting on ETH/USD, 1H on Tradingview using pinescript version 4. The complete script is shown below: //@version=4 strategy(title="Simple SL script",…
Casper Nybroe
  • 1,179
  • 3
  • 23
  • 47
2
votes
2 answers

Python ZIPLINE:_RunAlgoError: No ``benchmark_spec`` was provided, and ``zipline.api.set_benchmark`` was not called in ``initialize``

This is my First Question Here, Excuse me for my mistakes I have been reading Andreas Clenow's Trading Evolved, a Book about Backtesting and Finance using Python Here is the Code that and error that I receive %matplotlib inline # Import Zipline…
2
votes
1 answer

Backtesting trading strategy using backtesting.py

I want to backtest a trading strategy. Its relatively simple. Just buy a stock at a start price. Immediately set a sell order at an exit difference above and a buy order at an entry difference below. I want it to continue till a max open lot…
Omkar Bhutra
  • 21
  • 1
  • 2
2
votes
1 answer

Is it possible to backtest trading algorithms without using backtesting libaries?

So my questions is, are there functions within basic python libaries(such as pandas, numpy, matplotlib) to backtest without using backtesting liabries(such as pyalgotrade, backtesting.py and zipline). So could you backtest by just using basic…
benito.cano
  • 797
  • 1
  • 8
  • 23
2
votes
1 answer

What is the cause of the "No Data" error when backtesting in Trading View a strategy written in Pine Script?

I wrote a strategy in Pine Script in order to backtest it on Trading View. It seems it compiles with no error but when backtesting it says "No Data". I can't figure out what is wrong with my code and I will show to you. The Strategy consists of two…
Marco Consiglio
  • 133
  • 2
  • 7
2
votes
0 answers

TypeError: unsupported operand type(s) for +: 'slice' and 'int' with bt backtesting

I'm trying to backtest a simple strategy with a library called bt. Bt throws the TypeError: unsupported operand type(s) for +: 'slice' and 'int'. I can't seem to figure out why. Code and full error below. Despite maybe being library specific, I was…
Alexander Thomsen
  • 459
  • 1
  • 4
  • 16
2
votes
1 answer

Why are simulated stock returns re-scaled and re-centered in the “pbo” vignette in the pbo (probability of backtest overfitting) package in R?

Here's the relevant code from the vignette, altered slightly to fit it on the page here, and make it easy to reproduce. Code for visualizations omitted. Comments are from vignette author. (Full vignette:…
2
votes
1 answer

Access to forward-testing statistics

I'm using the TesterStatistics() function (called from the OnDeinit() function) to export various strategy-testing statistical values: void OnDeinit(const int /*reason*/) { int h = FileOpen("results.txt",…
manlio
  • 18,345
  • 14
  • 76
  • 126
2
votes
0 answers

Dual Moving Average Crossover monthly

I am building a simple trading strategy using a dual moving average crossover on a monthly basis. I am using the simple 2-month MA and the 10-month MA. If 2Ma crosses above the 10Ma, then buy if it crosses below, then sell. The problem is that my…
marya
  • 31
  • 3
2
votes
1 answer

Keep getting the "dims do not match the length of object" in quantstrat

I have been modifying a backtest I made a few months ago using quantstrat. It was all working fine until I added in signal and rule 6 (donchian channel low) My full code is below. Any help would be greatly appreciated. Thanks in advance. PS: Sorry…
Cameron Giles
  • 72
  • 1
  • 8
2
votes
1 answer

Limit number of Position in Quantstrat

I have been scratching my head for the last few days trying to understand how to limit the number of position in a strategy. Its a channel breakout strategy (go long/shirt the 20d breakout channel with a 10d high/low stop loss. I don't want the…
NicolasB
  • 83
  • 5
2
votes
1 answer

R: run parallelized backtest

I need to run lengthy and computationally intensive backtests in parallel. My backtests take an average of 8 hours to run and I need to run 30 of them. They all call the same function with different inputs. What I was able to find so far is the…
2
votes
4 answers

Reversed array with MQL4

With MetaTrader Terminal ( MQL4 ), I try to have a reversed array, that I append ( prepend ) items to. So, on every tick, myArray[0] becomes the 'newest' value, and the previous value shifts to myArray[1] and so on. But its harder then it sounds. I…
DutchKevv
  • 1,659
  • 2
  • 22
  • 39
1
vote
1 answer

Move profit target and stop loss after initial profit target is hit in amibroker

I have the following amibroker afl backtesting code with stop-loss set at 10 points and profit target set at 20 points. long_entry_condition = close > EMA(close, 50); Buy = long_entry_condition; BuyPrice = Close; risk =…
user3848207
  • 3,737
  • 17
  • 59
  • 104
1
vote
0 answers

How to place a Futures Market order with Take Profit and Stop Loss using python

I'm using backtesting package for testing my trading bot but struggling to place Take Profit order along with buy order using python. Fow now I am using following python code for buy orders like: def support_trade_level(self, support,…
1 2
3
16 17