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
0
votes
0 answers

Pinescript 1m backtesting

When trying to backtest my strategy on 1min timeframe I am only able to do so on the most recent 7 days. Is it possible to stretch this over more candles? I have even attempted to customise a time period using inDateRange = (time >=…
0
votes
1 answer

How to trigger crossover AND price above security in Pine Editor

I have been trying to research how I can trigger LONG and EXIT from both crossover and price above security in my backtesting logic without luck and ask now for assistance with my backtesting pine editor code. I will include some parts of my code so…
Rafal
  • 37
  • 1
  • 11
0
votes
1 answer

Intraday time window backtesting Pine script

How can you backtest your strategy only within a specific time window on an intraday basis? I'm testing a combination of MACD and BB on a timeframe of 1 minute. But I only want to enter a long or short position at UTC+2 between 10am and 1430 and…
Bas
  • 1
  • 2
0
votes
1 answer

PineScript (TradingView) Strategy Close trade after X mins

I've composed a simple script and want to insert a couple of conditions to close the trade. Either it hits the stop loss / take profit or after 30mins the trade is closed. I have done the the stop loss / take profit part, I need assistance with…
hello11
  • 115
  • 4
  • 15
0
votes
0 answers

Test Daily Timeframe strategy on strictly defined historical 15min data

I have a strategy that calculates entry/exit criteria based on Daily timeframe, but I use 15min timeframe to actually trade against those daily values. It works fine, EXCEPT when I try to go farther back in time to backtest than the current 15min…
Geewhiz
  • 3
  • 2
0
votes
1 answer

Regarding a buystop order which is not executed in the next candle in pine script

I was trying to backtest a breakout strategy. The problem is when the longCondition is met, buystop is triggered. But this buy order if not fulfilled in the next candle looks for signals in the following candles. How to stop looking for fulfillment…
Abhay Sahu
  • 11
  • 2
0
votes
1 answer

how to get a price that the order was submitted backtester python

Here is my code class TestStrategy(bt.Strategy): params = dict( stop_loss=0.02, # price is 2% less than the entry point trail=False, ) def log(self, txt, dt=None): ''' Logging function fot this strategy''' …
YanRemes
  • 347
  • 2
  • 10
0
votes
0 answers

How to enter position with fractional share value Pinescript tradingview

how can I enter a trade with a fractional amount. For example, at the end of each bar, I want to buy $25 dollars worth of the share. How can I do this when the stock is well above $25. Does pinescript support entering a position with fractional…
0
votes
0 answers

pandas.core.base.SpecificationError - Resample

Code: from __future__ import(absolute_import, division, print_function, unicode_literals) import backtrader as bt from datetime import datetime, timedelta import pandas as pd import csv import numpy as np import math csvframe =…
0
votes
1 answer

Pyramiding trades with independent take profit (Pinescript)

Let's say I have 1 long signal. Take profit is set to 10% (not yet reach). Then, I have another long signal (same condition). I want to set 10% of take profit like the other one. I want each trade to have independent take profit because entries…
Mathieu
  • 797
  • 2
  • 6
  • 24
0
votes
1 answer

How do I analyze the back tested strategy either it is optimized or not?

I have back tested the one of the strategy and results are shown below. Should I consider this as optimized? I do see a draw down also significantly high. I referred the pine script documentation to analyze. But, I couldn't understood clearly.
ramkumar-yoganathan
  • 1,918
  • 3
  • 13
  • 29
0
votes
1 answer

Determine a fixed, defined period / value, Pine Script

How can I set a defined value. In backtesting, the bars are processed from back to front. Is it possible in Pine Script that, for example, a certain function is always carried out on the last 3rd bar. for example: IF 3rd bar from the front THEN x: =…
Pit
  • 21
  • 3
0
votes
1 answer

Back Test - Check if previous candle has variable or shape was plotted

Im trying to back test and open positions when hidden divergence is detected followed by a stochatic cross up or down. I'm using this script to detect divergence which just sets a variable pos_hid_div_detected or neg_hid_div_detected when hidden…
AfromanJ
  • 3,922
  • 3
  • 17
  • 33
0
votes
1 answer

RuntimeWarning on a financial backtesting program

I'm trying to backtest a trading strategy using the bt library by using one of the examples presented on their web page (I'm not retrieving the data as presented due to the bt.get() function not working. But here is the code that I'm using (I know…
0
votes
2 answers

Python finding reoccuring values in list (backtesting)

and thanks in advance. my problem is the following: I wanna analyse a dataframe (list) consisting of only e.g. "x" and "y". only if "x" is given in three consecutive indizes I want to get a statement that gives me the index of the third time when…
tetter
  • 9
  • 1