OPEN-SOURCE SCRIPT
Proper Candles

This Pine Script indicator, titled "Proper Candles", is a custom implementation of candlesticks on a TradingView chart. It modifies the traditional candlestick representation by adjusting the open, high, and low values, and overlays these adjusted candles on the chart. The main purpose of this indicator is to create a more visually intuitive candle that reflects price movements with a focus on momentum and continuity between bars.
🔍 Full Description of the "Proper Candles" Indicator
📌 Script Header
indicator("Proper Candles", overlay=true)
This declares the indicator with the name "Proper Candles" and places it directly on the price chart (overlay=true), instead of a separate pane.
🔄 Adjusted Candle Calculations
This indicator modifies the standard candlestick components (open, high, and low) to produce a smoother or more logical visual flow between candles.
adjustedOpen = close[1]
adjustedHigh = math.max(high[0], close[1])
adjustedLow = math.min(low[0], close[1])
Explanation:
adjustedOpen = close[1]
The candle’s open is set to the previous candle’s close, rather than the actual open.
This creates a continuous price flow from one candle to the next, visually eliminating gaps.
adjustedHigh = math.max(high[0], close[1])
The high of the candle is adjusted to be the maximum between the actual high of the current candle and the previous close.
This ensures that the high fully encompasses any price movement from the previous close to the current high.
adjustedLow = math.min(low[0], close[1])
The low is set as the minimum between the current low and the previous close, again ensuring continuity in the visual range of the candle.
These adjustments are primarily aimed at eliminating price gaps and creating a more consistent visual representation of price action.
🎨 Bar Coloring Logic
barColor = close > close[1] ? color.rgb(42, 170, 42) : color.rgb(195, 42, 42)
If the current close is higher than the previous close, the candle is colored green (rgb(42, 170, 42)).
If the current close is lower or equal to the previous close, the candle is colored red (rgb(195, 42, 42)).
This coloring is based on momentum or directional movement, rather than open-close comparisons within the same candle.
🕯️ Candle Plotting
plotcandle(adjustedOpen, adjustedHigh, adjustedLow, close,
title="Proper Candles", color=barColor, wickcolor=color.black, bordercolor=barColor)
Candle Body:
Open: Adjusted to previous close.
Close: Actual close of the current bar.
Color: Based on whether price increased or decreased from the last close.
Wicks:
High/Low: Adjusted to include previous close if it lies outside the current high/low.
Wick Color: Always black, creating a clean visual contrast.
Border Color: Same as candle body color for a unified look.
🧠 Key Benefits & Use Cases
Eliminates Visual Gaps Between Candles:
By using the previous close as the open, the chart avoids discontinuities that can be distracting in fast-moving or gappy markets.
Highlights Momentum Clearly:
Color logic based on close-to-close changes makes it easy to see directional momentum at a glance.
Ideal for Algorithmic or Visual Trend Analysis:
Can help in detecting streaks of bullish or bearish momentum.
Better for Visual Continuity:
This can be helpful for traders who rely on pattern recognition, as it maintains a flowing chart narrative without abrupt jumps.
⚠️ Limitations & Considerations
Not Suitable for Gap Analysis:
Since it eliminates gaps by design, traders who analyze open gaps as part of their strategy might find this misleading.
May Differ from Price Feed:
Visually, these candles differ from the actual price action candles, which could cause confusion if not properly understood.
For Visualization, Not Execution:
This should be used for visual aid, not for decision-making in trading bots or automation without further validation.
🔍 Full Description of the "Proper Candles" Indicator
📌 Script Header
indicator("Proper Candles", overlay=true)
This declares the indicator with the name "Proper Candles" and places it directly on the price chart (overlay=true), instead of a separate pane.
🔄 Adjusted Candle Calculations
This indicator modifies the standard candlestick components (open, high, and low) to produce a smoother or more logical visual flow between candles.
adjustedOpen = close[1]
adjustedHigh = math.max(high[0], close[1])
adjustedLow = math.min(low[0], close[1])
Explanation:
adjustedOpen = close[1]
The candle’s open is set to the previous candle’s close, rather than the actual open.
This creates a continuous price flow from one candle to the next, visually eliminating gaps.
adjustedHigh = math.max(high[0], close[1])
The high of the candle is adjusted to be the maximum between the actual high of the current candle and the previous close.
This ensures that the high fully encompasses any price movement from the previous close to the current high.
adjustedLow = math.min(low[0], close[1])
The low is set as the minimum between the current low and the previous close, again ensuring continuity in the visual range of the candle.
These adjustments are primarily aimed at eliminating price gaps and creating a more consistent visual representation of price action.
🎨 Bar Coloring Logic
barColor = close > close[1] ? color.rgb(42, 170, 42) : color.rgb(195, 42, 42)
If the current close is higher than the previous close, the candle is colored green (rgb(42, 170, 42)).
If the current close is lower or equal to the previous close, the candle is colored red (rgb(195, 42, 42)).
This coloring is based on momentum or directional movement, rather than open-close comparisons within the same candle.
🕯️ Candle Plotting
plotcandle(adjustedOpen, adjustedHigh, adjustedLow, close,
title="Proper Candles", color=barColor, wickcolor=color.black, bordercolor=barColor)
Candle Body:
Open: Adjusted to previous close.
Close: Actual close of the current bar.
Color: Based on whether price increased or decreased from the last close.
Wicks:
High/Low: Adjusted to include previous close if it lies outside the current high/low.
Wick Color: Always black, creating a clean visual contrast.
Border Color: Same as candle body color for a unified look.
🧠 Key Benefits & Use Cases
Eliminates Visual Gaps Between Candles:
By using the previous close as the open, the chart avoids discontinuities that can be distracting in fast-moving or gappy markets.
Highlights Momentum Clearly:
Color logic based on close-to-close changes makes it easy to see directional momentum at a glance.
Ideal for Algorithmic or Visual Trend Analysis:
Can help in detecting streaks of bullish or bearish momentum.
Better for Visual Continuity:
This can be helpful for traders who rely on pattern recognition, as it maintains a flowing chart narrative without abrupt jumps.
⚠️ Limitations & Considerations
Not Suitable for Gap Analysis:
Since it eliminates gaps by design, traders who analyze open gaps as part of their strategy might find this misleading.
May Differ from Price Feed:
Visually, these candles differ from the actual price action candles, which could cause confusion if not properly understood.
For Visualization, Not Execution:
This should be used for visual aid, not for decision-making in trading bots or automation without further validation.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.