PROTECTED SOURCE SCRIPT
Last Price Line

# Last Price Line with Enhanced Features
## Description
This indicator provides a highly customizable horizontal price line that tracks the current market price with advanced visualization options and real-time price change tracking. Unlike the basic price line built into most charting platforms, this tool offers extensive customization including dynamic color changes based on price movement, detailed price change statistics, adjustable line extensions, and flexible label positioning. The indicator is designed to give traders instant visual reference of the current price level with optional momentum context through color-coded labels showing gains or losses from the previous bar.
## How It Works
The indicator continuously monitors the closing price of the most recent bar and draws a horizontal line at that exact level. The line extends both left and right by user-defined amounts, with an option to infinitely extend the line to the right. When price change display is enabled, the indicator calculates the difference between the current price and the previous close, presenting this information both in absolute points and percentage terms directly on the price label.
**Core Calculation:**
- Current Price = Close of most recent bar
- Price Change = Current Price - Previous Close
- Percent Change = (Price Change / Previous Close) × 100
**Dynamic Color Logic:**
When "Color by Change Direction" is enabled, the label automatically changes color based on price movement:
- **Up Color** (default: green) when current price > previous close
- **Down Color** (default: red) when current price < previous close
- **Neutral Color** (default: gray) when price is unchanged
This provides instant visual feedback on intrabar momentum without needing to look at price values.
## Original Features & Methodology
**What Makes This Script Unique:**
- Combines a customizable price reference line with real-time price change statistics
- Implements percentage-based label offset system that works consistently across all price scales
- Features tri-state color system (up/down/neutral) with user-definable colors for each state
- Includes independent left and right extension controls for precise visual placement
- Offers multiple decimal place precision options (0-8 decimals) for any asset class
- Provides optional circular marker plot that can be toggled independently from the main line
**Technical Implementation:**
- Uses `barstate.islast` to ensure line updates only on the most recent bar for performance
- Implements proper object deletion to prevent memory buildup over time
- Employs `line.style_label_left` and `line.style_label_right` for intelligent label positioning
- Supports infinite right extension via `extend.right` or fixed extension via `extend.none`
- Line transparency and marker transparency controlled independently
## Key Features
🔹 **Fully Customizable Line**: Control color, width, style (solid/dashed/dotted), and transparency
🔹 **Flexible Extension**: Separate left and right extension controls with optional infinite right extension
🔹 **Smart Price Labels**: Display current price with customizable size, position, and decimal precision
🔹 **Price Change Display**: Optional display of price change from previous bar in points and/or percentage
🔹 **Dynamic Color Coding**: Label automatically changes color based on up/down/neutral movement
🔹 **Custom Color Palette**: Define your own colors for bullish, bearish, and neutral conditions
🔹 **Precision Control**: Set decimal places from 0 to 8 for any asset (stocks, forex, crypto, futures)
🔹 **Optional Price Marker**: Toggle circular plot marker independently from main line
🔹 **Performance Optimized**: Efficient code that only updates on the most recent bar
## Input Parameters Explained
**Line Settings**
- **Line Color**: Base color for the horizontal price line (default: yellow)
- **Line Width**: Thickness from 1-5 pixels (default: 2)
- **Line Style**: Choose Solid, Dashed, or Dotted appearance
- **Line Transparency**: 0-100% transparency control (0 = opaque, 100 = invisible)
**Extension Settings**
- **Left Extension**: How many bars to extend the line to the left (default: 50)
- **Right Extension**: How many bars to extend the line to the right (default: 10)
- **Extend Line Right**: Toggle infinite right extension (overrides right extension bars when enabled)
**Label Settings**
- **Show Price Label**: Toggle the price label on/off
- **Label Position**: Place label on Left or Right side of chart
- **Label Size**: Choose from Tiny, Small, Normal, Large, or Huge
- **Label Text Color**: Color of the text inside the label (default: white)
- **Price Decimals**: Number of decimal places to display (0-8)
**Price Change Settings**
- **Show Price Change**: Display change from previous bar
- **Show Percent Change**: Include percentage change in label
- **Color by Change Direction**: Enable dynamic color coding based on movement
- **Up Color**: Label color when price is higher (default: green)
- **Down Color**: Label color when price is lower (default: red)
- **Neutral Color**: Label color when price is unchanged (default: gray)
**Display Settings**
- **Show Current Price Marker**: Toggle the circular plot marker
- **Marker Transparency**: Control transparency of the marker line (default: 90%)
## How to Use This Indicator
**Basic Setup:**
1. Add the indicator to your chart - a yellow horizontal line will appear at the current price
2. The line extends 50 bars to the left and 10 bars to the right by default
3. A label on the right shows the current price with 2 decimal places
**Customizing Appearance:**
1. Adjust line color, width, and style to match your chart theme
2. Modify left/right extensions to fit your chart display preferences
3. Change label position to Left if it interferes with right-side indicators
4. Increase/decrease label size based on your screen resolution and preferences
**Enabling Price Change Display:**
1. Check "Show Price Change" to see movement from previous bar
2. Label will show: Current Price, Point Change, and Percent Change
3. Enable "Color by Change Direction" for instant visual momentum feedback
4. Customize up/down/neutral colors to match your trading style
**Precision Settings:**
- **Stocks**: Use 2 decimal places
- **Forex majors**: Use 4-5 decimal places
- **Crypto**: Use 2-4 decimal places depending on asset value
- **Futures**: Use 2 decimal places (0 for index futures)
- **Commodities**: Vary by instrument (0-4 typical)
**Pro Tips:**
- Use high transparency (60-80%) for subtle price reference
- Disable the circular marker if you only want the main line
- Enable infinite right extension to see price level projection into the future
- Use different colors for different timeframes on multi-chart layouts
## Use Cases
**Day Trading:**
- Quick visual reference for entry price and current price relationship
- Color-coded momentum feedback shows if you're gaining or losing on the bar
- Precise decimal control for instruments with specific tick sizes
**Swing Trading:**
- Track daily close levels across multiple days
- Monitor percentage gains/losses from previous session close
- Clear visual separation between current price and reference levels
**Position Monitoring:**
- Instant visual of current P&L when combined with entry indicators
- Clean price display without cluttering the chart
- Customizable to match any chart color scheme
**Multi-Monitor Setups:**
- Consistent price reference across different timeframe charts
- Large label sizes for viewing from a distance
- High-contrast colors for quick recognition
## Technical Details
- Updates only on `barstate.islast` for optimal performance
- Proper line and label deletion prevents memory buildup
- Works on all timeframes and asset classes
- No repainting - all values based on confirmed bar data
- Label position calculated using `bar_index` for accurate placement
- Supports both fixed and infinite line extension modes
## Best Practices
- Use contrasting line colors that stand out against your chart background
- Set appropriate decimal places for your asset to avoid clutter
- Enable price change display for active trading, disable for clean charts
- Use transparency when layering multiple indicators
- Position labels to avoid overlap with other chart elements
- Customize colors to distinguish between different chart windows
- Test different label sizes to find what works best for your screen
This indicator serves as an essential price reference tool that combines simplicity with powerful customization options, making it suitable for traders of all experience levels and trading styles.
---
## Connect With Me
📧 **Email**: contact@savvytraderpro.com
📊 **Website**: [savvytraderpro.com](savvytraderpro.com)
🐦 **X (Twitter)**: [savvytraderpro](twitter.com/savvytraderpro)
💬 Follow for more indicators, trading strategies, and market insights!
---
**⚠️ Disclaimer:**
This script is provided for educational and informational purposes only. It is not financial advice and should not be considered a recommendation to buy, sell, or hold any financial instrument. Trading involves significant risk of loss and is not suitable for every investor. Users should perform their own due diligence and consult with a licensed financial advisor before making any trading decisions. The author does not guarantee any profits or results from using this script, and assumes no liability for any losses incurred. Use this script at your own risk.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.