0% found this document useful (0 votes)
458 views

TradingView AddOns

The document provides code for several TradingView Pine Script indicators and studies, including: - An "Auto cc" script that draws pivot lines based on highs and lows over a given period. - A "Daily/Weekly/Monthly WVAP" script that calculates and plots the volume weighted average price on the selected time frame. - An "MS Market Structure" script that analyzes market structure by identifying patterns like higher highs and higher lows over a lookback period.

Uploaded by

gogozd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
458 views

TradingView AddOns

The document provides code for several TradingView Pine Script indicators and studies, including: - An "Auto cc" script that draws pivot lines based on highs and lows over a given period. - A "Daily/Weekly/Monthly WVAP" script that calculates and plots the volume weighted average price on the selected time frame. - An "MS Market Structure" script that analyzes market structure by identifying patterns like higher highs and higher lows over a lookback period.

Uploaded by

gogozd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

TradingView Indicators

CC Sessions

https://de.tradingview.com/script/V12PMSHI-CC-Sessions/

Igor Sessions

https://de.tradingview.com/script/071wAXoA-Igor-Sessions/
pD Levels

https://de.tradingview.com/script/JJOn7xNg-pd-Levels/

CC Value

https://www.tradingview.com/script/AHNKTwcK-Trading-Ideas-Chart-Champions-Value-
Points-of-Interest/
Trading View Pine-Editor Scripts

Auto CC

//@version=4
study("Auto cc", overlay=true)

// pivots threshold
threshold_multiplier = input(title="Deviation", type=input.float,
defval=3, minval=0)
dev_threshold = atr(10) / close * 100 * threshold_multiplier

depth = input(title="Depth", type=input.integer, defval=10, minval=1)


var extendLeft = input(false, "Extend Lines Left")
var extendRight = input(true, "Extend Lines Right")

var extending = extend.none


if extendLeft and extendRight
extending := extend.both
if extendLeft and not extendRight
extending := extend.left
if not extendLeft and extendRight
extending := extend.right

reverse = input(false, "Reverse")


prices = input(true, "Prices")
levels = input(true, "Levels")
levelsFormat = input("Values", "Levels Format", options = ["Values",
"Percent"])
labelsPosition = input("Left", "Labels Position", options = ["Left",
"Right"])

var line lineLast = na


var int iLast = 0
var int iPrev = 0
var float pLast = 0
var isHighLast = false // otherwise the last pivot is a low pivot

pivots(src, length, isHigh) =>


l2 = length * 2
c = nz(src[length])
ok = true
for i = 0 to l2
if isHigh and src[i] > c
ok := false

if not isHigh and src[i] < c


ok := false
if ok
[bar_index[length], c]
else
[int(na), float(na)]
[iH, pH] = pivots(high, depth / 2, true)
[iL, pL] = pivots(low, depth / 2, false)

calc_dev(base_price, price) =>


100 * (price - base_price) / price

pivotFound(dev, isHigh, index, price) =>


if isHighLast == isHigh and not na(lineLast)
// same direction
if isHighLast ? price > pLast : price < pLast
line.set_xy2(lineLast, index, price)
[lineLast, isHighLast]
else
[line(na), bool(na)]
else // reverse the direction (or create the very first line)
if abs(dev) > dev_threshold
// price move is significant
id = line.new(iLast, pLast, index, price, color=color.gray,
width=1, style=line.style_dashed)
[id, isHigh]
else
[line(na), bool(na)]

if not na(iH)
dev = calc_dev(pLast, pH)
[id, isHigh] = pivotFound(dev, true, iH, pH)
if not na(id)
if id != lineLast
line.delete(lineLast)
lineLast := id
isHighLast := isHigh
iPrev := iLast
iLast := iH
pLast := pH
else
if not na(iL)
dev = calc_dev(pLast, pL)
[id, isHigh] = pivotFound(dev, false, iL, pL)
if not na(id)
if id != lineLast
line.delete(lineLast)
lineLast := id
isHighLast := isHigh
iPrev := iLast
iLast := iL
pLast := pL

_draw_line(price, col) =>


var id = line.new(iLast, price, bar_index, price, color=col,
width=1, extend=extending)
if not na(lineLast)
line.set_xy1(id, line.get_x1(lineLast), price)
line.set_xy2(id, line.get_x2(lineLast), price)

_draw_label(price, txt, txtColor) =>


