INVITE-ONLY SCRIPT

MAPE of Expected Value and Percent Residuals

Overview

This indicator calculates and visualizes the Mean Absolute Percentage Error (MAPE) and the percent residuals of the expected value compared to the actual closing price. The purpose of this indicator is to provide insights into the accuracy of price forecasts by comparing predicted values to actual market outcomes. The expected values are derived from the transform model, which uses the mean line from the mean and standard deviation lines as an indicator for expected price movement. Users can customize the number of periods over which calculations are averaged.

Inputs

  1. Mean Period (Bars): Specifies the number of bars used to calculate the moving average of the change between closing prices. This value should match the value used in the mean and standard deviation lines indicator.
  2. MAPE Period (Bars): Specifies the number of bars used to calculate the moving average of the absolute percentage error.


Outputs

  1. Percent Residuals Histogram: Displays the percentage error between the predicted (expected) value and the actual closing price. The bars are color-coded, with green indicating positive residuals (i.e., the actual value is higher than the predicted value) and red indicating negative residuals (i.e., the actual value is lower than the predicted value).
  2. Reference Line: A horizontal line at zero is added to the chart to indicate the baseline for percent residuals.
  3. Mean Absolute Percentage Error (MAPE) Line: Plots the moving average of the absolute percentage error over the specified period, helping users gauge the average accuracy of their predictions over time.


Methodology

  1. Calculation of Individual Bar Normalized Residuals: The normalized residuals for each bar are computed by taking the difference between the actual closing price and the predicted (expected) value, divided by the closing price. If the actual closing price is above the expected value, the residual is considered positive and is represented in green; otherwise, it is negative and represented in red. This normalization provides a standardized measure of deviation that allows for consistent comparison across different bars.
  2. Mean Absolute Percentage Error (MAPE) Calculation: Over the user-defined period, the absolute values of the normalized residuals are computed and subsequently averaged to determine the Mean Absolute Percentage Error (MAPE). This metric quantifies the average magnitude of the forecast errors, providing a clear indication of the model's predictive accuracy over time.


How to Use

  1. Add Indicators to Chart: First, apply the mean and standard deviation lines indicator to the chart, then add the MAPE of Expected Value and Percent Residuals indicator to evaluate the accuracy of price forecasts.
  2. Set Parameters: Set the `Mean Period (Bars)` to be the same value in both the mean and standard deviation lines indicator and the MAPE indicator to ensure accuracy. Adjust the `MAPE Period (Bars)` to fine-tune the length of historical data used in calculating the MAPE.
  3. Interpret Residuals and MAPE: Use the percent residuals histogram to understand how the actual closing price deviates from predictions. The MAPE line helps track the average prediction accuracy over time.


This tool is particularly useful for traders who want to evaluate the performance of their price prediction models based on the transform model and track how well their expected values, derived from mean and standard deviation lines, align with actual market movements.

forecastingstatistics

招待専用スクリプト

このスクリプトへのアクセスは作者が許可したユーザーに制限されており、通常はお支払いが必要です。お気に入りに追加することはできますが、許可を申請して作者が許可した後でなければ使用することはできません。 詳細については oisigma にお問い合わせいただくか、以下の作者の指示に従ってください。

スクリプトの動作を理解していて作者も100%信頼できるということでなければ、TradingViewとしてはお金を払ってまでスクリプトを利用するのはお勧めしません。そのかわりに、コミュニティスクリプトでオープンソースの優れたスクリプトが無料で見つけられることが多々あります。

作者の指示

visit oisigma.com to subscribe.

チャートでこのスクリプトを利用したいですか?

注: アクセス権をリクエストされる前にこちらをご覧ください

他のメディア:

免責事項