OPEN-SOURCE SCRIPT

Precision Trader Indicator, v1.01

Overview:
The PTI is a custom indicator designed to provide buy and sell signals based on price movements and volatility. It uses the Average True Range (ATR) to calculate stop levels and identifies potential trend changes.

Parameters:
The indicator has several customizable parameters that you can adjust according to your preferences. These parameters include:
- ATR Period (length): Determines the lookback period for calculating the ATR.
- ATR Multiplier (mult): Specifies the multiplier applied to the ATR to determine the stop levels.
- Show Buy/Sell Labels (showLabels): Allows you to choose whether to display buy/sell labels on the chart.
- Use Close Price for Extremums (useClose): Determines whether the indicator considers the close price for calculating extremums.
- Highlight State (highlightState): Enables highlighting of the long and short state on the chart.

Calculation:
1. ATR Calculation: The indicator calculates the Average True Range (ATR) using the specified length parameter and multiplies it by the ATR Multiplier (mult) to obtain the ATR value.

2. Long Stop Calculation: The long stop level is calculated based on the highest price over the specified length period (using either the high or close price, depending on the useClose parameter) minus the ATR value. It ensures that the long stop is below the recent highest point.

3. Short Stop Calculation: The short stop level is calculated based on the lowest price over the specified length period (using either the low or close price) plus the ATR value. It ensures that the short stop is above the recent lowest point.

4. Direction Calculation: The indicator determines the current direction based on the close price compared to the previous long stop and short stop levels. If the close price is above the previous long stop, the direction is set to 1 (indicating a bullish trend). If the close price is below the previous short stop, the direction is set to -1 (indicating a bearish trend). Otherwise, the direction remains unchanged.

Plotting:
The indicator plots several visual elements on the chart:
- Long Stop: Draws a line representing the long stop level.
- Long Stop Start: Plots a small circle marker indicating the start of a long stop (buy signal).
- Buy Label: Displays a "Buy" label near the long stop start marker.
- Short Stop: Draws a line representing the short stop level.
- Short Stop Start: Plots a small circle marker indicating the start of a short stop (sell signal).
- Sell Label: Displays a "Sell" label near the short stop start marker.
- Long State Filling: Fills the area between the mid price and the long stop line with a color (optional).
- Short State Filling: Fills the area between the mid price and the short stop line with a color (optional).

Alerts:
The indicator includes three types of alerts:
- PTI Direction Change: Triggers an alert when the PTI direction changes (from bullish to bearish or vice versa).
- PTI Buy: Triggers an alert when a buy signal occurs (long stop start).
- PTI Sell: Triggers an alert when a sell signal occurs (short stop start).

By using the PTI indicator, traders can monitor potential trend changes and receive alerts when buy or sell signals are generated based on price and volatility dynamics.

Please note that the interpretation and effectiveness of this indicator should be evaluated through rigorous backtesting and analysis before making any trading decisions.
Candlestick analysisChart patternsforecasting

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الرمز في المنشور يخضع لقواعد‎‎قوانين الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟

إخلاء المسؤولية