Backtest

General Information

The Backtest has been implemented as a key feature for analyzing the performance of a strategy on a historical basis. It is possible to backtest a strategy for a single instrument (security) or instrument list (portfolio).

Running a backtest will require:

With AgenaTrader Discovery and higher: AgenaTrader++ (plusplus) strategy.

In order to open the backtest window select Backtest by using Main -> New.

Workflow: ● Choose your Analyzer Session in SetupEscort ● Define your Entry-, Stop- and Target-parameter in SetupEscort ● Choose Main / New -> Backtest ● Choose your strategy in “General Options” (e.g.: AT++) ● Choose a data source, e.g. “Datafeed” or “File with ticks” (you need to download and/or select from file) ● Define a timeframe ● Select an InstrumentList (optional: you can additionally choose one specific instrument by simply clicking on it) ● Set start and end times (date and time) ● Go to the tabs and click on “Settings” ● Choose your entry signal in “Backtest Parameters” and check if stops and targets match your settings in SetupEscort. Yet you have the chance to chance those settings here. Confirm by clicking “Save Setup”. ● Go to “Parameters” and choose your Analyzer Session ● Define other settings like amount of bars, buying power and so on. ● Confirm by clicking “Save Setup”. Please note: If you have changed your setup in “Backtest Parameters”, you overwrite your settings in SetupEscort when clicking “Save Setup”. ● Start your backtest by clicking “Run”. Now you can choose if you want to backtest your strategy on a selected instrument or on the whole list. ● In the area below your InstrumentList you can watch the progress of calculation or stop it.

General Options

The Input Tab allows the following settings:

Result tab offers the following possibilities:

Settings tab

This tab shows two types of strategies: 1. Self programmed or imported strategies

The parameters of the strategy can be edited.

Additional parameters:

  • Buying Power

  • Cash Value

  • Commission

  • Slippage

2. AgenaTrader++ Strategies The AT++ parameters are mainly the same as the above, with just a few slight differences:

  • The Backtest Parameters category contains the parameters from the Setup Builder

  • The Parameters category allows you to select an Analyzer Column session from the Setup Builder

  • It is possible to save the manually edited settings with the Save Setup button

    • Saving the setup will overwrite the Setup Builder.

The following functions are available under the category "Trading":

Data Source

Possible options are: - Datаfeed (e.g. YFeed etc. or a datafeed from a broker) - File with Bars - File with Ticks

File format and data format for data from a file:

File with Bars: .csv and .txt

File with Ticks: .csv and .txt

Charts tab

The Charts tab is divided into the equity curve and the chart history. The equity curve contains information either about one instrument (security) or an entire instrument list (portfolio), while the chart history is always for one instrument only.

The functions Show, Equity and X Axis are only available after a backtest has been generated.

Equity curve representation

  • If the option Show All is active, the equity curve shows all trades of the backtesting result.

  • If the option Show Chart is active, the equity curve shows all trades within the charting history area (zoom).

In the same manner:

  • If the option Show All is active, then results of the tabs Summary, Trades, Orders, Executions, Periods and Trading Info are calculated for all trades.

  • If the option Show Chart is active, then results of the tabs Summary, Trades, Orders, Executions, Periods and Trading Info are only calculated for those trades within the charting history area (zoom).

  • Equity Single: displays only the selected instrument

  • Equity All: displays all instruments of the instrument list (portfolio) and draws a curve for each instrument.

  • Equity Account: displays all instruments of the instrument list (portfolio) in one curve.

Please Note! The options Show All or Show Chart have no impact if the Equity options are set to All or Account. The above mentioned other tabs will calculate there results on all trades only and not for a specific area of the chart history window.

The X Axis options allow the user to display the equity curve either with Date & Profil/Loss or Trades & Profit/Loss.

Navigation There are two zoom options for analyzing the results:

  1. mouse wheel

  2. click and hold right mouse button and select an area in the chart history or equity curve.

As mentioned above, the Show All or Show Chart options have an impact on the displayed of the equity curve and the results in the other tabs. If the option Show Chart is active, then zooming within the chart history will also zoom within the equity curve. If the option Show All is active, then the chart history zoom has no impact on the equity curve. Zooming within the equity curve, on the other hand, always has an impact on the chart history.

Context menu

There are several options in the context menu:

  • Copy

  • Save Image As...

  • Page Setup... (for printing)

  • Print...

  • Show Point Values

  • Set Scale to Default

Context menu Graph:

  • Cumulative Profit

  • Daily Net Profit

  • Entry Efficiency

  • Exit Efficiency

  • MAE

  • MFE

  • Monthly Net Profit

  • Weekly Net Profit

  • Total Efficiency

  • Trade Profit/Loss

Context menu Trades:

  • All

  • Long

  • Short