x = labelsPosition == "Left" ? line.get_x1(lineLast) : not
extendRight ? line.get_x2(lineLast) : bar_index
labelStyle = labelsPosition == "Left" ? label.style_label_right :
label.style_label_left
align = labelsPosition == "Left" ? text.align_right :
text.align_left
labelsAlignStrLeft = txt + '\n
\n'
labelsAlignStrRight = ' ' + txt + '\n
\n'
labelsAlignStr = labelsPosition == "Left" ? labelsAlignStrLeft :
labelsAlignStrRight
var id = label.new(x=x, y=price, text=labelsAlignStr,
textcolor=txtColor, style=labelStyle, textalign=align, color=#00000000)
label.set_xy(id, x, price)
label.set_text(id, labelsAlignStr)
label.set_textcolor(id, txtColor)

_wrap(txt) =>
"(" + tostring(txt, "#.##") + ")"

_label_txt(level, price) =>


l = levelsFormat == "Values" ? tostring(level) : tostring(level *
100) + "%"
(levels ? l : "") + (prices ? _wrap(price) : "")

_crossing_level(sr, r) =>
(r > sr and r < sr[1]) or (r < sr and r > sr[1])

startPrice = reverse ? line.get_y1(lineLast) : pLast


endPrice = reverse ? pLast : line.get_y1(lineLast)

iHL = startPrice > endPrice


diff = (iHL ? -1 : 1) * abs(startPrice - endPrice)

level_0 = input(true, "0")


color_0 = input(#787b86, "0 Level Color")
float m = 0
r = startPrice + diff * m
if level_0
_draw_line(r, color_0)
_draw_label(r, _label_txt(m, r), color_0)
alertcondition(_crossing_level(close, r), "Autofib 0 crossing!",
"Autofib: {{ticker}} crossing level 0.")

level_0618 = input(true, "0.618")


color_0618 = input(#009688, "0.618 Level Color")
m := 0.618
r := startPrice + diff * m
if level_0618
_draw_line(r, color_0618)
_draw_label(r, _label_txt(m, r), color_0618)
alertcondition(_crossing_level(close, r), "Autofib 0.618 crossing!",
"Autofib: {{ticker}} crossing level 0.618.")

level_066 = input(true, "0.66")


color_066 = input(#009688, "0.66 Level Color")
m := 0.66
r := startPrice + diff * m
if level_066
_draw_line(r, color_066)
_draw_label(r, _label_txt(m, r), color_066)
alertcondition(_crossing_level(close, r), "Autofib 0.66 crossing!",
"Autofib: {{ticker}} crossing level 0.66.")

level_1 = input(true, "1")


color_1 = input(#787b86, "1 Level Color")
m := 1
r := startPrice + diff * m
if level_1
_draw_line(r, color_1)
_draw_label(r, _label_txt(m, r), color_1)
alertcondition(_crossing_level(close, r), "Autofib 1 crossing!",
"Autofib: {{ticker}} crossing level 1.")

level_1618 = input(true, "1.618")


color_1618 = input(#2196f3, "1.618 Level Color")
m := 1.618
r := startPrice + diff * m
if level_1618
_draw_line(r, color_1618)
_draw_label(r, _label_txt(m, r), color_1618)
alertcondition(_crossing_level(close, r), "Autofib 1.618 crossing!",
"Autofib: {{ticker}} crossing level 1.618.")

level_n0618 = input(false, "-0.618")


color_n0618 = input(#009688, "-0.618 Level Color")
m := -0.618
r := startPrice + diff * m
if level_n0618
_draw_line(r, color_n0618)
_draw_label(r, _label_txt(m, r), color_n0618)
alertcondition(_crossing_level(close, r), "Autofib -0.618 crossing!",
"Autofib: {{ticker}} crossing level -0.618.")

Daily / Weekly / Monthly WVAP


(Replace D - W - M for Daily, Weekly, Monthly Script)
// This source code is subject to the terms of the Mozilla Public
License 2.0 at https://mozilla.org/MPL/2.0/
// (c) igor

//@version=2
study("Daily VWAP", overlay=true)
showPrevVWAP = input(true, type=bool, title="Show Previous VWAP close")

start = security(tickerid, "D", time)

newSession = iff(change(start), 1, 0)

vwapsum = iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)


volumesum = iff(newSession, volume, volumesum[1]+volume)
v2sum = iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap = vwapsum/volumesum
dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))

plot(myvwap, title="VWAP", color=aqua, style=cross)

prevwap = iff(newSession, myvwap[1], prevwap[1])


plot(showPrevVWAP ? prevwap : na, style=cross, color=close > prevwap ?
aqua : aqua)
MS Market Structure

//@version=3
study("Market Structure", shorttitle = "MS", overlay =true)
lb = input(4, title="Left Bars", minval = 1)
rb = input(4, title="Right Bars", minval = 1)

showsupres = input(false, title="Show Support/Resistance")


changebarcol = input(false, title="Change Bar Color")
mb = lb + rb + 1

ph = iff(not na(high[mb]), iff(highestbars(high, mb) == -lb, high[lb],


na), na) // Pivot High
pl = iff(not na(low[mb]), iff(lowestbars(low, mb) == -lb, low[lb], na),
na) // Pivot Low

hl = na
hl := iff(ph, 1, iff(pl, -1, na)) // Trend direction
zz = na
zz := iff(ph, ph, iff(pl, pl, na)) // similar to zigzag but may have
multiple highs/lows
zz :=iff(pl and hl == -1 and valuewhen(hl, hl, 1) == -1 and pl >
valuewhen(zz, zz, 1), na, zz)
zz :=iff(ph and hl == 1 and valuewhen(hl, hl, 1) == 1 and ph <
valuewhen(zz, zz, 1), na, zz)

hl := iff(hl==-1 and valuewhen(hl, hl, 1)==1 and zz > valuewhen(zz, zz,


1), na, hl)
hl := iff(hl==1 and valuewhen(hl, hl, 1)==-1 and zz < valuewhen(zz, zz,
1), na, hl)
zz := iff(na(hl), na, zz)

findprevious()=> // finds previous three points (b, c, d, e)


ehl = iff(hl==1, -1, 1)
loc1 = 0.0, loc2 = 0.0, loc3 = 0.0, loc4 = 0.0
xx = 0
for x=1 to 1000
if hl[x]==ehl and not na(zz[x])
loc1 := zz[x]
xx := x + 1
break
ehl := hl
for x=xx to 1000
if hl[x]==ehl and not na(zz[x])
loc2 := zz[x]
xx := x + 1
break
ehl := iff(hl==1, -1, 1)
for x=xx to 1000
if hl[x]==ehl and not na(zz[x])
loc3 := zz[x]
xx := x + 1
break
ehl := hl
for x=xx to 1000
if hl[x]==ehl and not na(zz[x])
loc4 := zz[x]
break
[loc1, loc2, loc3, loc4]

a = na, b = na, c = na, d = na, e = na


if not na(hl)
[loc1, loc2, loc3, loc4] = findprevious()
a := zz
b := loc1
c := loc2
d := loc3
e := loc4

_hh = zz and (a > b and a > c and c > b and c > d)


_ll = zz and (a < b and a < c and c < b and c < d)
_hl = zz and ((a >= c and (b > c and b > d and d > c and d > e)) or (a <
b and a > c and b < d))
_lh = zz and ((a <= c and (b < c and b < d and d < c and d < e)) or (a >
b and a < c and b > d))

plotchar(_hl, text="HL", title="Higher Low", char='', textcolor=lime,


textcolor=black, location=location.belowbar, transp=0, offset = -lb)
plotchar(_hh, text="HH", title="Higher High", char='', textcolor=lime,
textcolor=black, location=location.abovebar, transp=0, offset = -lb)
plotchar(_ll, text="LL", title="Lower Low", char='', textcolor=red,
textcolor=white, location=location.belowbar, transp=0, offset = -lb)
plotchar(_lh, text="LH", title="Lower High", char='', textcolor=red,
textcolor=white, location=location.abovebar, transp=0, offset = -lb)

res = na, sup = na


res := iff(_lh, zz, res[1])
sup := iff(_hl, zz, sup[1])

trend = na
trend := iff(close > res, 1, iff(close < sup, -1, nz(trend[1])))

res := iff((trend == 1 and _hh) or (trend == -1 and _lh), zz, res)


sup := iff((trend == 1 and _hl) or (trend == -1 and _ll), zz, sup)

plot(showsupres ? res : na, title="Resistance", color= na(res) ? na :


red, linewidth=2, style=linebr, offset = -lb)
plot(showsupres ? sup : na, title="Support", color= na(sup) ? na :
green, linewidth=2, style=linebr, offset = -lb)

barcolor(color = iff(changebarcol, iff(trend == 1, green, red), na))

You might also like