CC_VPCI_Signal

stable
By tedo in Hybrid Published March 2024 👁 1,094 views 💬 0 comments

Description

Signal generation using Volume Price Confirmation Indicator (VPCI) with Plots and Highlight Breaches' Developed by Buff Dormeier, VPCI won 2007 Charles H Dow award by the MTA. VPCI plots the relationship between price trend and the volume, as either being in a state of confirmation or contradiction. Excerpt from article below: "Fundamentally, the VPCI reveals the proportional imbalances between price trends and volume-adjusted price trends. An uptrend with increasing volume is a market characterized by greed supported by the fuel needed to grow. An uptrend without volume is complacent and reveals greed deprived of the fuel needed to sustain itself. Investors without the influx of other investors (volume) will eventually lose interest and the uptrend should eventually breakdown. A falling price trend reveals a market driven by fear. A falling price trend without volume reveals apathy, fear without increasing energy. Unlike greed, fear is self-sustaining, and may endure for long time periods without increasing fuel or energy. Adding energy to fear can be likened to adding fuel to a fire and is generally bearish until the VPCI reverses. In such cases, weak-minded investor's, overcome by fear, are becoming irrationally fearful until the selling climax reaches a state of maximum homogeneity. At this point, ownership held by weak investor’s has been purged, producing a type of heat death capitulation. These occurrences may be visualized by the VPCI falling below the lower standard deviation of a Bollinger Band of the VPCI, and then rising above the lower band, and forming a 'V' bottom. " dependency https://www.haasscripts.com/t/pshaicmd-vwma-v2-optimized/ source https://www.tradingview.com/script/lmTqKOsa-Indicator-Volume-Price-Confirmation-Indicator-VPCI/
HaasScript
DefineCommand('VPCI_Signal', 'Signal generation using Volume Price Confirmation Indicator (VPCI) with Plots and Highlight Breaches')

-- Define parameters and inputs
local name = DefineParameter(StringType, 'name', 'Unique name of the indicator.', false, 'VPCI_Indicator', 'Text')
local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', false, 6, 'Number')

InputGroupHeader('Indicator Settings')
local bbLength = Input('BB Length', 20)
local bbMult = Input('BB Multiplier', 2.5)
local highlightBreaches = Input('Highlight BB Breaches?', true)
local vpcLength = Input('VPC Length', 20)
local shortTerm = Input('Short Term', 5)
local longTerm = Input('Long Term', 20)
local lengthMA = Input('VPCI MA Length', 8)

--==============================================================

--=============================================================
-- Data retrieval
local prices = ClosePrices()
local high = HighPrices()
local low = LowPrices()
local volume = GetVolume()

-- VPCI Calculation
local vpc = CC_VWMA_v2(prices, volume, vpcLength) - SMA(prices, vpcLength)
local vpr = CC_VWMA_v2(prices, volume, shortTerm) / SMA(prices, shortTerm)
local vm = SMA(volume, shortTerm) / SMA(volume, longTerm)
local vpci = CC_HMA((vpc * vpr * vm), lengthMA)
local vpciMA = CC_HMA (vpci, lengthMA)

-- BBands for VPCI
local vpciBB = BBANDS(vpci, bbLength, bbMult, bbMult, SmaType)
local upperBB = vpciBB[1]
local lowerBB = vpciBB[3]

-- Plotting VPCI and its Bollinger Bands
Plot(2, 'VPCI', vpci, White)
Plot(2, 'VPCI MA', vpciMA, Orange)
local upperPlot = Plot(2, 'Upper BB', upperBB, Red)
local lowerPlot = Plot(2, 'Lower BB', lowerBB, Green)
PlotBands(upperPlot, lowerPlot, SkyBlue(15))

-- Signal Logic based on VPCI
local signal = SignalNone -- Initialize with no signal

-- Highlight Breaches and Determine Signal based on VPCI and its Bollinger Bands
if vpci > upperBB then
    if highlightBreaches then
        PlotSignalBar(1, Red) -- Highlight overbought condition
    end
    signal = SignalLong
elseif vpci < lowerBB then
    if highlightBreaches then
        PlotSignalBar(3, Green) -- Highlight oversold condition
    end
    signal = SignalShort
end

-- Optionally, you could also plot the VPCI signal directly as a shape on the chart
-- This is in addition to the BB breaches highlight
if signal == SignalLong then
    PlotShape(0, ShapeTriangleUp, Gold, 3, true) -- Indicate a long signal
elseif signal == SignalShort then
    PlotShape(0, ShapeTriangleDown, Teal, 3, true) -- Indicate a short signal
end

-- Return the custom signal
DefineOutput(EnumType, signal, 'Signal result', 'TradeBotContainer, Indicator Container, Signal Helpers')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!