> ## Documentation Index
> Fetch the complete documentation index at: https://takeprofit.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Strategy/Backtesting Widget

The **Strategy/Backtesting Widget** allows you to test and analyze trading strategies using historical data directly inside your workspace.
It combines strategy execution, performance analytics, trade logs, and risk statistics in a single environment — tightly integrated with Charts and the Indie IDE.

<video
  autoPlay
  muted
  loop
  playsInline
  className="w-full rounded-2xl"
  style={{
border: "1.9px solid rgba(179, 200, 224, 0.08)",
objectFit: "fill",
display: "block"
}}
  src="https://mintcdn.com/takeprofit-a5dc0462/67XMQdOAlONNWB1u/images/guide/platform/backtest-widget/6.1.0_Backtesting.mp4?fit=max&auto=format&n=67XMQdOAlONNWB1u&q=85&s=795d6947c860418159687584d4a0dafd"
  data-path="images/guide/platform/backtest-widget/6.1.0_Backtesting.mp4"
/>

***

## Getting Started

When the Strategy/Backtesting Widget is opened, you will see a prompt to select a strategy.

<video
  autoPlay
  muted
  loop
  playsInline
  className="w-full rounded-2xl"
  style={{
border: "1.9px solid rgba(179, 200, 224, 0.08)",
objectFit: "fill",
display: "block"
}}
  src="https://mintcdn.com/takeprofit-a5dc0462/67XMQdOAlONNWB1u/images/guide/platform/backtest-widget/6.1.1_New_Strategy.mp4?fit=max&auto=format&n=67XMQdOAlONNWB1u&q=85&s=9149ddb1f033ecad00d1e9d76a1e0737"
  data-path="images/guide/platform/backtest-widget/6.1.1_New_Strategy.mp4"
/>

Click **Select Strategy** or **Open Strategy** to:

* Choose a built-in strategy
* Open an existing custom strategy
* Create a new strategy

***

## Using Built-in Strategies

The widget includes a library of ready-to-use strategies such as:

* ADX Breakout Strategy
* MACD Strategy
* Moving Average Cross
* RSI Strategy
* Price Channel Strategy
* Consecutive Up/Down Strategy
* Inside Bar / Outside Bar Strategies

To use a built-in strategy:

1. Open the strategy selector
2. Choose a strategy from the **Built-in** section
3. Run the backtest

Built-in strategies are useful for:

* Learning how strategy logic works
* Benchmarking performance
* Comparing behavior across instruments and timeframes

***

## Creating a Custom Strategy

To create your own strategy:

1. Open the strategy selector
2. Click **Create New Strategy**
3. The Indie editor will open
4. Define your strategy logic

Custom strategies are written in Indie using the strategy framework.

