OPEN-SOURCE SCRIPT

Volume IChi v.6

От G4ll4nt
Here’s a concise description you can use for your TradingView script publication:

volume.ichi is a versatile indicator that integrates custom volume analysis with Ichimoku cloud calculations. It allows traders to visualize market trends and potential reversals using various volume types, such as Dollar Volume, On-Balance Volume (OBV), and VWAP. The indicator plots volume-based candles and Ichimoku lines to highlight key support and resistance levels. This makes it an essential tool for identifying momentum, breakout points, and overall market dynamics. Perfect for traders looking to enhance their analysis and decision-making process.
2 days ago
Release Notes
1. Indicator Definition and Settings

pinescript

//version=6
indicator(shorttitle='gallant.v6', title='gallant with custom volume', overlay=false, format=format.volume)

version=6: Specifies that the script uses Pine Script version 6, the latest version of Pine Script.
indicator(): Defines the indicator settings.
shorttitle: The short name displayed on the chart.
title: The full title of the indicator.
overlay=false: Sets the indicator to be displayed in a separate pane, not on the price chart.
format=format.volume: Formats the indicator values as volume.

2. Custom Volume Source Options

pinescript

volumeType = input.string('Volume', title='Volume Type', options=['Volume', 'Dollar Volume', 'OBV', 'VWAP', 'A/D Line'])

input.string(): Creates an input option for the volume type with predefined choices:
Volume: Standard volume.
Dollar Volume: Calculated by multiplying the close price by the volume.
OBV: On-Balance Volume, which accumulates volume based on price movement direction.
VWAP: Volume Weighted Average Price.
A/D Line: Accumulation/Distribution Line.

3. Custom Volume Calculations

pinescript

customVolume = switch volumeType
'Dollar Volume' => close * volume
'OBV' => ta.cum(close > close[1] ? volume : close < close[1] ? -volume : 0)
'VWAP' => ta.vwap
'A/D Line' => ta.cum(((close - low) - (high - close)) / (high - low) * volume)
=> volume

switch: Determines the volume calculation based on the selected volumeType.
Each option applies a specific formula:
Dollar Volume multiplies the close price by the volume.
OBV adds or subtracts volume based on price direction.
VWAP uses the built-in VWAP calculation.
A/D Line uses a formula for the Accumulation/Distribution Line.
Default is standard volume.

4. Volume Candle Calculation

pinescript

barColorsOnPrevClose = input.bool(true, title='Color bars based on previous close')
openCloseNA = input.bool(true, title='open=close mean na')

barColorsOnPrevClose: A boolean input that colors bars based on the previous close.
openCloseNA: A boolean input that handles cases where open equals close, setting these cases to "NA."

5. Volume Candle Plotting

pinescript

palette = barColorsOnPrevClose ? (close[1] > close ? color.red : color.green) : (open > close ? color.red : color.green)
palette_r = barColorsOnPrevClose ? (close[1] > close ? false : true) : (open > close ? false : true)
nv = openCloseNA ? (open == close ? 0 : (palette_r ? customVolume : -customVolume)) : (palette_r ? customVolume : -customVolume)
mclose = ta.cum(nv)
mopen = palette_r ? mclose[1] : mclose[1]
mlow = openCloseNA ? (open == close ? na : math.min(mopen, mclose)) : math.min(mopen, mclose)
mhigh = openCloseNA ? (open == close ? na : math.max(mopen, mclose)) : math.max(mopen, mclose)
plotcandle(open=mopen, high=mhigh, low=mlow, close=mclose, title='volume candles', color=palette, wickcolor=color.black)

This section calculates and plots custom volume candles with:
Color palette based on price movements.
Calculated open, high, low, and close values for custom volume candles.
plotcandle(): Plots these custom candles on the chart with the specified colors.

6. Ichimoku Calculation

pinescript

ichisrc = mclose
conversionPeriods = input.int(9, minval=1, title='Conversion Line (Tenkan-Sen) Periods')
basePeriods = input.int(26, minval=1, title='Base Line (Kijun-Sen) Periods')
laggingSpan2Periods = input.int(52, minval=1, title='Lagging Span 2 (Senkou Span B) Periods')
displacement = input.int(26, minval=1, title='Displacement')

ichisrc: The data source for Ichimoku calculations, set to the mclose value from volume calculations.
Ichimoku Parameters: Inputs for the conversion line, base line, lagging span, and displacement.

7. Donchian Function and Ichimoku Lines

pinescript

donchian(len) =>
math.avg(ta.lowest(ichisrc, len), ta.highest(ichisrc, len))

conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

plot(conversionLine, color=color.new(color.red, 0), linewidth=2, title='Conversion Line (Tenkan-Sen)')
plot(baseLine, color=color.new(color.blue, 0), linewidth=2, title='Base Line (Kijun-Sen)')
p11 = plot(leadLine1, offset=displacement, color=color.new(color.green, 50), title='Lead Line 1 (Senkou Span A)')
p22 = plot(leadLine2, offset=displacement, color=color.new(color.red, 50), title='Lead Line 2 (Senkou Span B)')
fill(p11, p22, color=leadLine1 > leadLine2 ? color.green : color.red, title='Cloud', transp=90)

donchian(): A function calculating the average of the highest high and lowest low over a given period.
Ichimoku Lines: Plots Conversion Line (Tenkan-Sen), Base Line (Kijun-Sen), Lead Line 1 (Senkou Span A), and Lead Line 2 (Senkou Span B).
fill(): Colors the cloud area between Lead Line 1 and Lead Line 2 based on their relative values.

8. Custom Ichimoku Lines with New Periods

pinescript

customPeriods1 = 52 // Updated to 52 as requested
customPeriods2 = 3100 // Updated to 3100 as requested

customLine1 = donchian(customPeriods1)
customLine2 = donchian(customPeriods2)

plot(customLine1, color=color.new(color.orange, 0), linewidth=2, title='Custom Line 1 (52)')
plot(customLine2, color=color.new(color.purple, 0), linewidth=2, title='Custom Line 2 (3100)')

Custom Ichimoku Lines: Two custom lines using periods 52 and 3100, as you requested.
These lines are plotted with distinct colors to differentiate them from standard Ichimoku components.

Summary

This script combines custom volume visualization with Ichimoku components and adds custom lines with specified periods.
It provides a unique perspective on market data by adjusting Ichimoku calculations based on volume dynamics.
ichimokuforexichimoku_traderMoving AveragesvolumesVolume
G4ll4nt

Скрипт с открытым кодом

В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения. Вы можете добавить этот скрипт в избранное и использовать его на графике.

Хотите использовать этот скрипт на графике?

Отказ от ответственности