Vpa Candles
Vpa Candles
0 at
https://mozilla.org/MPL/2.0/
// © karthikmarar
//@version=4
// This is a updated version of the VPA Analysis, Rechristened as VPA 5.0 to be
inline with the Amibroker Version.
// Thanks to Marge Pande for Coding assistance - Resistance and Volume Lines and
some updates
// Credits to Quantnomad for the new Alert log (Public Script).
// Revision Notes
// Added the Bar Status and Trend Indication Table
// Aded the Alert Indicatio and LOg
// New signals like two bar reversal and Ease of movement added
// Option to switch off various VSA indication added
//Added option to plot Ressitance and Volume LInes
study("VPA - 5.0 ", overlay=true)
bkbg = input(title="Black Background", type=input.bool, defval=false)
showtrend = input(false, title="Show Trend Bands", type=input.bool, group="Bands")
strband = input(false, title="Show Strength Bands", type=input.bool, group="Bands")
plot50 = input(title="Plot 50 MA", type=input.bool, defval=false, group="Mov.Avg")
plot200 = input(title="Plot 200 MA", type=input.bool, defval=false,
group="Mov.Avg")
plot(plot50? sma(close,50): na, "EMA50", color= color.blue, style = plot.style_line
)
plot(plot200? sma(close,200): na,"EMA200", color=color.fuchsia, style =
plot.style_line )
volAvg = sma(volume,40)
volMean = stdev(volAvg,30)
volUpBand3 = volAvg + (3*volMean)
volUpBand2 = volAvg + (2*volMean)
volUpBand1 = volAvg + (1*volMean)
volDnBand1 = volAvg -(1*volMean)
volDnBand2 = volAvg - (2*volMean)
H = high
L = low
V = volume
C = close
O = open
midprice = (H+L)/2
spread = (H-L)
avgSpread = sma(spread,40)
AvgSpreadBar = spread > avgSpread// to be checked
wideRangeBar = spread>(1.5*avgSpread)
narrowRangeBar = spread<(0.7*avgSpread)
lowVolume = V<volume[1] and V<volume[2] and V <volAvg // mods
upBar = C>close[1]//C>Ref(C,-1)
downBar = C<close[1]//C<Ref(C,-1)
highVolume = V>volume[1] and volume[1]>volume[2]// Review
closeFactor = C-L
clsPosition = spread/closeFactor
closePosition = ((closeFactor == 0) ? (avgSpread) : (clsPosition))
vb = V > volAvg or V> volume[1]
upClose = C>=((spread*0.7)+L)// close is above 70% of the Bar
downClose = C<=((spread*0.3)+L)// close is below the 30% of the bar
aboveClose = C>((spread*0.5)+L)// close is between 50% and 70% of the bar
belowClose = C<((spread*0.5)+L)// close is between 50% and 30% of the bar
midClose = C>((spread*0.3)+L) and C<((spread*0.7)+L)// close is between 30% and
70% of the bar
veryLowClose = closePosition>4//close is below 25% of the bar
veryHighClose = closePosition<1.35// Close is above 80% of the bar
ClosePos =
iff(C<=((spread*0.2)+L),1,iff(C<=((spread*0.4)+L),2,iff(C<=((spread*0.6)+L),3,iff(C
<=((spread*0.8)+L),4,5))))
//1 = downClose, 2 = belowClose, 3 = midClose, 4 = aboveClose, 6 = upClose
volpos = iff(V>(volAvg*2),1,iff(V>(volAvg*1.3),2,iff(V>volAvg,3,iff(V<volAvg and
(V<volAvg*0.7) ,4,5))))
//1 = veryhigh, 2 = High , 3 = AboveAverage, 4 = volAvg //LessthanAverage, 5 =
lowVolume
k = RWIHi-RWILo
ground = RWIHi
sky = RWILo
j = RWILHi-RWILLo
j2 = RWILHi
k2 = RWILLo
//=========================================================================|
// Slope Calculation |
//=========================================================================|
src = sma(close,5)
//--------------longterm trend---------------
lts = linreg(src, 40, 0)
ltsprev = linreg(close[3], 40, 0)
ltsslope = ((lts - ltsprev) / 3 )
//-------------Medium Term Trend-------------
mts = linreg(src, 20, 0)
mtsprev = linreg(close[3], 20, 0)
mtsslope = ((mts - mtsprev) / 3 )
//-------------short Term Trend-------------
sts = linreg(src, 3, 0)
stsprev = linreg(close[1], 3, 0)
stsslope = ((sts - stsprev) / 2 )
tls = stsslope
//=========================================================================|
// VSA SIGNAL GENERATION |
//=========================================================================|
upThrustBar = wideRangeBar and downClose and high > high[1] and upmid==1 //WRB
and UHS in midterm trend
nut = wideRangeBar and downClose and freshGndHi and highVolume // NEW
SIGNAL - Upthrust after new short up move
bc = wideRangeBar and aboveClose and volume == highest(volume,60) and
upmajor==1 // Buying Climax
upThrustBar1 = wideRangeBar and (ClosePos==1 or ClosePos==2) and upminor>0 and
H>H[1]and (upmid>0 or upmajor>0) and volpos < 4 // after minor up trend
upThrustBartrue = wideRangeBar and ClosePos==1 and upmajor>0 and H>H[1] and volpos
< 4//occurs after a major uptrend
upThrustCond1 = upThrustBar[1] and downBar and not narrowRangeBar // The Bar
after Upthrust Bar- Confirms weakness
upThrustCond2 = upThrustBar[1] and downBar and V>(volAvg*1.3) // The Bar after
Upthrust Bar- Confirms weakness
upThrustCond3 = upThrustBar and V>(volAvg*2) // Review
topRevBar = V[1]>volAvg and upBar[1] and wideRangeBar[1] and downBar and
downClose and wideRangeBar and upmajor>0 and H==highest(H,10)// Top Reversal bar
PseudoUpThrust = (upBar[1])and H>H[1] and V[1]>1.5*volAvg and downBar and
downClose and not upThrustBar
pseudoUtCond = PseudoUpThrust[1] and downBar and downClose and not upThrustBar
trendChange = upBar[1] and H==highest(H,5) and downBar and (downClose or
midClose) and V>volAvg and upmajor>0 and upmid>0 and not wideRangeBar and not
PseudoUpThrust
noDemandBarUt = upBar and narrowRangeBar and lowVolume and (aboveClose or
upClose) and ((upminor>=0 and upmid>=0) or (upminor<=0 and upminor>=0))//in a up
market
noDemandBarDt = upBar and narrowRangeBar and lowVolume and (aboveClose or
upClose) and (upminor<=0 or upmid<=0)// in a down or sidewayss market
noSupplyBar = downBar and narrowRangeBar and lowVolume and midClose
showtrb = input(true, "Show Top Reversal Bar (TRB)", tooltip="Top Reversal. Sign of
Weakness. ", group="VSA Signals")
plotshape(showtrb ? topRevBar and not sellCond and not UT and not effortUpfail :
na, "TRB", style=shape.triangledown, location=location.abovebar,
color=color.new(#ff9900, 0), text="TRB", textcolor=#ff9900, editable=false,
size=size.tiny)
//alertcondition(topRevBar , title='Alert on TRB', message='Top Reversal. Sign of
Weakness. ')
showtch = input(true, "Show Trend Change (TC)", tooltip="High volume Downbar after
an upmove on high volume indicates weakness.", group="VSA Signals")
plotshape(showtch ? trendChange and not effortUpfail : na, "TC",
style=shape.triangledown, location=location.abovebar, color=color.new(#ff471a, 0),
text="TC", textcolor=#ff471a, editable=false, size=size.tiny)
//alertcondition(trendChange , title='Alert on TCH', message='High volume Downbar
after an upmove on high volume indicates weakness. ')
showlvtst = input(true, "Show Low Volume Supply Test (LVT/ST)", tooltip="Test for
supply. An upBar closing near High after a Test confirms strength.", group="VSA
Signals")
plotshape(showlvtst ? lowVolTest and not effortDownFail : na, "LVT",
style=shape.circle, location=location.belowbar, color=color.new(color.lime, 0),
text="LVT", textcolor=color.green, editable=false, size=size.tiny)
plotshape(showlvtst ? lowVolTest2 and not effortUp : na, "ST",
style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0),
text="ST", textcolor=color.green, editable=false, size=size.tiny)
lvt = lowVolTest or lowVolTest2
//alertcondition(lvt , title='Alert on LVT', message='Test for supply. An upBar
closing near High after a Test confirms strength. ')
EFD = effortDownFail
ST1 = strengthDown0
ST2 = strengthDown and not strengthDown2
strcond = (strengthDown2 and not strengthDown0 and not strengthDown and not
strengthDown1)? 1:0
ST3 = strengthDown1
ST4 = strengthDown2 and strcond
ST5 = strengthDown2 and not strcond
ST = ST1 or ST2 or ST3 or ST4 or ST5
showstsig = input(true, "Show Strength Signals (ST)", tooltip="Strength seen
returning after a down trend.", group="VSA Signals")
plotshape(showstsig ? strengthDown0 and not EFD and not effortUp and not stopVolume
: na, "ST1", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), text="ST1", textcolor=color.green, editable=false,
size=size.tiny)
plotshape(showstsig ? strengthDown and not strengthDown2 and not EFD and not
effortUp and not stopVolume : na, "ST2", style=shape.triangleup,
location=location.belowbar, color=color.new(color.lime, 0), text="ST1",
textcolor=color.green, editable=false, size=size.tiny)
plotshape(showstsig ? strengthDown1 and not EFD and not effortUp and not stopVolume
: na, "ST3", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), text="ST1", textcolor=color.green, editable=false,
size=size.auto)
plotshape(showstsig ? strengthDown2 and strcond and not EFD and not effortUp and
not stopVolume : na, "ST4", style=shape.triangleup, location=location.belowbar,
color=color.new(color.lime, 0), text="ST2", textcolor=color.green, editable=false,
size=size.tiny)
//alertcondition(ST , title='Alert on ST1, ST2, ST3, ST4 and ST', message='Strength
seen returning after a down trend. ')
showed = input(true, "Show Effort Down (ED)", tooltip="Effort to Move Down. Bearish
Sign.", group="VSA Signals")
plotshape(showed ? effortDown and not effortUpfail : na, "ED",
style=shape.triangledown, location=location.abovebar, color=color.new(color.red,
0), text="ED", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(effortDown , title='Alert on ED', message='Effort to Move Down.
Bearish Sign ')
showedf = input(true, "Show Effort Down Fail (EDF)", tooltip="Effort to Move Down
Failed. Bullish sign.", group="VSA Signals")
plotshape(showedf ? effortDownFail and not ST : na, "EDF", style=shape.triangleup,
location=location.belowbar, color=color.new(color.lime, 0), text="EDF",
textcolor=color.green, editable=false, size=size.tiny)
plotshape(showedf ? effortDownFail and ST : na, "EDF", style=shape.triangleup,
location=location.belowbar, color=color.new(color.lime, 0), text="ST\nEDF",
textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(effortDownFail , title='Alert on EDF', message='Effort to Down
Failed. Bullish sign ')
showtb = input(true, "Show Two bar Reversal (TB)", tooltip="Two bar revesal -
Indicated possibility of reversal of current move. High volume adds strength",
group="VSA Signals")
plotshape(showtb ? tbc2 : na, "TB", style=shape.triangleup,
location=location.belowbar, color=color.new(color.green, 0), text="TB",
textcolor=color.red, editable=false, size=size.tiny)
plotshape(showtb ? tbc3 : na, "TB", style=shape.triangleup,
location=location.belowbar, color=#f7e30c, text="TB", textcolor=color.red,
editable=false, size=size.tiny)
plotshape(showtb ? tbc4 : na, "TB", style=shape.triangledown,
location=location.abovebar, color=color.new(color.red, 0), text="TB",
textcolor=color.green, editable=false, size=size.tiny)
plotshape(showtb ? tbc5 : na, "TB", style=shape.triangledown,
location=location.abovebar, color=#f7e30c, text="TB", textcolor=color.green,
editable=false, size=size.tiny)
//alertcondition(tbc2 or tbc3 , title='Alert on TBR', message='Two Bar Reversal to
the Upside')
//alertcondition(tbc4 or tbc5 , title='Alert on TBR', message='Two Bar Reversal to
the Downside')
//-----------------------------Bar coloring
Code-------------------------------------------------
//---------------------
if (upThrustBar)
log_msg("UpThrust Bar - A Sure sign of weakness", 'weakness')
if (upThrustCond1)
log_msg("A downbar after an Upthrust. Confirm weakness." , 'weakness')
if (upThrustCond3)
log_msg("This upthrust at very High Voume, Confirms weakness" , 'weakness')
if (PseudoUpThrust)
log_msg("Psuedo UpThrust. A Sign of Weakness." , 'weakness')
if (pseudoUtCond)
log_msg("A Down Bar closing down after a Pseudo Upthrust confirms weakness." ,
'weakness')
if (trendChange)
log_msg("High volume Downbar after an upmove on high volume indicates
weakness." , 'weakness')
if (sellCond)
log_msg("Possible end of Uptrend and start of Downtrend soon." , 'weakness')
if (effortUpfail)
log_msg("Effort to Move up has failed. Bearish sign." , 'weakness')
if (bearBar)
log_msg("Day's Move Indicates weakness." , 'weakness')
if (bc)
log_msg("Potential Buying climax." , 'weakness')
if (effortDown)
log_msg("Effort to Fall. Bearish sign. " , 'weakness')
if (tbc4)
log_msg("Two Bar Reversal on Higher volume " , 'weakness')
if (noSupplyBar)
log_msg("No Supply. A sign of Strength. " , 'weakness')
if (lowVolTest)
log_msg("Test for supply. " , 'strength')
if (lowVolTest2)
log_msg("An upBar closing near High after a Test confirms strength." ,
'strength')
if (lowVolTest1)
log_msg("Test for supply in a uptrend. Sign of Strength." , 'strength')
if (strengthDown1)
log_msg("Strength seen returning after a down trend. High volume adds to
strength.." , 'strength')
if (strengthDown0 and not strengthDown)
log_msg("Strength seen returning after a down trend." , 'strength')
if (strengthDown and not strengthDown1)
log_msg("Strength seen returning after a down trend." , 'strength')
if (buyCond)
log_msg("Possible end of downtrend and start of uptrend soon.." , 'strength')
if (effortDownFail)
log_msg("Effort to Move Down has failed. Bulish sign. " , 'strength')
if (strengthDown2)
log_msg("High volume upBar closing on the high indicates strength. " ,
'strength')
if (stopVolume)
log_msg("Stopping volume. Normally indicates end of bearishness is nearing." ,
'strength')
if (revUpThrust)
log_msg("Reverse upthrust. Indicates strength" , 'strength')
if (bullBar )
log_msg("Day's Move Indicates strength. " , 'strength')
if (tbc2 )
log_msg("Two Bar Reversal on Higher volume. " , 'strength')
if (tbc2a )
log_msg("Two Bar like Reversal to upside on high volume. " , 'strength')
if (sc )
log_msg(" Possible Selling Climax " , 'strength')
if (topRevBar )
log_msg("Top Reversal. Sign of Weakness. " , 'warning')
if (noDemandBarDt )
log_msg("No Demand. upside unlikely soon. " , 'warning')
if (noDemandBarUt )
log_msg("No Demand in a Uptrend. A sign of Weakness. " , 'warning')
if (fom1 )
log_msg("High Volume unable to move the price. Could be a Supply / Demand Area
" , 'warning')
if (tbc2 )
log_msg("Two Bar Reversal to upside on High volume. " , 'warning')
if (tbc3 )
log_msg("Two Bar Reversal to upside on Low volume. " , 'warning')
if (tbc4 )
log_msg("Two Bar Reversal to upside on High volume. " , 'warning')
if (tbc5 )
log_msg("Two Bar Reversal to upside on Low volume. " , 'warning')
///////////////////////////////
// Create and fill log table //
for i = 1 to log_show_msg
arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset
if (arr_i < 0)
break
//============================================================
//
===================================================================================
=|
// Support & Resistance volume Lines
|
//
===================================================================================
=|
showrs = input(false, "Show support and resistance lines", group="Support &
Resistance lines")
sens = input(10, "Sensitivity", minval=2, maxval=15, group="Support & Resistance
lines")
ph = pivothigh(high, sens, 0)
pl = pivotlow(low, sens, 0)
//
===================================================================================
=|
// End of Support & Resistance volume Lines
|
//
===================================================================================
=|