Context menu Winning/Losing:

  • All

  • Winning

  • Losing

Summary tab

As the name implies, the Summary tab contains a summary of trading results.

Indicator explanations The Indicator results are divided into three columns: all long and short trades together, long trades only and short trades only.

Trades tab

The Trades tab contains all trades from the backtesting summary. Right clicking on the column names opens the context menu, which allows you to add or remove columns using the Choose columns window. Right clicking on the trades list allows you to export the list as MS Excel document.

Tip: PnL shows profit and loss of the actual trade. The cumulative PnL (“Com. PnL”) shows total profit and loss of all trades so far. As you can see in the screenshot, top down - starting with the first PnL - the following PnL is subtracted respectively added on. Each new result you will find in “Com. PnL”-column, every following PnL will be added on or subtracted in a zigzag-mode down to the latest result of cumulated PnL. Please take into account that most minimal deviations might occur as the cumulated PnL is rounded to two decimal figures whereas prices sometimes are calculated to three or more decimal figures.

Orders tab

The Orders tab contains all orders from the backtesting summary. Right clicking on the column names opens the context menu, which allows you to add or remove columns using the Choose columns window. Right clicking on the trades list allows you to export the list as MS Excel document.

Order execution description

The Backtest simulates a real-time behavior in two different modes: Mode No. 1 - Tick based (works in the same way as the simulation account). If the current tick touches an open order this tick price will be used as fill price. Mode No. 2 - Candle based (simulates the tick based mode).

Each candle will be split in four pieces:

  • growing candle: Open; High; Low; Close.

  • falling candle: Open; Low; High; Close.

If e.g. the High price touches an open order this price will be used as fill price. The same is valid if an open order touches the Open, Low or Close price.

Difference between Market, Stop and StopLimit order: Market and Stop orders will be filled with the same candle. StopLimit orders will be filled with the next candle. Example. Assuming TimeFrame = 1 Day the StopLimit order will be filled on the next day, while the Stop order will be filled on the same day.

Executions tab

The Executions tab contains all order executions of the backtesting summary. Right clicking on the column names opens the context menu, which allows you to add or remove columns using the Choose columns window. Right clicking on the trades list allows you to export the list as MS Excel document.

Periods tab

The Periods tab contains a summary of the backtesting results based on various calendar settings. Right clicking on the column names opens the context menu, which allows you to add or remove columns using the Choose columns window. Right clicking on the list allows you to export the list as MS Excel document and choose the period type.

Possible period types are:

  • Annual

  • Monthly

  • Weekly

  • Day of Week

  • Daily

  • Hour of Day

Trading Info tab

The Trading Info tab contains all information about the trade in a trading tree. It includes Partial Trades, Orders and Executions. Right clicking on the column names opens the context menu, which allows you to add or remove columns using the Choose columns window.

Essential information

To backtest a trading signal it is necessary to set the correct history length required by the signal or condition. To do this the setting "Required bars count" must be defined. In general, the default setting of 20 bars is enough for most signals. If a signal or condition with the Signal Builder or via programming was created that requires more history (bars) the setting must be adjusted accordingly. Be aware that for the defined history (bars count) setting no signals/conditions can be calculated. Only the bars after that will show signals.

Information for Dow Theory signals: Signals created with Dow Theory indicators like the P123 require a long history to calculate the signals. At least 500 bars or more must be set. Note, that your datafeed or file must deliver enough history since the e.g. first 500 bars will not show any signals. Only the following bars will show them.

Further development from Standard to Advanced

In collaboration with the University of Aachen (Institute for Mathematics), the Backtest function of AgenaTrader has been further developed and the Advanced Mode has been created. The research paper by Dr. Stanislaus Maier-Paape and Dr. Andreas Platen indicates that a strategy in the Backtest only delivers results for historical data and cannot be a basis for live trade, since the future results can deviate substantially therefrom. Nevertheless, the function Backtest, which is offered by all leading software manufacturers, still plays an essential role in the quality of the software. A well-functioning backtest algorithm is necessary in order to develop a well-functioning trading system. The more accurately the results are calculated in the backtest, the more reliable the trading system is when it comes to live trading.

Furthermore, the research also demonstrates that despite very progressively developed algorithms and tests in the market, in some cases, the calculations are not outputted correctly. In one of these cases, one speaks of situations that cannot be clearly defined, for short SNU (situation which is not unique). In order to make it possible to also react to SNUs, the function "Decision Mode" was developed, which gives the user of the software the chance to make a decision. The following three settings can be made:

  • Worst case: the SNU is evaluated based on the worst possible result.

  • Best case: the SNU is evaluated based on the best possible result.

  • Ignore: the entry signal or the whole trade is ignored.

SNUs only occur in connection with stop, limit and stop limit orders. Market orders can always be clearly defined.

Last updated