For full implementation details, refer to: [https://takeprofit.com/docs/indie/Strategies/Strategies-overview](https://takeprofit.com/docs/indie/Strategies/Strategies-overview)

Once saved, the strategy becomes available inside the Strategy/Backtesting Widget.

***

## Strategy Settings

<video
  autoPlay
  muted
  loop
  playsInline
  className="w-full rounded-2xl"
  style={{
border: "1.9px solid rgba(179, 200, 224, 0.08)",
objectFit: "fill",
display: "block"
}}
  src="https://mintcdn.com/takeprofit-a5dc0462/67XMQdOAlONNWB1u/images/guide/platform/backtest-widget/6.1.2_Settings.mp4?fit=max&auto=format&n=67XMQdOAlONNWB1u&q=85&s=980da6a9b4d8e6dd1e162dd605a54da4"
  data-path="images/guide/platform/backtest-widget/6.1.2_Settings.mp4"
/>

Each strategy includes configurable inputs.

Typical parameters may include:

* Initial Capital
* Commission value and type
* Leverage
* Risk-free rate
* Order size and order size unit
* Market order type
* Intrabar execution rules
* Strategy-specific logic inputs (periods, thresholds, multipliers, etc.)

You can modify these inputs directly from the settings panel and instantly rerun the backtest.

***

## Backtesting Date Range

You can control the period used for backtesting directly from the top panel of the widget.

<video
  autoPlay
  muted
  loop
  playsInline
  className="w-full rounded-2xl"
  style={{
border: "1.9px solid rgba(179, 200, 224, 0.08)",
objectFit: "fill",
display: "block"
}}
  src="https://mintcdn.com/takeprofit-a5dc0462/RlUXWQgU8OI9Aefh/images/guide/platform/backtest-widget/6.1.4_Calendar.mp4?fit=max&auto=format&n=RlUXWQgU8OI9Aefh&q=85&s=80aa6b641c5da4052a6f96453358e3c9"
  data-path="images/guide/platform/backtest-widget/6.1.4_Calendar.mp4"
/>

### Start Date

* **Start Available** – uses the earliest available historical data (limited by your plan)
* **From Custom Date** – manually select a start date using the calendar

> Note: Historical data is capped depending on your plan (e.g., 5,000 candles on Free, 20,000 on All-in).

***

### End Date

* **Now** – includes the most recent market data and updates automatically (forward testing)
* **Until Custom Date** – manually select an end date

***

### Calendar Selection

When selecting a custom range:

* A dual calendar picker allows you to define **start and end dates**
* You can navigate between months and years
* Selected dates define the exact backtesting window

This allows you to:

* Test strategies on specific market periods
* Compare performance across different conditions
* Isolate trends, volatility phases, or events

Adjusting the date range will immediately affect the backtest results and all related metrics.

## Main Performance Overview

<video
  autoPlay
  muted
  loop
  playsInline
  className="w-full rounded-2xl"
  style={{
border: "1.9px solid rgba(179, 200, 224, 0.08)",
objectFit: "fill",
display: "block"
}}
  src="https://mintcdn.com/takeprofit-a5dc0462/67XMQdOAlONNWB1u/images/guide/platform/backtest-widget/6.1.3_Open_Report.mp4?fit=max&auto=format&n=67XMQdOAlONNWB1u&q=85&s=90257717dff3060bda2090540fd1d681"
  data-path="images/guide/platform/backtest-widget/6.1.3_Open_Report.mp4"
/>

After running a strategy, the Strategy/Backtesting Widget provides a structured performance summary.

### Core Metrics

* Total P\&L
* Win Rate
* Profit Factor
* Total Trades
* Wins / Losses
* Average Trade
* Expectancy
* Risk–Reward Ratio

***

## Capital & Returns

This section summarizes capital progression:

* Initial Capital
* Final Capital
* Realized P\&L
* Unrealized P\&L
* Annualized Return
* Buy & Hold Return
* Average Monthly Return
* Minimum / Maximum Equity

***

## Risk & Volatility

Risk metrics help evaluate downside exposure:

* Max Drawdown
* Average Drawdown
* Number of Drawdowns
* Max Drawdown Duration
* Sharpe Ratio

***

## Volatility & Recovery

Additional recovery and stability indicators:

* Sortino Ratio
* Calmar Ratio
* Daily Standard Deviation
* Daily Value at Risk (95% / 99%)
* Annualized Volatility
* Average Recovery Time
* Maximum Recovery Time

***

## Trade Quality

Trade-level quality metrics include:

* Expectancy
* Risk–Reward Ratio
* Profit Factor
* Best Trade Net P\&L
* Worst Trade Net P\&L
* Commission-to-Profit Ratio

***

## Trade Analysis

The **Trades** tab provides a detailed breakdown:

* Trade ID and type (Long / Short)
* Entry and exit timestamps
* Duration
* Individual trade P\&L
* Cumulative P\&L
* Drawdown and run-up

Trades can be inspected individually for execution analysis.

***

## Orders Log

The **Orders** tab displays:

* Order ID
* Order type (Market / Limit / Stop)
* Price
* Quantity
* Exposure
* Fee

This allows you to audit execution mechanics in detail.

***

## Visual Components

The widget also provides:

* Equity curve
* Drawdown chart
* Position activity
* Trade distribution statistics

These visualizations help identify instability, overfitting, or structural weaknesses in strategy logic.

To compare the backtesting of two strategies side-by-side:

* Open two **Strategy/Backtesting Widgets** with the two strategies you want to compare (these can be built-in, existing custom strategies, or a new strategy you want to create).
* Select the **asset**.
* Select the **timeframe**.
* Click **"Source Code"** to open them for both strategies and click **"Open Report"** to update your strategy backtesting results.
* **Verify the results** of both strategies side-by-side.

***

## Workflow Integration

The Strategy/Backtesting Widget is designed to work together with:

* **Charts** – to visually validate entries and exits
* **IDE** – to develop and refine strategy logic
* **Watchlist** – to test strategies across multiple instruments

This creates a structured research loop:

Develop → Test → Analyze → Refine → Retest

***

The Strategy/Backtesting Widget transforms your workspace into a complete strategy validation environment — combining execution logic, risk diagnostics, and performance analytics in one unified interface.
