OPEN-SOURCE SCRIPT

Price Projector [MacAlgo]

183
Description:

The “Price Projector [MacAlgo]” is a Pine Script indicator designed to project possible future price movements based on historical price action. It allows you to select specific historical periods (up to two different reference dates) from which it extracts price change patterns and then applies a user-defined growth factor to create forward projections on your chart.

Key Features:

  • Dual Projection Capability: Define two distinct reference dates and periods to generate two separate projections.
  • Customizable Growth Factor: Apply a percentage-based drift or growth rate to your projections.
  • Adjustable Projection Length: Control how many bars into the future the script will visualize the projected price path.
  • Connector Lines: Optionally display lines connecting the historical reference points to the current chart position for easy visualization.
  • Debug Mode: Provides detailed information in a table for troubleshooting and transparency of internal calculations.


How it Works:

1. Reference Date & Data Collection
  • For each of the two projections, you select a reference date (e.g., 2022-01-01) and a period (number of bars).
  • Once the script reaches that reference date in the chart’s historical data, it begins storing the daily (or bar-based) price change percentages over the specified period.


2. Price Change Array
  • These price changes (ratios) are stored in arrays. For instance, if today’s close is 1% higher than yesterday’s, that ratio is recorded as 1.01.


3. Growth Factor Application
  • When projecting forward, the script replays the collected price change patterns starting from the current close and adjusts each step by a user-defined growth factor (percentage drift).


4. Drawing the Projection
  • The script creates a series of points (up to the chosen projection length) that represent the possible future price path.
  • It then draws polylines on the chart to visualize these forward projections.


5. Visualization & Debugging
  • Optional connector lines can be displayed to illustrate where the script started referencing data.
  • A debug table (when enabled) shows the validity of each projection, the number of data points collected, and other diagnostic details.


Customization Options:

1. Reference Dates & Periods
  • Projection 1 Reference Date, Projection 2 Reference Date
  • Period (bars) for each reference date


2. Growth Factor:
  • Growth Factor (%) for each projection to simulate additional drift over time


3. Projection Display:
  • Show Projection 1, Show Projection 2 toggle switches
  • Projection 1 Color, Projection 2 Color for line styling
  • Projection Length (bars) to specify how far out the script projects
  • Line Width to adjust the thickness of the projection lines
  • Show Connector Lines to connect historical reference points to current price
  • Debug Mode for displaying extra diagnostic information


Visual Components:

  • Projection Polylines: Colored lines showing the projected future price path for each reference date.
  • Connector Lines (Optional): Lines from the historical reference points to the current chart location, aiding in visualization of the historical data range used.
  • Debug Table (Optional): Displays internal state information such as validity checks, the size of data arrays, and reference bar indices.
  • Warning Table: Appears if the script fails to find the user-defined reference date in the available data, alerting you to input issues.


How to Use:

1. Add the Script: In TradingView, open the Pine Editor or the Indicators dialog, then add this script to your chart.

2. Configure Inputs:
  • Set “Projection 1 Reference Date” (and optionally “Projection 2 Reference Date”).
  • Specify how many bars (Period) you want to analyze for each reference date.
  • Adjust the “Growth Factor (%)” if you wish to introduce a drift in the projection.
  • Toggle display options and colors under “Display Settings.”


3. Observe Historical Data: The script will begin collecting price change data once it reaches the defined reference dates in the historical chart.

4. View Projections: As new bars print, the script will calculate and eventually render forward projections when you reach the end of your available chart data or are viewing live bars.

5. Enable Debug Mode (Optional): Check the “Debug Mode” box to see detailed information that can help verify the logic and data collection process.

Important Notes:
  • The projections are purely a replay of historical percentage changes, optionally scaled by a growth factor. They do not guarantee future performance or price levels.
  • If the script does not find your specified reference date within the visible or loaded chart data, it will display an error message.
  • Because it relies on historical data, the script’s behavior and drawn lines can change when chart data updates, or if the data for the reference period is missing.


Disclaimer:

This indicator is for informational and educational purposes only. It is not financial advice or a recommendation to buy or sell any securities or assets. Always conduct your own analysis and/or consult a qualified financial professional before making investment decisions. Use at your own risk.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.