OPEN-SOURCE SCRIPT
Cập nhật

Equity Curve with Trend Indicator (Long & Short) - Simulation

497
Overview:

Market Regime Detector via Virtual Equity Curve is a unique indicator that simulates the performance of a trend-following trading system—incorporating both long and short trades—to help you identify prevailing market regimes. By generating a “virtual equity” curve based on simple trend signals and applying trend analysis directly on that curve, this indicator visually differentiates trending regimes from mean-reverting (or sideways) periods. The result is an intuitive display where green areas indicate a trending (bullish) regime (i.e., where trend-following strategies are likely to perform well) and red areas indicate a mean-reverting (bearish) regime.

Features:

Simulated Trade Performance:
Uses a built-in trend-following logic (a simple 10/50 SMA crossover example) to simulate both long and short trades. This simulation creates a virtual equity curve that reflects the cumulative performance of the system over time.

Equity Trend Analysis:
Applies an Exponential Moving Average (EMA) to the simulated equity curve to filter short-term noise. The EMA acts as a trend filter, enabling the indicator to determine if the equity curve is in an upward (trending) or downward (mean-reverting) phase.

Dynamic Visual Regime Detection:
Fills the area between the equity curve and its EMA with green when the equity is above the EMA (indicating a healthy trending regime) and red when below (indicating a mean-reverting or underperforming regime).

Customizable Parameters:
Easily adjust the initial capital, the length of the equity EMA, and other settings to tailor the simulation and visual output to your trading style and market preferences.

How It Works:

Trade Simulation:

The indicator generates trading signals using a simple SMA crossover:

When the 10-period SMA is above the 50-period SMA, it simulates a long entry.
When the 10-period SMA is below the 50-period SMA, it simulates a short entry. The virtual equity is updated bar-by-bar based on these simulated positions.
Equity Trend Filtering:
An EMA is calculated on the simulated equity curve to smooth out fluctuations. The relative position of the equity curve versus its EMA is then used as a proxy for the market regime:

Bullish Regime: Equity is above its EMA → fill area in green.
Bearish Regime: Equity is below its EMA → fill area in red.
Visualization:
The indicator plots:

A gray line representing the simulated equity curve.
An orange line for the EMA of the equity curve.
A dynamic fill between the two lines, colored green or red based on the prevailing regime.
Inputs & Customization:

Initial Capital: Set your starting virtual account balance (default: 10,000 USD).
Equity EMA Length: Specify the lookback period for the EMA applied to the equity curve (default: 30).
Trend Signal Logic:
The current implementation uses a simple SMA crossover for demonstration purposes. Users can modify or replace this logic with their own trend-following indicator to tailor the simulation further.
Phát hành các Ghi chú
Overview:

Market Regime Detector via Virtual Equity Curve is a unique indicator that simulates the performance of a trend-following trading system—incorporating both long and short trades—to help you identify prevailing market regimes. By generating a “virtual equity” curve based on simple trend signals and applying trend analysis directly on that curve, this indicator visually differentiates trending regimes from mean-reverting (or sideways) periods. The result is an intuitive display where green areas indicate a trending (bullish) regime (i.e., where trend-following strategies are likely to perform well) and red areas indicate a mean-reverting (bearish) regime.

Features:

Simulated Trade Performance:
Uses a built-in trend-following logic (a simple 10/50 SMA crossover example) to simulate both long and short trades. This simulation creates a virtual equity curve that reflects the cumulative performance of the system over time.

Equity Trend Analysis:
Applies an Exponential Moving Average (EMA) to the simulated equity curve to filter short-term noise. The EMA acts as a trend filter, enabling the indicator to determine if the equity curve is in an upward (trending) or downward (mean-reverting) phase.

Dynamic Visual Regime Detection:
Fills the area between the equity curve and its EMA with green when the equity is above the EMA (indicating a healthy trending regime) and red when below (indicating a mean-reverting or underperforming regime).

Customizable Parameters:
Easily adjust the initial capital, the length of the equity EMA, and other settings to tailor the simulation and visual output to your trading style and market preferences.

How It Works:

Trade Simulation:
The indicator generates trading signals using a simple SMA crossover:

When the 10-period SMA is above the 50-period SMA, it simulates a long entry.
When the 10-period SMA is below the 50-period SMA, it simulates a short entry. The virtual equity is updated bar-by-bar based on these simulated positions.
Equity Trend Filtering:
An EMA is calculated on the simulated equity curve to smooth out fluctuations. The relative position of the equity curve versus its EMA is then used as a proxy for the market regime:

Bullish Regime: Equity is above its EMA → fill area in green.
Bearish Regime: Equity is below its EMA → fill area in red.
Visualization:
The indicator plots:

A gray line representing the simulated equity curve.
An orange line for the EMA of the equity curve.
A dynamic fill between the two lines, colored green or red based on the prevailing regime.
Inputs & Customization:

Initial Capital: Set your starting virtual account balance (default: 10,000 USD).
Equity EMA Length: Specify the lookback period for the EMA applied to the equity curve (default: 30).
Trend Signal Logic:
The current implementation uses a simple SMA crossover for demonstration purposes. Users can modify or replace this logic with their own trend-following indicator to tailor the simulation further.
Disclaimer:
This indicator is a simulation-based tool designed for educational and informational purposes only. It simulates trading performance using a simplified trend-following model and does not account for commissions, slippage, or advanced risk management. Use it as a visual aid to understand market regimes and supplement it with additional analysis and proper risk management before making trading decisions.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.