Market Structure
Market Structure
//
-----------------------------------------------------------------------------------
--------------- //
//# *
-----------------------------------------------------------------------------------
-----------
//# *
//# * Study : Pivot Points
//# * - Pivot Type Options
//# * 1-) Camarilla
//# * 2-) DeMark
//# * 3-) Fibonacci
//# * 4-) Floor - Classic
//# * 5-) Swing - Custom interpretation
//# * 6-) Traditional
//# * 7-) Woodie
//# *
//# * - Additions
//# * 1-) Central Pivot Range
//# * 2-) Previous TimeFrame OHLC Levels
//# *
//# * - Plotting Add-Ons - Plots the following custom and built-in
indicators
//# * 1-) ADX Colored DMI Line - custom interpretation of
directional movement index
//# * 2-) Volatility Colored Price/MA Line - custom
interpretation of "price distance to its moving average" study
//# * 3-) Volume Weighted Colored Bars - custom volume study
presentation
//# * 4-) Ichimoku Cloud Projection - build-in with only kumo
cloud display option
//# * 5-) Bollinger Bands : build-in with customized multi bands
display
//# * 6-) Logistic EMA - Logistic Map Equation apllied EMA
//# * 7-) Volume Weighted Average Price (VWAP) - build-in
//# * 8-) Linear Regression : build-in with slight customzations
//# * 9-) Pivot Points High Low : build-in with major
customzations
//# *
//# * - Panel Add-Ons - Statistical panel presents evaluation of the
following custom and built-in indicators
//# * 1-) Directional Movment Index (DMI)
//# * 2-) Ichimoku Cloud
//# * 3-) Price Distance to its MA - custom interpretation
//# * 4-) RSI Oscillator
//# * 5-) Stochastic Oscillator
//# * 6-) MACD Oscillator
//# * 7-) Fear & Greed - custom interpretation
//# * 8-) Volume - custom interpretation
//# *
//# * - Market Sentiment Meter
//# * - Range Meter with Average True Range AddOn
//# *
//# * Author : � Viswanath Palyam
//# *
//# * Revision History
//# * Release : Dec 04, 2020
//# * Update : Dec 09, 2020 : Bollinger Bands addition
//# * Update : Dec 12, 2020 : Code completely reworked by introducing arrays
//# * - Logistic EMA (LEMA) addition
//# * Update : Dec 13, 2020 : Panel additions
//# * - RSI, STOCH and MACD
//# * - Fear & Greed
//# * Update : Dec 14, 2020 : Central Pivot Range (CPR) addition
//# * Update : Dec 17, 2020 : Market Sentiment Meter addition
//# * Update : Dec 28, 2020 : Previous TimeFrame OHLC plotting addition
//# * Update : Dec 31, 2020 : Range Meter addition
//# * Update : Jan 04, 2021 : Added ability to support
//# * - Weekly and/or Monthly Pivot
//# * - Historical Pivots
//# * - Range Meter extended with ATR Range
//# * Update : Jan 07, 2021 : Linear Regresion addition
//# * Update : Mar 01, 2021 : Enchantments with Bollinger Bands, and Linear
Regression
//# * Update : Mar 24, 2021 : Linear Regression enable both Deviation
Plottings, slightly re-organized script inputs and added tips for options
//# * Update : Apr 20, 2021 : Added Alerts to Pivot Support & Resistance
Levels, Linear Regression, Previous HL, BB stDev 3rd and 4th Band, LEMA
//# * - Added ability to customize Pivot Support &
Resistance Levels
//# * - Added Camarilla Level 6
//# * - Enlarged labels with tooltips added
//# * - Imporved Price Range Meter
//# * Update : Nov 22, 2021 : Pine Error Fix : probable cause of the error is
likely pine core update by pine team may have affected the scripts behaviour
//# * Update : Dec 15, 2021 : Slight improvments and additions
//# * - Volume info along with avearage volume added
to statistical panel
//# * - Imporved Price Range Meter
//# * - Converted to Pine v5
//# * Update : May 29, 2022 : Optimization and user requests
//# * - Pivot Points Timeframe AUTO resolution
determination made same as TV's build-in
//# * - More Customization options
//# * * Pivot S&R Level Lables
//# * * Linear Regression Channel
//# * * Previous OHLC
//# * Update : Jul 25, 2022 : User requests
//# * - Specific for Indian Users : Start Trading
Week from Specific Day option added, default option is Monday
//# * - Display Middle Pivot S&R Level Lines option
added, default value set to false
//# * - Individual color option for each Pivot S&R
Level Line added. Disabling a specific pivot level option removed, instead color
transparency can be adjusted or remove the line display
//# * - Pivot Points types extended to include
'Classic' and 'Traditional' pivot points
//# * - Slight aesthetic changes
//# * Update : Sep 15, 2022 : Indicator addition, User Requests and
Improvments
//# * - customized pivot points high low indicator
addition
//# * - replaced statistical panel label wth a table
//# * - slight aesthetic changes with historcal
pivots (had to remove BB background fill)
//# * Update : Nov 10, 2022 : Pivot points high low improvments
//# * - a temporary pivot point high low detection
added (3 bars)
//# * - pivot point high low label customization
//# * OHLC data selection option added, besides
internally calculated data now fetching data with security() function option is
available
//# * Displying both Selected Pivots and CPR
historical levels at the same time is made available
//# * Moving thr location of Market Sentiment Meter
and Price Range Meter is now possible with horizontal and vertical offset options
//# *
//# *
-----------------------------------------------------------------------------------
-----------
//
-----------------------------------------------------------------------------------
--------------- //
//------------------------------------------------------------------------------
// security() function free higher timeframe price calculations
f_htf_ohlc(_go, _htf, _s, _wStart) =>
var htf_o = 0., var htf_h = 0., var htf_l = 0., htf_c = close // higher
time frame ohlc
var htf_ox = 0., var htf_hx = 0., var htf_lx = 0., var htf_cx = 0. // previous
higher time frame ohlc
if _go
if _htf == 'D' and _s == 'Daily' ? dayofweek != dayofweek[1] : _htf ==
'W' ? dayofweek(time) == _wStart and ta.change(time('D')) : ta.change(time(_htf))
htf_ox := htf_o, htf_o := open
htf_hx := htf_h, htf_h := high
htf_lx := htf_l, htf_l := low
htf_cx := htf_c[1]
true
else
htf_h := math.max(high, htf_h)
htf_l := math.min(low , htf_l)
true
//------------------------------------------------------------------------------
// Get Pivot Points and Support & Resistance Levels
if _go
if _pvt == 'Camarilla'
r5x := _h / _l * _c
r4x := _c + (_h - _l) * 1.1 / 2
r3x := _c + (_h - _l) * 1.1 / 4
//r2x := _c + (_h - _l) * 1.1 / 6
//r1x := _c + (_h - _l) * 1.1 / 12
r6x := r5x + 1.168 * (r5x - r4x)
//s1x := _c - (_h - _l) * 1.1 / 12
//s2x := _c - (_h - _l) * 1.1 / 6
s3x := _c - (_h - _l) * 1.1 / 4
s4x := _c - (_h - _l) * 1.1 / 2
s5x := _c - (r5x - _c)
s6x := _c - (r6x - _c)
s6x
[r6x, r5x, r4x, r3x, r2x, r1x, px, s1x, s2x, s3x, s4x, s5x, s6x]
//------------------------------------------------------------------------------
// Central Pivot Range
//------------------------------------------------------------------------------
// line/label/alert functions
f_drawLineX(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
var id = line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width)
f_processPivotLevelX(_show, _x1, _y, _x2, _c, _s, _w, _lb, pivot, _levels, _pos) =>
if _show
f_drawLineX(_x1, _y, _x2, _y, xloc.bar_time, extend.none, _c, _s, _w)
f_getStyle(_style) =>
_style == 'Solid' ? line.style_solid : _style == 'Dotted' ? line.style_dotted :
line.style_dashed
//
-----------------------------------------------------------------------------------
----------- //
// Definitions
----------------------------------------------------------------------------------
//
tooltip_range = 'Displays graphical price range during the higher time frame
period as well its previous higher time frame range\nincludes the range numerical
display calculated based on selected ATR period and multiplier'
tooltip_pvt = 'The Pivot Points High Low indicator aims to predict and
determine price changes and potential reversals in the market'
tooltip_linreg = 'A line that best fits the prices specified over a user-
defined time period. It is calculated using the least squares method\n' +
'Both Upper/Lower and Standart Devaiation channels are
plotted'
// -Inputs
-----------------------------------------------------------------------------------
--- //
// -Calculations
-------------------------------------------------------------------------------- //
[htf_o1s, htf_h1s, htf_l1s, htf_c1s, htf_os] = request.security(syminfo.tickerid,
htf, [open[1], high[1], low[1], close[1], open], lookahead = barmerge.lookahead_on)
[htf_o1, htf_h1, htf_l1, htf_c1, htf_o , htf_h, htf_l, htf_c] = f_htf_ohlc(true,
htf, htf_tf, wStart)
htf_o1 := customStrat != 'Monday' ? htf_o1 : ohlcData == 'Internally Calculated' ?
htf_o1 : htf_o1s
htf_h1 := customStrat != 'Monday' ? htf_h1 : ohlcData == 'Internally Calculated' ?
htf_h1 : htf_h1s
htf_l1 := customStrat != 'Monday' ? htf_l1 : ohlcData == 'Internally Calculated' ?
htf_l1 : htf_l1s
htf_c1 := customStrat != 'Monday' ? htf_c1 : ohlcData == 'Internally Calculated' ?
htf_c1 : htf_c1s
htf_o := customStrat != 'Monday' ? htf_o : ohlcData == 'Internally Calculated' ?
htf_o : htf_os
[r6m, r5m, r4m, r3m, r2m, r1m, pm, s1m, s2m, s3m, s4m, s5m, s6m] =
f_get_pivot(htf != 'M' and (dispWM == 'Both' or dispWM == 'Monthly'), pivot,
htf_om, htf_hm, htf_lm, htf_cm, htf_om0)
[r6w, r5w, r4w, r3w, r2w, r1w, pw, s1w, s2w, s3w, s4w, s5w, s6w] =
f_get_pivot(htf != 'W' and (dispWM == 'Both' or dispWM == 'Weekly' ), pivot,
htf_ow, htf_hw, htf_lw, htf_cw, htf_ow0)
[r61, r51, r41, r31, r21, r11, p1, s11, s21, s31, s41, s51, s61] =
f_get_pivot(pivot != '?? None', pivot, htf_o1, htf_h1, htf_l1, htf_c1, htf_o )
[r6 , r5 , r4 , r3 , r2 , r1 , p , s1 , s2 , s3 , s4 , s5 , s6 ] = f_get_pivot(true
, pivot, htf_o , htf_h , htf_l , htf_c , htf_o )
//------------------------------------------------------------------------------
// Linear Regression - Build-in : slight presentation changes
for i = 0 to linregLength - 1 by 1
val = linregSrc[i]
per = i + 1.0
sumX += per
sumY += val
sumXSqr += per * per
sumXY += val * per
sumXY
for i = 0 to periods by 1
price = high[i] - val
price := linregSrc[i]
dxt = price - average
dyt = val - daY
price -= val
stdDevAcc += price * price
dsxx += dxt * dxt
dsyy += dyt * dyt
dsxy += dxt * dyt
val += slope
val
if f_crossingLevelX(close, endPrice)
alert('LinReg (PVTvX) : ' + syminfo.ticker + ' crossing linear regression
line')
if f_crossingLevelX(close, endPrice + upperMult * stdDev)
alert('LinReg (PVTvX) : ' + syminfo.ticker + ' crossing linear regression
upper standart deviation line')
if f_crossingLevelX(close, endPrice + lowerMult * stdDev)
alert('LinReg (PVTvX) : ' + syminfo.ticker + ' crossing linear regression
lower standart deviation line')
if f_crossingLevelX(close, endPrice + upDev)
alert('LinReg (PVTvX) : ' + syminfo.ticker + ' crossing linear regression
upper deviation line')
if f_crossingLevelX(close, endPrice - upDev)
alert('LinReg (PVTvX) : ' + syminfo.ticker + ' crossing linear regression
lower deviation line')
if f_crossingLevelX(pearsonR, pearsonAlert)
alert('LinReg (PVTvX) : ' + syminfo.ticker + ' crossing pearsonR
threshold')
//------------------------------------------------------------------------------
// ADX Colored Directional Movement Index Line by DGT
//------------------------------------------------------------------------------
// Price Distance to its Moving Average by DGT
//------------------------------------------------------------------------------
// Volume Weighted Colored Bars by Kivan� �ZBILGI�
nzVolume = nz(volume)
volMA = ta.sma(nzVolume, vwcbLen)
//------------------------------------------------------------------------------
// Pivot Points High Low - build-in, slight presentation changes
pvtLengthTemp = 3
pvtHighTemp = ta.pivothigh(pvtLengthTemp, pvtLengthTemp)
pvtLowTemp = ta.pivotlow (pvtLengthTemp, pvtLengthTemp)
proceedTemp = not na(pvtHighTemp) or not na(pvtLowTemp)
var x1 = 0
var x2 = 0
var x2Temp = 0
var pvtHigh1 = 0.
var pvtLow1 = 0.
var pvtHigh1Temp = 0.
var pvtLow1Temp = 0.
if proceed
x1 := x2
x2 := bar_index
if proceedTemp
x2Temp := bar_index
profileLength = x2 - x1
profileLengthTemp = x2Temp - pvtLengthTemp - x2 + pvtLength
//------------------------------------------------------------------------------
// Ichimoku Cloud - build-in, slight presentation changes
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
//------------------------------------------------------------------------------
// Bollinger Bands - build-in
//------------------------------------------------------------------------------
// Logistic EMA by DGT - custum application of Logistic Map Equation
// https://www.tradingview.com/script/jUuBT0bO-Logistic-EMA-w-Signals-by-DGT/
maColor = lema > lema200 ? lema > lema100 ? lema > lema50 ? color.olive :
color.aqua : color.orange : color.maroon
hlColor = trend == 1 ? #006400 : #910000
//------------------------------------------------------------------------------
// Trading Psychology - Fear & Greed Index by DGT : Panel Add-On
// https://www.tradingview.com/script/HfNGbuRt-Trading-Psychology-Fear-Greed-Index-
by-DGT/
slowLength = 144
fastLength = 21
smoothLen = 5
pmacd = (close / ta.ema(close, slowLength) - 1) * 100
ror = ta.change(close, slowLength) / close[slowLength] * 100
accDist = close == high and close == low or high == low ? 0 : (2 * close - low -
high) / (high - low)
moneyFlow = math.sum(accDist * nzVolume, fastLength) / math.sum(nzVolume,
fastLength) * 100
vix = request.security('VIX', timeframe.period, -(close / ta.ema(close,
slowLength) - 1) * 100, barmerge.gaps_off, barmerge.lookahead_on)
gold = request.security('GOLD', timeframe.period, -(1 - close[fastLength] /
close) * 100, barmerge.gaps_off, barmerge.lookahead_on)
avg = nzVolume ? math.avg(pmacd, ror, vix, gold, moneyFlow) :
math.avg(pmacd, ror, vix, gold)
feargreed = ta.rma(avg, smoothLen)
//------------------------------------------------------------------------------
// VWAP - build-in
computeVWAP(src, isNewPeriod, stDevMultiplier) =>
var float sumSrcVol = na
var float sumVol = na
var float sumSrcSrcVol = na
//timeChange(period) =>
// ta.change(time(period))
isNewPeriod = ta.change(time(htf))
//na(src[1]) ? true : anchor == 'Session' ? timeChange('D') : anchor == 'Week' ?
timeChange('W') : anchor == 'Month' ? timeChange('M') : anchor == 'Quarter' ?
timeChange('3M') : anchor == 'Year' ? timeChange('12M') : anchor == 'Decade' ?
timeChange('12M') and year % 10 == 0 : anchor == 'Century' ? timeChange('12M') and
year % 100 == 0 : false
float vwapValue = na
float std = na
float upperBandValue = na
float lowerBandValue = na
//if not(hideonDWM and timeframe.isdwm)
[_vwap, bottom, top] = computeVWAP(src, isNewPeriod, stdevMult)
vwapValue := _vwap
upperBandValue := showBands ? top : na
lowerBandValue := showBands ? bottom : na
// -Plotting
-----------------------------------------------------------------------------------
- //
//------------------------------------------------------------------------------
// Pivots
when = barstate.islast and pivot != '?? None' and i_dispPVT and time_x21 - timenow
< 3600000 * i_when
style_r = f_getStyle(i_style_r)
f_processPivotLevelX(when and i_show_r, time_x1, r6, time_x2, i_color_r6, style_r,
i_width_r, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r, time_x1, r5, time_x2, i_color_r5, style_r,
i_width_r, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r, time_x1, r4, time_x2, i_color_r4, style_r,
i_width_r, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r, time_x1, r3, time_x2, i_color_r3, style_r,
i_width_r, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r, time_x1, r2, time_x2, i_color_r2, style_r,
i_width_r, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r, time_x1, r1, time_x2, i_color_r1, style_r,
i_width_r, '', pivot, srLabel, srLabelPos)
style_p = f_getStyle(i_style_p)
f_processPivotLevelX(when and i_show_p, time_x1, p, time_x2, i_color_p, style_p,
i_width_p, '', pivot, srLabel, srLabelPos)
style_s = f_getStyle(i_style_s)
f_processPivotLevelX(when and i_show_s, time_x1, s1, time_x2, i_color_s1, style_s,
i_width_s, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s, time_x1, s2, time_x2, i_color_s2, style_s,
i_width_s, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s, time_x1, s3, time_x2, i_color_s3, style_s,
i_width_s, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s, time_x1, s4, time_x2, i_color_s4, style_s,
i_width_s, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s, time_x1, s5, time_x2, i_color_s5, style_s,
i_width_s, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s, time_x1, s6, time_x2, i_color_s6, style_s,
i_width_s, '', pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r and i_midPvt, time_x11, r61 > 0 and r51 >
0 ? math.avg(r61, r51) : 0, time_x21, i_color_r6, style_r, i_width_r - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r and i_midPvt, time_x11, r51 > 0 and r41 >
0 ? math.avg(r51, r41) : 0, time_x21, i_color_r5, style_r, i_width_r - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r and i_midPvt, time_x11, r41 > 0 and r31 >
0 ? math.avg(r41, r31) : 0, time_x21, i_color_r4, style_r, i_width_r - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r and i_midPvt, time_x11, r31 > 0 and r21 >
0 ? math.avg(r31, r21) : 0, time_x21, i_color_r3, style_r, i_width_r - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r and i_midPvt, time_x11, r21 > 0 and r11 >
0 ? math.avg(r21, r11) : 0, time_x21, i_color_r2, style_r, i_width_r - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_r and i_midPvt, time_x11, r11 > 0 and p1 >
0 ? math.avg(r11, p1 ) : 0, time_x21, i_color_r1, style_r, i_width_r - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s and i_midPvt, time_x11, s11 > 0 and p1 >
0 ? math.avg(s11, p1 ) : 0, time_x21, i_color_s1, style_s, i_width_s - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s and i_midPvt, time_x11, s21 > 0 and s11 >
0 ? math.avg(s21, s11) : 0, time_x21, i_color_s2, style_s, i_width_s - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s and i_midPvt, time_x11, s31 > 0 and s21 >
0 ? math.avg(s31, s21) : 0, time_x21, i_color_s3, style_s, i_width_s - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s and i_midPvt, time_x11, s41 > 0 and s31 >
0 ? math.avg(s41, s31) : 0, time_x21, i_color_s4, style_s, i_width_s - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s and i_midPvt, time_x11, s51 > 0 and s41 >
0 ? math.avg(s51, s41) : 0, time_x21, i_color_s5, style_s, i_width_s - 2, '',
pivot, srLabel, srLabelPos)
f_processPivotLevelX(when and i_show_s and i_midPvt, time_x11, s61 > 0 and s51 >
0 ? math.avg(s61, s51) : 0, time_x21, i_color_s6, style_s, i_width_s - 2, '',
pivot, srLabel, srLabelPos)
plot(spHistDisp and s11 > 0 ? htf_time or islast ? na : s11 : na, 'Historical S1',
i_color_s1, i_width_s, plot.style_linebr, show_last=pll, editable=false)
plot(spHistDisp and s21 > 0 ? htf_time or islast ? na : s21 : na, 'Historical S2',
i_color_s2, i_width_s, plot.style_linebr, show_last=pll, editable=false)
plot(spHistDisp and s31 > 0 ? htf_time or islast ? na : s31 : na, 'Historical S3',
i_color_s3, i_width_s, plot.style_linebr, show_last=pll, editable=false)
plot(spHistDisp and s41 > 0 ? htf_time or islast ? na : s41 : na, 'Historical S4',
i_color_s4, i_width_s, plot.style_linebr, show_last=pll, editable=false)
plot(spHistDisp and s51 > 0 ? htf_time or islast ? na : s51 : na, 'Historical S5',
i_color_s5, i_width_s, plot.style_linebr, show_last=pll, editable=false)
plot(spHistDisp and s61 > 0 ? htf_time or islast ? na : s61 : na, 'Historical S6',
i_color_s6, i_width_s, plot.style_linebr, show_last=pll, editable=false)
when := barstate.islast and dispCPR and i_dispPVT and time_x21 - timenow < 3600000
* i_when
if i_show_o
f_drawLineX(time_x10, htf_o1, time_x21, htf_o1, xloc.bar_time, extend.none,
ohlcC, style_ohlc, 1)
f_drawLabelX(time_x10, htf_o1, 'O', xloc.bar_time, yloc.price, #00000000,
label.style_label_right, ohlcC, size.normal, text.align_center, 'PREVIOUS HTF(' +
htf + ') OPEN : ' + str.tostring(htf_o1, format.mintick))
if i_show_h
f_drawLineX(time_x10, htf_h1, time_x21, htf_h1, xloc.bar_time, extend.none,
ohlcC, style_ohlc, 2)
f_drawLabelX(time_x10, htf_h1, 'H', xloc.bar_time, yloc.price, #00000000,
label.style_label_right, ohlcC, size.normal, text.align_center, 'PREVIOUS HTF(' +
htf + ') HIGH : ' + str.tostring(htf_h1, format.mintick))
if i_show_l
f_drawLineX(time_x10, htf_l1, time_x21, htf_l1, xloc.bar_time, extend.none,
ohlcC, style_ohlc, 2)
f_drawLabelX(time_x10, htf_l1, 'L', xloc.bar_time, yloc.price, #00000000,
label.style_label_right, ohlcC, size.normal, text.align_center, 'PREVIOUS HTF(' +
htf + ') LOW : ' + str.tostring(htf_l1, format.mintick))
if i_show_c
f_drawLineX(time_x10, htf_c1, time_x21, htf_c1, xloc.bar_time, extend.none,
ohlcC, style_ohlc, 1)
f_drawLabelX(time_x10, htf_c1, 'C', xloc.bar_time, yloc.price, #00000000,
label.style_label_right, ohlcC, size.normal, text.align_center, 'PREVIOUS HTF(' +
htf + ') CLOSE : ' + str.tostring(htf_c1, format.mintick))
//------------------------------------------------------------------------------
// ADX Colored Directional Movement Line by DGT
//------------------------------------------------------------------------------
// Price Distance to its Moving Average by DGT
//------------------------------------------------------------------------------
// Volume weighted Colored Bars by KIVAN� �ZBILGI�
//------------------------------------------------------------------------------
// Ichimoku Cloud - presentation customized by DGT
//------------------------------------------------------------------------------
// Pivot Points High Low
if not na(pvtLow)
tradedVolume = f_getTradedVolume(profileLength, proceed, pvtLength)
f_drawOnlyLabelX(bar_index[pvtLength], pvtLow , (pvtPrice ?
str.tostring(pvtLow , format.mintick) : '') + (pvtChange ? (pvtPrice ? ' ? %' : '?
%') + str.tostring((pvtHigh1 - pvtLow) * 100 / pvtHigh1, '#.##') : '') + (pvtVolume
and nzVolume ? (pvtPrice or pvtChange ? '\n' : '') + str.tostring(tradedVolume,
format.volume) : ''), xloc.bar_index, yloc.price, chart.fg_color,
label.style_label_up , chart.bg_color, (not pvtPrice and not pvtChange and not
pvtVolume ? size.tiny : pvtTextSize), text.align_center, 'Pivot Low : ' +
str.tostring(pvtLow , format.mintick) + '\n -Price Change : ? %' +
str.tostring((pvtHigh1 - pvtLow) * 100 / pvtHigh1, '#.##') + (nzVolume ? '\n -
Traded Volume : ' + str.tostring(tradedVolume, format.volume) + ' (' +
str.tostring(profileLength - 1) + ' bars)\n *Average Volume/Bar : ' +
str.tostring(tradedVolume / (profileLength - 1), format.volume) : '') + '\n\nNumber
of bars : ' + str.tostring(profileLength) )
pvtLow1 := pvtLow
//pvtLast := 'L'
label.delete(tempLow[1])
if x2 - pvtLength > x2Temp - pvtLengthTemp// ???
label.delete(tempHigh[1])
//------------------------------------------------------------------------------
// Bolligner Bands - customized presentation
//pu4 = plot(addons and dispBB and islast and not extendBB ? u4 : na, 'BB Upper
stDev bbMult4', color.new(color.red , 0), 1)
pu3 = plot(addons and dispBB and islast and not extendBB ? u3 : na, 'BB Upper stDev
bbMult3', color.new(color.orange, 0), 1)
pu2 = plot(addons and dispBB and islast and not extendBB ? u2 : na, 'BB Upper stDev
bbMult2', color.new(color.aqua , 0), 1)
pu1 = plot(addons and dispBB and islast and not extendBB ? u1 : na, 'BB Upper stDev
bbMult1', color.new(color.silver, 0), 1)
pl1 = plot(addons and dispBB and islast and not extendBB ? l1 : na, 'BB Lower stDev
bbMult1', color.new(color.silver, 0), 1)
pl2 = plot(addons and dispBB and islast and not extendBB ? l2 : na, 'BB Lower stDev
bbMult2', color.new(color.aqua , 0), 1)
pl3 = plot(addons and dispBB and islast and not extendBB ? l3 : na, 'BB Lower stDev
bbMult3', color.new(color.orange, 0), 1)
//pl4 = plot(addons and dispBB and islast and not extendBB ? l4 : na, 'BB Lower
stDev bbMult4', color.new(color.red , 0), 1)
//pu4e = plot(addons and dispBB and extendBB ? u4 : na, 'BB Upper stDev bbMult4
(extended)', color.new(color.red , 0), 1, show_last=pll)
pu3e = plot(addons and dispBB and extendBB ? u3 : na, 'BB Upper stDev bbMult3
(extended)', color.new(color.orange, 0), 1, show_last=pll)
pu2e = plot(addons and dispBB and extendBB ? u2 : na, 'BB Upper stDev bbMult2
(extended)', color.new(color.aqua , 0), 1, show_last=pll)
pu1e = plot(addons and dispBB and extendBB ? u1 : na, 'BB Upper stDev bbMult1
(extended)', color.new(color.silver, 0), 1, show_last=pll)
pl1e = plot(addons and dispBB and extendBB ? l1 : na, 'BB Lower stDev bbMult1
(extended)', color.new(color.silver, 0), 1, show_last=pll)
pl2e = plot(addons and dispBB and extendBB ? l2 : na, 'BB Lower stDev bbMult2
(extended)', color.new(color.aqua , 0), 1, show_last=pll)
pl3e = plot(addons and dispBB and extendBB ? l3 : na, 'BB Lower stDev bbMult3
(extended)', color.new(color.orange, 0), 1, show_last=pll)
//pl4e = plot(addons and dispBB and extendBB ? l4 : na, 'BB Lower stDev bbMult4
(extended)', color.new(color.red , 0), 1, show_last=pll)
//------------------------------------------------------------------------------
// Volume Weighted Average Price (VWAP) - Build-In
//------------------------------------------------------------------------------
// Logistic EMA (LEMA) by DGT
plot(addons and dispLEMA ? lema : na, 'LEMA Trend ', trend != trend[1] ?
hlColor[1] : hlColor, 4, show_last=pll)
plot(addons and dispLEMA ? lema : na, 'Logistic EMA (LEMA)', maColor, 2,
show_last=pll)
if f_crossingLevelX(close, lema)
alert('LEMA (PVTvX) : ' + syminfo.ticker + ' crossing Logistic EMA (LEMA)')
//------------------------------------------------------------------------------
// Statistical Panel
textSize = i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ?
size.normal : i_textSize == 'Large' ? size.large : size.tiny
statPosition = switch statPos
'Top Left' => position.top_left
'Top Center' => position.top_center
'Top Right' => position.top_right
'Middle Right' => position.middle_right
'Bottom Left' => position.bottom_left
'Bottom Center' => position.bottom_center
// Directional Movement
diStat = diplus >= diminus ? '\ndiplus(' + str.tostring(diplus, '#.##') + ') >=
diminus(' + str.tostring(diminus, '#.##') + ')' : '\ndiplus(' +
str.tostring(diplus, '#.##') + ') < diminus(' + str.tostring(diminus, '#.##') + ')'
adxMom = adxValue > adxValue[1] ? ' and rising' : ' and falling'
// Ichimoku Cloud
tkStat = conversionLine >= baseLine ? '\ntenkan-sen(' +
str.tostring(conversionLine, format.mintick) + ') >= kijun-sen(' +
str.tostring(baseLine, format.mintick) + ')' : '\ntenkan-sen(' +
str.tostring(conversionLine, format.mintick) + ') < kijun-sen(' +
str.tostring(baseLine, format.mintick) + ')'
ichiTxt = aboveCloud ? 'bullish' : belowCloud ? 'bearish' : inCloud ?
'trendless or \ntransitioning' : na
ichiTxt1 = aboveCloud ? 'price action above the kumo cloud' : belowCloud ?
'price action below the kumo cloud' : inCloud ? 'price action within the kumo
cloud' : na
ichiColor1 = aboveCloud ? color.green : belowCloud ? color.red : inCloud ?
color.black : na
// RSI
[rsiColor, rsiText, rsiTip] = if rsiValue >= 50
if rsiValue > rsiOverbought
[color.green, 'bullish\noverbought', 'over overbought zone']
else if rsiValue > 60 and rsiValue < rsiOverbought
[color.green, 'bullish', 'in bullish zone (rsi > 60)']
else
[color.black, 'neutral', 'in bullish zone (60 > rsi > 50)']
else
if rsiValue < rsiOversold
[color.red, 'bearish\noversold', 'below oversold zone']
else if rsiValue < 40 and rsiValue > rsiOversold
[color.red , 'bearish', 'in bearish zone (rsi < 40)']
else
[color.black, 'neutral', 'in bearish zone (50 > rsi > 40)']
// Stochastic
stochMom = stochK > stochK[1] ? ', stochK rising' : ', stochK falling'
stochStat = stochK > stochOverbought ? '\noverbought' : stochK <
stochOversold ? '\noversold' : ''
// MACD
macdMom = histLine > histLine[1] ? '\nmomentum rising' : '\nmomentum falling'
[macdColor, macdText, macdTip] = if macdLine > signalLine
[color.green, 'bullish', 'macd > signal' + macdMom]
else
[color.red, 'bearish', 'macd > signal' + macdMom]
fgTip = 'Fear and Greed Index ' + str.tostring(feargreed, '#.##') + '%' + '\n\
nReference Sources : ' + '\n-----------------------------------------------' +
'\n 1 - Price Convergence/Divergence, Length (' + str.tostring(slowLength) +
') : ' + str.tostring(pmacd, '#.##') + '%' +
'\n 2 - Rate of Return, Length (' + str.tostring(slowLength) + ') : ' +
str.tostring(ror, '#.##') + '%' +
'\n 3 - Chaikin Money Flow, Length (' + str.tostring(fastLength) + ') : ' +
str.tostring(moneyFlow, '#.##') + '% \n ps: CMF calculated only if volume data
is provided' +
'\n 4 - VIX - Volatility (Fear) Index, Length (' + str.tostring(slowLength) +
') : ' + str.tostring(vix, '#.##') + '%' +
'\n 5 - Safe Haven (Gold) Demand, Length (' + str.tostring(fastLength) + ') :
' + str.tostring(gold, '#.##') + '%' +
'\n\nWarren Buffett�s quote, buy when others are fearful, and sell when others
are greedy'
// Volume
if nzVolume
volTip = 'last volume : ' + str.tostring(nzVolume, format.volume) + '\
naverage volume : ' + str.tostring(volMA, format.volume)
volColor = nzVolume > 1.618 * volMA ? color.green : nzVolume < .618 * volMA
? color.red : color.black
//------------------------------------------------------------------------------
// Market Sentiment Meter
if barstate.isfirst
array.push(c, color.gray)
array.push(c, color.red)
array.push(c, #910000)
array.push(c, color.gray)
array.push(c, color.green)
array.push(c, #006400)
if barstate.islast
for i = 0 to l - 1 by 1
array.push(lns, line.new(t[l + i] + msmHOffset, f + a *
math.sqrt(math.pow(l, 2) - math.pow(i, 2)), t[l + i + 1] + msmHOffset, f + a *
math.sqrt(math.pow(l, 2) - math.pow(i + 1, 2)), xloc.bar_index, extend.none,
array.get(c, math.round((i - 2) / 5)), line.style_solid, 5))
for i = 1 to array.size(lns) - 1 by 1
array.push(lns, line.new(t[i + 1] + msmHOffset, f + a *
math.sqrt(math.pow(l, 2) - math.pow(l - i, 2)), t[i] + msmHOffset, f + a *
math.sqrt(math.pow(l, 2) - math.pow(l - i + 1, 2)), xloc.bar_index, extend.none,
array.get(c, math.round(3 + (l - i - 2) / 5)), line.style_solid, 5))
//------------------------------------------------------------------------------
// Price Range Meter / ATR Range Display
f_atr(_length) =>
ta.atr(_length)
atr = request.security(syminfo.tickerid, htf, f_atr(atrLength))
if barstate.islast
oo = math.round(l * (htf_h - htf_o) / (htf_h - htf_l))
co = math.round(l * (htf_h - close) / (htf_h - htf_l))
if not timeframe.ismonthly
oo1 = math.round(l * (htf_h1 - htf_o1) / (htf_h1 - htf_l1))
co1 = math.round(l * (htf_h1 - htf_c1) / (htf_h1 - htf_l1))