name
stringlengths 1
64
| url
stringlengths 44
135
| author
stringlengths 3
30
| author_url
stringlengths 34
61
| likes_count
int64 0
33.2k
| kind
stringclasses 3
values | pine_version
int64 1
5
| license
stringclasses 3
values | source
stringlengths 177
279k
|
---|---|---|---|---|---|---|---|---|
Gap | https://www.tradingview.com/script/AZyykmZ6/ | Arthur-QuantTrader | https://www.tradingview.com/u/Arthur-QuantTrader/ | 172 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ArthurBuyStock
//@version=5
indicator("Gap", overlay = true)
b = request.security(syminfo.tickerid, 'W', bar_index, lookahead = barmerge.lookahead_on)
h = request.security(syminfo.tickerid, 'D', high[1], lookahead = barmerge.lookahead_on)
l = request.security(syminfo.tickerid, 'D', low[1], lookahead = barmerge.lookahead_on)
string nintendo = input.string("True", "Type", options = ["True", "Fix", "Intuition"])
var box[] bricks = array.new_box()
switch nintendo
"True" =>
if b != b[1]
if open > high[1]
array.unshift(bricks, box.new(bar_index - 1, open, bar_index, close[1], na, extend = extend.right, bgcolor = na))
else if open < low[1]
array.unshift(bricks, box.new(bar_index - 1, close[1], bar_index, open, na, extend = extend.right, bgcolor = na))
"Fix" =>
if b != b[1]
if open > h
array.unshift(bricks, box.new(bar_index - 1, open, bar_index, close[1], na, extend = extend.right, bgcolor = na))
else if open < l
array.unshift(bricks, box.new(bar_index - 1, close[1], bar_index, open, na, extend = extend.right, bgcolor = na))
"Intuition" =>
if open > high[1]
array.unshift(bricks, box.new(bar_index - 1, open, bar_index, high[1], na, extend = extend.right, bgcolor = na))
else if open < low[1]
array.unshift(bricks, box.new(bar_index - 1, low[1], bar_index, open, na, extend = extend.right, bgcolor = na))
if array.size(bricks) > 0
if array.size(bricks) == 1
if high >= box.get_top(array.get(bricks,0)) and low <= box.get_bottom(array.get(bricks,0))
box.delete(array.get(bricks,0))
array.remove(bricks,0)
else
if b == b[1]
if low[1] <= box.get_bottom(array.get(bricks,0)) and high >= box.get_top(array.get(bricks,0)) or high[1] >= box.get_top(array.get(bricks,0)) and low <= box.get_bottom(array.get(bricks,0))
box.delete(array.get(bricks,0))
array.remove(bricks,0)
else
t = 0
for i = 0 to array.size(bricks) - 1
if high >= box.get_top(array.get(bricks,i - t)) and low <= box.get_bottom(array.get(bricks,i - t))
box.delete(array.get(bricks,i - t))
array.remove(bricks,i - t)
t := t + 1
else
if i > 0
if low[1] <= box.get_bottom(array.get(bricks,i - t)) and high >= box.get_top(array.get(bricks,i - t)) or high[1] >= box.get_top(array.get(bricks,i - t)) and low <= box.get_bottom(array.get(bricks,i - t))
box.delete(array.get(bricks,i - t))
array.remove(bricks,i - t)
t := t + 1
if array.size(bricks) > 0
r = 0
g = 0
for i = 0 to array.size(bricks) - 1
if high < box.get_top(array.get(bricks,i)) and low > box.get_bottom(array.get(bricks,i))
if high[1] <= box.get_bottom(array.get(bricks,i))
box.set_bottom(array.get(bricks, i), high)
if low[1] >= box.get_top(array.get(bricks,i))
box.set_top(array.get(bricks, i), low)
else
if box.get_top(array.get(bricks,i)) > low and low > box.get_bottom(array.get(bricks,i))
box.set_top(array.get(bricks, i), low)
if box.get_top(array.get(bricks,i)) > high and high > box.get_bottom(array.get(bricks,i))
box.set_bottom(array.get(bricks, i), high)
if close >= box.get_top(array.get(bricks,i))
box.set_bgcolor(array.get(bricks, i), color.new(#ff595e, 20 + g >= 100 ? 90 : 20 + g))
g := g + 20
else if close <= box.get_bottom(array.get(bricks,i))
box.set_bgcolor(array.get(bricks, i), color.new(#8ac926, 20 + r >= 100 ? 90 : 20 + r))
r := r + 20
|
Money Velocity(GDP/M2) | https://www.tradingview.com/script/tJuCf3BA-Money-Velocity-GDP-M2/ | EsIstTurnt | https://www.tradingview.com/u/EsIstTurnt/ | 30 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EsIstTurnt
//@version=5
indicator("Money Velocity(GDP/M2)")
tf=input.timeframe(defval='1W')
current=request.security(syminfo.ticker,tf,close)
//USA(BLUE)
usgdp =(request.security(input.symbol(defval='USGDP'),tf,close))
usm2 =(request.security(input.symbol(defval='USM2'),tf,close))
usv = ta.ema(usgdp/usm2,4)
plot(usv,color=#3244f0,title='USA')
//CANADA(RED)
cagdp =(request.security(input.symbol(defval='CAGDP'),tf,close))
cam2 =(request.security(input.symbol(defval='CAM2'),tf,close))
cav = ta.ema(cagdp/cam2,4)
plot(cav,color=#ff0000,title='CANADA')
//EUROPE(GREEN)
eugdp =(request.security(input.symbol(defval='EUGDP'),tf,close))
eum2 =(request.security(input.symbol(defval='EUM2'),tf,close))
euv = ta.ema(eugdp/eum2,4)
plot(euv,color=#27f50c,title='EUROPEON UNION')
//CHINA(YELLOW)
cngdp =(request.security(input.symbol(defval='CNGDP'),tf,close))
cnm2 =(request.security(input.symbol(defval='CNM2'),tf,close))
cnv = ta.ema(cngdp/cnm2,4)
plot(cnv,color=#e3f036,title='CHINA')
//RUSSIA(WHITE)
rugdp =(request.security(input.symbol(defval='RUGDP'),tf,close))
rum2 =(request.security(input.symbol(defval='RUM2'),tf,close))
ruv = ta.ema(rugdp/rum2,4)
plot(ruv,color=#ffffff,title='RUSSIA*Disable for better view lmao')
//TURKEY(ORANGE)
trgdp =(request.security(input.symbol(defval='TRGDP'),tf,close))
trm2 =(request.security(input.symbol(defval='TRM2'),tf,close))
trv = ta.ema(trgdp/trm2,4)
plot(trv,color=#f5840c,title='TURKEY')
//AUSTRALIA(PINK)
augdp =(request.security(input.symbol(defval='AUGDP'),tf,close))
aum3 =(request.security(input.symbol(defval='AUM3'),tf,close))
auv = ta.ema(augdp/aum3,4)
plot(auv,color=#d707de,title='AUSTRALIA(M3 substiting M2')
//GREAT BRITAIN(LIGHT BLUE)
gbgdp =(request.security(input.symbol(defval='GBGDP'),tf,close))
gbm2 =(request.security(input.symbol(defval='GBM2'),tf,close))
gbv = ta.ema(gbgdp/gbm2,4)
plot(gbv,color=#07c5de,title='BRITAIN')
//INDIA(BROWN)
ingdp =(request.security(input.symbol(defval='inGDP'),tf,close))
inm2 =(request.security(input.symbol(defval='inM2'),tf,close))
inv = ta.ema(ingdp/inm2,4)
plot(inv,color=#de3404,title='INDIA') |
MTF 24-hour Volume [Anan] | https://www.tradingview.com/script/4r5IDckf-MTF-24-hour-Volume-Anan/ | Mohamed3nan | https://www.tradingview.com/u/Mohamed3nan/ | 93 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mohamed3nan
/////////////////////////////////////////////////
// /\ //
// / \ _ __ __ _ _ __ //
// / /\ \ | '_ \ / _` | | '_ \ //
// / ____ \ | | | | | (_| | | | | | //
// /_/ \_\ |_| |_| \__,_| |_| |_| //
/////////////////////////////////////////////////
//@version=5
indicator("MTF 24-hour Volume [Anan]", "MTF 24H Vol [Anan]", format=format.volume)
// built-in indicator: 24-hour Volume
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
priceTooltip = "If the symbol's volume is expressed in base units, it is multiplied by this value to convert it into a price."
price = input.source(close, "Price Source", tooltip = priceTooltip)
currencyInput = input.string(title = "Target Currency", defval="Default", options=["Default", "USD", "EUR", "CAD", "JPY", "GBP", "HKD", "CNY", "NZD", "RUB"])
currency = currencyInput == "Default" ? "" : currencyInput
volTypeInput = input.string("SMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
volLengthInput = input.int(14, title="MA Length", group="MA Settings")
msIn24h = 24 * 60 * 60 * 1000
maxBufferSize = switch
timeframe.isminutes or timeframe.isseconds => 24 * 60
timeframe.isdaily => 24 * 60 / 5
=> 24
cumVolTF = switch
timeframe.isminutes or timeframe.isseconds => "1"
timeframe.isdaily => "5"
=> "60"
cum24hVol(s) =>
src = s
if bar_index == 0
// Creating a buffer of 'maxBufferSize+1' for 'src' and 'time' to avoid the 'max_bars_back' error
src := src[maxBufferSize+1] * time[maxBufferSize+1] * 0
var cumSum = 0.
var int firstBarTimeIndex = na
if na(firstBarTimeIndex) // 24H have not elapsed yet
sum = 0.
for i = 0 to maxBufferSize
if (time - time[i]) >= msIn24h
firstBarTimeIndex := bar_index - i + 1
break
sum += src[i]
cumSum := sum
else
cumSum += nz(src)
for i = firstBarTimeIndex to bar_index
if (time - time[bar_index - i]) < msIn24h
firstBarTimeIndex := i
break
cumSum -= nz(src[bar_index - i])
cumSum
if syminfo.volumetype == "tick" and syminfo.type == "crypto"
runtime.error("Can't calculate volume. There is no delivery of physical goods or securities with CFDs.")
expr = syminfo.volumetype == "quote" ? volume : price * volume
vol24h = request.security(syminfo.tickerid, cumVolTF, cum24hVol(expr), currency = currency)
volMA = ma(vol24h, volLengthInput, volTypeInput)
plot(vol24h, title = "24H Volume",color = price>price[1]?color.new(color.teal,50):color.new(color.red,50), style = plot.style_histogram)
plot(volMA, "Volume MA", color=color.gray)
// built-in indicator: 24-hour Volume
// Anan MTF
group_candle = 'Time Frames'
check_1 = input.bool(true, '', inline='ln1', group=group_candle)
mtf_1 = input.timeframe(title='', defval='', inline='ln1', group=group_candle)
check_2 = input.bool(true, '', inline='ln1', group=group_candle)
mtf_2 = input.timeframe(title='', defval='60', inline='ln1', group=group_candle)
check_3 = input.bool(true, '', inline='ln2', group=group_candle)
mtf_3 = input.timeframe(title='', defval='240', inline='ln2', group=group_candle)
check_4 = input.bool(true, '', inline='ln2', group=group_candle)
mtf_4 = input.timeframe(title='', defval='1D', inline='ln2', group=group_candle)
group_stat = 'Options'
show_1 = input.bool(true, 'Volume Change by currency', inline='#1', group=group_stat)
show_2 = input.bool(true, 'Volume Change %', inline='#2', group=group_stat)
show_3 = input.bool(true, 'Volume MA Change %', inline='#3', group=group_stat)
group_pos = 'Table Position & Size & Colors'
string i_tableYpos = input.string('top', '↕', inline='01', group=group_pos, options=['top', 'middle', 'bottom'])
string i_tableXpos = input.string('right', '↔', inline='01', group=group_pos, options=['left', 'center', 'right'], tooltip='Position on the chart.')
int i_tableRowHeight = input.int(0, '|', inline='02', group=group_pos, minval=0, maxval=100)
int i_tableColWidth = input.int(0, '—', inline='02', group=group_pos, minval=0, maxval=100, tooltip='0-100. Use 0 to auto-size height and width.')
string i_textSize = input.string('Small', 'Table Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group=group_pos)
string textSize = i_textSize == 'Auto' ? size.auto : i_textSize == 'Tiny' ? size.tiny : i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ? size.normal : i_textSize == 'Large' ? size.large : size.huge
row_col = input.color(color.blue, 'Headers', inline='03', group=group_pos)
col_col = input.color(color.blue, ' ', inline='03', group=group_pos)
poscol = input.color(color.green, 'Bull Color', inline='04', group=group_pos)
neutralcolor = input.color(color.gray, 'Neutral Color', inline='04', group=group_pos)
negcol = input.color(color.red, 'Bear Color', inline='04', group=group_pos)
////////////////////////////////////////////////////////////
cutLastDigit(str) =>
s = str + ';'
r = str.replace_all(s, '1;', '')
if r != s
[r, 1]
else
r := str.replace_all(s, '2;', '')
if r != s
[r, 2]
else
r := str.replace_all(s, '3;', '')
if r != s
[r, 3]
else
r := str.replace_all(s, '4;', '')
if r != s
[r, 4]
else
r := str.replace_all(s, '5;', '')
if r != s
[r, 5]
else
r := str.replace_all(s, '6;', '')
if r != s
[r, 6]
else
r := str.replace_all(s, '7;', '')
if r != s
[r, 7]
else
r := str.replace_all(s, '8;', '')
if r != s
[r, 8]
else
r := str.replace_all(s, '9;', '')
if r != s
[r, 9]
else
r := str.replace_all(s, '0;', '')
if r != s
[r, 0]
strToNumInt(str) =>
integer = 0 // integer part of the number
s_new = str
position = 0.0 // handled position of the number.
sign = 1 // sign of the number. 1.0 is PLUS and -1.0 is MINUS.
for i = 0 to 30 by 1
[s, digit] = cutLastDigit(s_new) // here we'll cut the digits by one from the string till the string is empty.
integer += digit * int(math.pow(10, position)) // it's just a regular digit.
position += 1
if s == ''
break
s_new := s // If we are here, then there are more digits in the string. Let's handle the next one!
s_new
sign * integer // We've exited from the loop. Build the returning value.
res_to_str(res) =>
str = res
if strToNumInt(str) < 60
str += 'm'
str
else if strToNumInt(str) >= 60 and strToNumInt(str) <= 1440
str := str.tostring(strToNumInt(str) / 60) + 'h'
str
else if str == ''
if strToNumInt(timeframe.period) < 60
str := 'Chart:' + timeframe.period + 'm'
str
else if strToNumInt(timeframe.period) >= 60 and strToNumInt(timeframe.period) <= 1440
str := 'Chart:' + str.tostring(strToNumInt(timeframe.period) / 60) + 'h'
str
else
str := 'Chart:' + timeframe.period
str
else
str
str
/////////////////
chg(src) =>
change = ta.change(src)
change
chg_perc(src) =>
change_percentage = ta.roc(src, 1)
change_percentage
calcRatingStatus(value) =>
str.tostring(value, '#.##') + '%'
calcRatingStatusVol(value) =>
str.tostring(value, format.volume)
poscond(value) =>
poscondition = value > 0
poscondition
negcond(value) =>
negcondition = value < 0
negcondition
//////////////////////////////////////////////////////////////////////////
f_addCell(_table, _column, _row, _cellTitle, _textColor, _bgColor) =>
table.cell(_table, _column, _row, _cellTitle, text_color=_textColor, bgcolor=_bgColor, text_size=textSize, width=i_tableColWidth, height=i_tableRowHeight)
var table anan = table.new(i_tableYpos + '_' + i_tableXpos, 5, 4, border_width=3)
if barstate.islast and check_1
f_addCell(anan, 1, 0, res_to_str(mtf_1), col_col, color.new(col_col, 80))
if barstate.islast and check_2
f_addCell(anan, 2, 0, res_to_str(mtf_2), col_col, color.new(col_col, 80))
if barstate.islast and check_3
f_addCell(anan, 3, 0, res_to_str(mtf_3), col_col, color.new(col_col, 80))
if barstate.islast and check_4
f_addCell(anan, 4, 0, res_to_str(mtf_4), col_col, color.new(col_col, 80))
indicator_1_1 = request.security(syminfo.tickerid, mtf_1, chg(vol24h))
indicator_1_2 = request.security(syminfo.tickerid, mtf_2, chg(vol24h))
indicator_1_3 = request.security(syminfo.tickerid, mtf_3, chg(vol24h))
indicator_1_4 = request.security(syminfo.tickerid, mtf_4, chg(vol24h))
if barstate.islast and show_1
f_addCell(anan, 0, 1, 'Vol. Chg '+ "("+syminfo.currency+")", row_col, color.new(row_col, 80))
if show_1 and check_1
f_addCell(anan, 1, 1, calcRatingStatusVol(indicator_1_1), poscond(indicator_1_1) ? poscol : negcond(indicator_1_1) ? negcol : color.gray, color.new(poscond(indicator_1_1) ? poscol : negcond(indicator_1_1) ? negcol : color.gray, 80))
if show_1 and check_2
f_addCell(anan, 2, 1, calcRatingStatusVol(indicator_1_2), poscond(indicator_1_2) ? poscol : negcond(indicator_1_2) ? negcol : color.gray, color.new(poscond(indicator_1_2) ? poscol : negcond(indicator_1_2) ? negcol : color.gray, 80))
if show_1 and check_3
f_addCell(anan, 3, 1, calcRatingStatusVol(indicator_1_3), poscond(indicator_1_3) ? poscol : negcond(indicator_1_3) ? negcol : color.gray, color.new(poscond(indicator_1_3) ? poscol : negcond(indicator_1_3) ? negcol : color.gray, 80))
if show_1 and check_4
f_addCell(anan, 4, 1, calcRatingStatusVol(indicator_1_4), poscond(indicator_1_4) ? poscol : negcond(indicator_1_4) ? negcol : color.gray, color.new(poscond(indicator_1_4) ? poscol : negcond(indicator_1_4) ? negcol : color.gray, 80))
indicator_2_1 = request.security(syminfo.tickerid, mtf_1, chg_perc(vol24h))
indicator_2_2 = request.security(syminfo.tickerid, mtf_2, chg_perc(vol24h))
indicator_2_3 = request.security(syminfo.tickerid, mtf_3, chg_perc(vol24h))
indicator_2_4 = request.security(syminfo.tickerid, mtf_4, chg_perc(vol24h))
if barstate.islast and show_2
f_addCell(anan, 0, 2, 'Vol. Chg (%)', row_col, color.new(row_col, 80))
if show_2 and check_1
f_addCell(anan, 1, 2, calcRatingStatus(indicator_2_1), poscond(indicator_2_1) ? poscol : negcond(indicator_2_1) ? negcol : color.gray, color.new(poscond(indicator_2_1) ? poscol : negcond(indicator_2_1) ? negcol : color.gray, 80))
if show_2 and check_2
f_addCell(anan, 2, 2, calcRatingStatus(indicator_2_2), poscond(indicator_2_2) ? poscol : negcond(indicator_2_2) ? negcol : color.gray, color.new(poscond(indicator_2_2) ? poscol : negcond(indicator_2_2) ? negcol : color.gray, 80))
if show_2 and check_3
f_addCell(anan, 3, 2, calcRatingStatus(indicator_2_3), poscond(indicator_2_3) ? poscol : negcond(indicator_2_3) ? negcol : color.gray, color.new(poscond(indicator_2_3) ? poscol : negcond(indicator_2_3) ? negcol : color.gray, 80))
if show_2 and check_4
f_addCell(anan, 4, 2, calcRatingStatus(indicator_2_4), poscond(indicator_2_4) ? poscol : negcond(indicator_2_4) ? negcol : color.gray, color.new(poscond(indicator_2_4) ? poscol : negcond(indicator_2_4) ? negcol : color.gray, 80))
indicator_3_1 = request.security(syminfo.tickerid, mtf_1, chg_perc(ma(vol24h, volLengthInput, volTypeInput)))
indicator_3_2 = request.security(syminfo.tickerid, mtf_2, chg_perc(ma(vol24h, volLengthInput, volTypeInput)))
indicator_3_3 = request.security(syminfo.tickerid, mtf_3, chg_perc(ma(vol24h, volLengthInput, volTypeInput)))
indicator_3_4 = request.security(syminfo.tickerid, mtf_4, chg_perc(ma(vol24h, volLengthInput, volTypeInput)))
if barstate.islast and show_3
f_addCell(anan, 0, 3, "Vol."+ volTypeInput + "(" + str.tostring(volLengthInput)+ ")Chg (%)", row_col, color.new(row_col, 80))
if show_3 and check_1
f_addCell(anan, 1, 3, calcRatingStatus(indicator_3_1), poscond(indicator_3_1) ? poscol : negcond(indicator_3_1) ? negcol : color.gray, color.new(poscond(indicator_3_1) ? poscol : negcond(indicator_3_1) ? negcol : color.gray, 80))
if show_3 and check_2
f_addCell(anan, 2, 3, calcRatingStatus(indicator_3_2), poscond(indicator_3_2) ? poscol : negcond(indicator_3_2) ? negcol : color.gray, color.new(poscond(indicator_3_2) ? poscol : negcond(indicator_3_2) ? negcol : color.gray, 80))
if show_3 and check_3
f_addCell(anan, 3, 3, calcRatingStatus(indicator_3_3), poscond(indicator_3_3) ? poscol : negcond(indicator_3_3) ? negcol : color.gray, color.new(poscond(indicator_3_3) ? poscol : negcond(indicator_3_3) ? negcol : color.gray, 80))
if show_3 and check_4
f_addCell(anan, 4, 3, calcRatingStatus(indicator_3_4), poscond(indicator_3_4) ? poscol : negcond(indicator_3_4) ? negcol : color.gray, color.new(poscond(indicator_3_4) ? poscol : negcond(indicator_3_4) ? negcol : color.gray, 80))
|
DadBod's BB with Squeeze | https://www.tradingview.com/script/ZUVMPTjQ-DadBod-s-BB-with-Squeeze/ | future_dadbod | https://www.tradingview.com/u/future_dadbod/ | 33 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © future_dadbod
//@version=5
indicator(shorttitle="BB", title="DadBod's BB", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
comp_len = input.int(125, "BBW Squeeze Look Back Period")
offset = input.int(0, "Offset", minval = -500, maxval = 500)
basis = ta.sma(src, length)
// Inner BB Bands
mult_A = input.float(2.0, minval=0.001, maxval=50, title="StdDev_A")
dev_A = mult_A * ta.stdev(src, length)
upper_A = basis + dev_A
lower_A = basis - dev_A
// Outter BB Bands
mult_B = input.float(3.0, minval=0.001, maxval=50, title = "StdDev_B")
dev_B = mult_B * ta.stdev(src, length)
upper_B = basis + dev_B
lower_B = basis - dev_B
// BB Squeeze
bb_width(basis, upper, lower) =>
(upper-lower)/basis
bbw_A = bb_width(basis, upper_A, lower_A)
std_sqz = bbw_A == ta.lowest(bbw_A, comp_len)
// bbw_B = bb_width(basis, upper_B, lower_B)
// dev_sqz = bbw_B == ta.lowest(bbw_B, comp_len)
// BB Plots
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper_A, "A-Upper", color=#2962FF, offset = offset)
p2 = plot(lower_A, "A-Lower", color=#2962FF, offset = offset)
fill(p1, p2, title = "A-Background", color=color.rgb(33, 150, 243, 95))
p3 = plot(upper_B, "B-Upper", color=#2962FF, offset = offset)
p4 = plot(lower_B, "B-Lower", color=#2962FF, offset = offset)
fill(p3, p4, title = "B-Background", color=color.rgb(150, 150, 150, 125))
// Squeeze Plot and Alerts
barcolor(std_sqz ? color.yellow : na)
bgcolor(std_sqz ? color.new(color.fuchsia,75) : na)
plotshape(std_sqz, style=shape.arrowup, location=location.belowbar, color=color.aqua)
plotshape(std_sqz, style=shape.arrowdown, location=location.abovebar, color=color.aqua)
alertcondition(std_sqz, "BB Squeeze", "BB Squeeze")
// alertcondition(dev_sqz, "Developing BB Squeeze", "Developing BB Squeeze")
|
RSI vs BITFINEX BTC Longs/Shorts Margin Ratio Percentage Rank | https://www.tradingview.com/script/s0HgspGY-RSI-vs-BITFINEX-BTC-Longs-Shorts-Margin-Ratio-Percentage-Rank/ | EltAlt | https://www.tradingview.com/u/EltAlt/ | 65 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EltAlt
//@version=5
// -------------------------------------------------------------------------------------------------------------------
//
// Authors: @EltAlt
// Revision: v1.03
// Date: 16-June-2022
//
// Description
// ===================================================================================================================
//
// This indicator should be used on a BTC chart. By default it plots the RSI of the current token with a color based
// on percentage rank the RSI of BITFINEX:BTCUSDLONGS divided by BITFINEX:BTCUSDSHORTS, with a plot of the moving
// average of the RSI. In the indicator options you can select to total any of of the availble BITFINEX LONG and SHORT
// tokens.
//
// The available ratio options are:
// • BITFINEX:BTCUSDLONGS : BITFINEX:BTCUSDSHORTS
// • BITFINEX:BTCUSTLONGS : BITFINEX:BTCUSTSHORTS
// • BITFINEX:BTCEURLONGS : BITFINEX:BTCEURSHORTS
// • BITFINEX:BTCEUTLONGS : BITFINEX:BTCEUTSHORTS
// • BITFINEX:BTCJPYLONGS : BITFINEX:BTCJPYSHORTS
// • BITFINEX:BTCGBPLONGS : BITFINEX:BTCGBPSHORTS
//
// The three plot options are:
// • Colored RSI - RSI plotted with colors based on the Longs/Shorts ratio
// • Background Color - White RSI plot with Longs/Shorts ratio as background color
// • RSI + Ratio - White RSI with Longs/Shorts ratio plotted in color
//
// By default it also plots a short term moving average and it can also plot the raw ratio rather than the percentage
// rank if selected.
//
// Alerts can be triggered and or shown on the chart when the Ratio is Above / Below specified values, with the
// option to filter by the RSI being beyond the displayed upper and lower limits and or the RSI above / below its
// moving average.
//
// ===================================================================================================================
//
// I would gladly accept any suggestions to improve the script.
// If you encounter any problems please share them with me.
//
// Changlog
// ===================================================================================================================
//
// 1.00 • First public release
// 1.01 • Added transparency options for above / below MA
// 1.02 • Added options so that all of the BITFINEX:BTCxxxLONGS and BITFINEX:BTCxxxSHORTS pairs can be selected
// • Added RBlG spectrum, I like Red Black Green spectrum as a background color
// • Moved to a drop down list for plot style
// 1.03 • Aligned with 'RSI vs Longs/Shorts Margin Ratio Percentage Rank' v1.01
// • Got rid of the average, not needed
// • Added alerts
// • Moved request.security to a function
//
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//
//
// ============ 'RSI vs BITFINEX BTC Longs/Shorts Margin Ratio'
indicator('RSI vs BITFINEX BTC Longs/Shorts Margin Ratio',
shorttitle='RSI vs Longs/Shorts',
overlay = false,
timeframe='',
timeframe_gaps=true)
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Inputs
rsioption = 'Colored RSI'
bkgoption = 'Background Color'
ratoption = 'RSI + Ratio'
typetip = 'The three plot options are:\nColored RSI - RSI plotted with colors based on the Longs/Shorts ratio\nBackground Color - White RSI plot with Longs/Shorts ratio as background color\nRSI + Ratio - White RSI with Longs/Shorts ratio plotted in color'
usd = input.bool (true, 'USD', group = 'BITFINEX Source symbols: BTCxxxLONGS and BTCxxxSHORTS', inline = '1', tooltip = 'The more you select the slower the indicator will become.')
ust = input.bool (false, 'UST', group = "BITFINEX Source symbols: BTCxxxLONGS and BTCxxxSHORTS", inline = '1')
eur = input.bool (false, 'EUR', group = 'BITFINEX Source symbols: BTCxxxLONGS and BTCxxxSHORTS', inline = '1')
eut = input.bool (false, 'EUT', group = 'BITFINEX Source symbols: BTCxxxLONGS and BTCxxxSHORTS', inline = '1')
jpy = input.bool (false, 'JPY', group = 'BITFINEX Source symbols: BTCxxxLONGS and BTCxxxSHORTS', inline = '1')
gbp = input.bool (false, 'GBP', group = 'BITFINEX Source symbols: BTCxxxLONGS and BTCxxxSHORTS', inline = '1')
plottype = input.string (rsioption , 'Plot Style', options=[rsioption, bkgoption, ratoption], tooltip = typetip)
plotbktab = input.int (defval = 60, maxval=100, minval=0, title = 'Transparency Above MA', inline='0')
plotbktbe = input.int (defval = 75, maxval=100, minval=0, title = 'Below MA', inline='0')
usepctrank = input.bool (true, 'Use the percentrank of the ratio?', inline='1')
pctlbk = input.int (500, title=' Lookback', inline='1')
plotrange = input.string ('RGB Spectrum', 'Color Type', options=['RGB Spectrum', 'RBlG Spectrum', 'RB Spectrum', 'RG Spectrum', 'Solid Color'], inline='2')
plotcolor = input.color (#FFFF00, ' Solid Color', inline='2')
plothilow = input.bool (true, 'Plot High/Low Lines', inline='2')
length = input (14, 'Length', inline='1', group='RSI Settings')
rsiupper = input (70, 'Upper', inline='1', group='RSI Settings')
rsilower = input (30, 'Lower', inline='1', group='RSI Settings')
plotma = input.bool (true, 'Plot RSI MA', inline='1', group='RSI Moving Average Settings')
malength = input.int (5, 'Length', inline='1', group='RSI Moving Average Settings')
matype = input.string ('EMA', 'Type', options=['SMA', 'EMA', 'VWMA'], inline='1', group='RSI Moving Average Settings')
alerts = input.bool (true, 'Plot Visable Alerts', inline='1', group='Alerts')
a_rsibands = input.bool (true, 'RSI Beyond Bands', inline='2', group='Alerts')
a_rsima = input.bool (true, 'RSI MA Filter', inline='2', group='Alerts')
a_ratiobelow = input.int (5, 'Ratio Below', inline='3', group='Alerts')
a_ratioabove = input.int (95, 'Ratio Above', inline='3', group='Alerts')
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Functions
f_color (_type, _solidcolor, _percent) =>
_color = switch _type
'RGB Spectrum' => _percent >= 50 ? color.from_gradient(_percent, 50, 100, #0AFF00, #FF2900): color.from_gradient(_percent, 0, 49, #0000FF, #0AFF00)
'RBlG Spectrum' => _percent >= 50 ? color.from_gradient(_percent, 50, 100, #000000, #FF2900): color.from_gradient(_percent, 0, 49, #0AFF00, #000000)
'RB Spectrum' => color.from_gradient(_percent, 0, 100, #0000FF, #FF2900)
'RG Spectrum' => color.from_gradient(_percent, 0, 100, #00FF00, #FF0000)
'Solid Color' => _solidcolor
f_ma (_type, _source, _length) => _type == 'VWMA' ? ta.vwma ( _source, _length ) : _type == 'EMA' ? ta.ema ( _source, _length ) : ta.sma ( _source, _length )
f_btfnx (_currency, _direction) => request.security (ticker.new ('BITFINEX', 'BTC' + _currency + _direction), timeframe.period, close)
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Calculations
longs = 0.0
longs += usd ? f_btfnx ('USD', 'LONGS') : 0
longs += ust ? f_btfnx ('UST', 'LONGS') : 0
longs += eur ? f_btfnx ('EUR', 'LONGS') : 0
longs += eut ? f_btfnx ('EUT', 'LONGS') : 0
longs += jpy ? f_btfnx ('JPY', 'LONGS') : 0
longs += gbp ? f_btfnx ('GBP', 'LONGS') : 0
shorts = 0.0
shorts += usd ? f_btfnx ('USD', 'SHORTS') : 0
shorts += ust ? f_btfnx ('UST', 'SHORTS') : 0
shorts += eur ? f_btfnx ('EUR', 'SHORTS') : 0
shorts += eut ? f_btfnx ('EUT', 'SHORTS') : 0
shorts += jpy ? f_btfnx ('JPY', 'SHORTS') : 0
shorts += gbp ? f_btfnx ('GBP', 'SHORTS') : 0
plotratio = plottype == ratoption
plotbkgrd = plottype == bkgoption
rsilong = ta.rsi (longs, length)
rsishort = ta.rsi (shorts, length)
rsiclose = ta.rsi (close, length)
rsiratio = ta.rsi (longs / shorts, length)
rsima = plotma ? f_ma (matype, rsiclose, malength) : na
pctrank = usepctrank ? ta.percentrank (rsiratio, pctlbk) : na
ratioplot = usepctrank ? pctrank : rsiratio
ratio_color = f_color (plotrange, plotcolor, ratioplot)
bottcolor = plotrange == 'RG Spectrum' or plotrange == 'RBlG Spectrum' ? color.green : color.blue
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Alerts
hghalert = (ratioplot > a_ratioabove)
and (a_rsibands ? rsiclose > rsiupper : true)
and (a_rsima ? rsiclose < rsima : true)
lowalert = (ratioplot < a_ratiobelow)
and (a_rsibands ? rsiclose < rsilower : true)
and (a_rsima ? rsiclose > rsima : true)
alertcondition (hghalert, title='RSI vs Longs/Shorts High Alert!', message='High Alert')
alertcondition (lowalert, title='RSI vs Longs/Shorts Low Alert!', message='Low Alert')
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Plots
plotshape (alerts ? hghalert : na, style=shape.triangledown, color=color.red, location=location.top, size=size.tiny, title='High Alert')
plotshape (alerts ? lowalert : na, style=shape.triangleup, color=color.lime, location=location.bottom, size=size.tiny, title='Low Alert')
bgcolor (plotbkgrd ? color.new(ratio_color, rsiclose > rsima ? plotbktab : plotbktbe) : na)
p_bandTop = hline (plothilow ? 100 : na, "100", color.red, hline.style_solid)
p_bandBot = hline (plothilow ? 0 : na, "0", bottcolor, hline.style_solid)
p_bandUpp = hline(rsiupper, "Upper Band", color.new(color.silver,50), hline.style_dashed)
p_bandMid = hline(50, "50", color.new(color.silver,75), hline.style_dashed)
p_bandLow = hline(rsilower, "Lower Band", color.new(color.silver,50), hline.style_dashed)
fill(p_bandUpp, p_bandLow, color.new(color.silver,96), title = "Background")
plot(plotratio or plotbkgrd ? na : rsiclose, 'Ratio Color RSI', color=ratio_color, linewidth=2)
p_ratio = plot(plotratio ? ratioplot : na, 'Long / Short Ratio', color=ratio_color)
p_rsi = plot(plotratio or plotbkgrd ? rsiclose : na, 'RSI', color=color.white, linewidth=2)
fill(p_ratio, p_rsi, color=color.new(ratio_color, rsiclose < rsima ? plotbktbe : plotbktab), fillgaps=true)
plot(plotma ? rsima : na, 'RSI MA', color=color.silver, linewidth=1)
|
Haydens RSI Companion | https://www.tradingview.com/script/pkom5uIa-Haydens-RSI-Companion/ | BarefootJoey | https://www.tradingview.com/u/BarefootJoey/ | 290 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Editor: © BarefootJoey
// Authors: © dgtrd, LonesomeTheBlue, TradeChartist, mmoiwgg, TradingView,
// and a couple of authors that need identification.
//
//@version=5
indicator("Hayden's Advanced Relative Strength Index (RSI) Companion", 'Hayden\s RSI Companion', overlay=true, max_bars_back=1000)
//-------------------------🦶 BarefootJoey Theme------------------------------//
// Gradient Bull/Bear
brightgreen = #00ff0a
green = color.green
darkgreen = #1b5e20
brightred = #ff1100
red = color.red
darkred = #801922
// Other
yellow = #ffe500
fuchsia = #da00ff
blue = #0006ff
aqua = #00ffef
orange = color.orange
gray = color.gray
grayishgreen = #a5d6a7
grayishred = #faa1a4
// Groups
grrsi = '📈 Relative Strength Index 📈'
grmtfma = '⏰ MTF Moving Averages ⏰'
grppl = '🔖 Price Pivot Labels 🔖' // label emoji appears unicode instead of emoji on some devices
grtl = "📐 Trend Lines 📐"
//grsx = "🧰 Stochastic [X] 🧰"
grhts = '🚦 Hayden Trend State 🚦'
grhaco = "🧨 Heiken Ashi Candle Overlay 🧨" // candle emoji appears unicode instead of emoji on some devices
grdv = '🔀 Divergences 🔀'
grfrt = '🧬 Fibonacci Retracements 🧬'
grwm = '✍ Watermark ✍ '
grtk = "🎰 Tickers 🎰"
// Default Variables
pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062
// ------------------------------------- RSI -------------------------------- //
rsisrc = input.source(close, "Source", group=grrsi)
prsilen = input.int(14, "RSI Length", group=grrsi, tooltip="For best results, these RSI settings should match the same settings used in Hayden's Advanced RSI oscillator.\nThis RSI length applies to all RSI functions in this chart indicator.")
//--------------------------------Moving Averages-----------------------------//
// Code Author: © TradingView
resCustom = input.timeframe(title='MTF MA\s Timeframe', defval='W', group=grmtfma)
showgaps = input(false, "Show MTF MA Gaps?", group=grmtfma, tooltip="Check this box for a smooth MTF MA line. The tradeoff is that it lags.")
// Fast MA
fastma = ta.sma(close, 9)
fastcol = fastma>fastma[1] ? green : fastma<fastma[1] ? red : gray
fastcolv = fastma>fastma[1] ? brightgreen : fastma<fastma[1] ? brightred : gray
// MTF Fast MA
fastma2 = request.security(syminfo.tickerid, resCustom, ta.sma(close,9), gaps=showgaps ? barmerge.gaps_on : barmerge.gaps_off)
fastcol2 = fastma2>fastma2[1] ? green : fastma2<fastma2[1] ? red : gray
// Slow 45 WMA/EMA
r45ma = input.string('WMA', title='45 WMA or EMA?', options=['WMA', 'EMA'], group=grmtfma, tooltip='There is some inconsistency in the book due to charts (Appendix C) citing use of a 45 EMA on RSI, and text (page 107 & 108) citing use of a 45 WMA on RSI. Take your pick.')
slowema = ta.ema(close, 45)
slowwma = ta.wma(close, 45)
slowmaout = r45ma == 'WMA' ? slowwma : slowema
slowcol = slowmaout>slowmaout[1] ? green : slowmaout<slowmaout[1] ? red : gray
slowcolv = slowmaout>slowmaout[1] ? brightgreen : slowmaout<slowmaout[1] ? brightred : gray
// MTF Slow 45 WMA/EMA
r45ma2 = input.string('WMA', title='MTF 45 WMA or EMA?', options=['WMA', 'EMA'], group=grmtfma, tooltip='There is some inconsistency in the book due to charts (Appendix C) citing use of a 45 EMA on RSI, and text (page 107 & 108) citing use of a 45 WMA on RSI. Take your pick.')
slowwma2 = request.security(syminfo.tickerid, resCustom, ta.wma(close,45), gaps=showgaps ? barmerge.gaps_on : barmerge.gaps_off)
slowema2 = request.security(syminfo.tickerid, resCustom, ta.ema(close,45), gaps=showgaps ? barmerge.gaps_on : barmerge.gaps_off)
slowmaout2 = r45ma2 == 'WMA' ? slowwma2 : slowema2
slowcol2 = slowmaout2>slowmaout2[1] ? green : slowmaout2<slowmaout2[1] ? red : gray
// River MA
riverlen = input(89, title="89 EMA Length", group=grmtfma, tooltip="Popular: 100, 144, 200, 233")
riverdisp = input.string("_____", title="89 EMA Display", options=["_____","-----","∙∙∙∙∙","None"], group=grmtfma)
riverglow = input.string("Normal", "89 EMA Color", options=["Normal", "Electric"], group=grmtfma,
tooltip="Normal is just a single aqua/orange line. Electric applies a thick & transparent blue/red line over the normal line to give the combination a glowing neon look.")
river = ta.ema(close, riverlen)
rivercol = river>river[1] ? aqua : river<river[1] ? orange : gray
rivercol2 = river>river[1] ? green : river<river[1] ? red : gray
// MTF River MA
riverlen2 = input(200, title="MTF 89 EMA Length", group=grmtfma)
river2 = request.security(syminfo.tickerid, resCustom, ta.ema(close, riverlen2), gaps=showgaps ? barmerge.gaps_on : barmerge.gaps_off)
fastfill = plot(fastma, '9 SMA', color=color.new(fastcol, 10))
slowfill = plot(slowmaout, '45 WMA', color=color.new(slowcol, 10))
fill(fastfill, slowfill, color=color.new(fastma>slowmaout ? green : red, 85))
plot(riverdisp=="_____"?river:na, '89 EMA', color=color.new(rivercol,10), linewidth=1, editable=false)
plot(riverdisp=="_____" and riverglow=="Electric"?river:na, '89 EMA Glow', color=color.new(rivercol2,60), linewidth=3, editable=false)
plotchar(riverdisp=="-----"?river:na, "Dashed 89 EMA", char="–", location=location.absolute, color=color.new(rivercol,10), editable=false)
plotchar(riverdisp=="∙∙∙∙∙"?river:na, "Dotted 89 EMA", char="∙", location=location.absolute, color=color.new(rivercol,10), editable=false)
fastfill2 = plot(fastma2, 'MTF 9 SMA', color=color.new(gray, 10), display=display.none, linewidth=1)
slowfill2 = plot(slowmaout2, 'MTF 45 WMA', color=color.new(gray, 10), display=display.none, linewidth=2)
plot(river2, 'MTF 89 EMA', color=color.new(gray,10), display=display.none, linewidth=3)
//-------------------------------Pivots---------------------------------------//
// Code Author: © mmoiwgg
showperc = input(defval=true, title='Show Price Pivot Labels?', group=grppl, tooltip="Hover over labels for additional info. \nThese labels might repaint up to a length of ZigZag Period or Bars to the Left # of bars. ")
upcolor = input(defval=green, title='Bullish Color', group=grppl)
downcolor = input(defval=red, title='Bearish Color', group=grppl)
// Pivot Lookback
leftbars = input.int(8, minval=1, title='Bars to the left', group=grppl)
rightbars = input.int(8, minval=1, title='Bars to the right', group=grppl)
// Pivot Prices
phigh = ta.pivothigh(high, leftbars, rightbars)
plow = ta.pivotlow(low, leftbars, rightbars)
//Pivot %
//Inputs
zigperiod = input(defval=13, title='ZigZag Period', group=grppl, tooltip="The higher the number, the fewer the labels")
pppsize = input.string(size.small, title="Price & Percent Change Pivots Label Size", options=[size.normal, size.small, size.tiny], group=grppl)
percentdecimals = input.int(defval=2, title='% Decimals', minval=0, maxval=10, group=grppl, tooltip="This % Decimals value also applies to the Ticker")
pricedecimals = input.int(defval=2, title='Price Decimals', minval=0, maxval=10, group=grppl, tooltip="This Price Decimals value also applies to the Ticker")
showline = false
zigstyle = input.string(defval='-----', title='Zig Zag Line Style', options=['.....', '-----'], group=grppl)
zigwidth = 1
elen = 5
esrc = close
out = ta.ema(esrc, elen)
prsi = ta.rsi(rsisrc,prsilen)
rsi = ta.rsi(rsisrc,prsilen)
//Float
float highs = ta.highestbars(close, zigperiod) == 0 ? close : na
float lows = ta.lowestbars(close, zigperiod) == 0 ? close : na
//Variables
var dir1 = 0
iff_1 = lows and na(highs) ? -1 : dir1
dir1 := highs and na(lows) ? 1 : iff_1
var max_array_size = 10
var ziggyzags = array.new_float(0)
add_to_zigzag(pointer, value, bindex) =>
array.unshift(pointer, bindex)
array.unshift(pointer, value)
if array.size(pointer) > max_array_size
array.pop(pointer)
array.pop(pointer)
update_zigzag(pointer, value, bindex, dir) =>
if array.size(pointer) == 0
add_to_zigzag(pointer, value, bindex)
else
if dir == 1 and value > array.get(pointer, 0) or dir == -1 and value < array.get(pointer, 0)
array.set(pointer, 0, value)
array.set(pointer, 1, bindex)
0.
// Number of Decimals for Labels
truncatepercent(number, percentdecimals) =>
factor = math.pow(10, percentdecimals)
int(number * factor) / factor
percenttruncate(number, percentdecimals) =>
factor = math.pow(10, percentdecimals)
int(number * factor) / factor
truncateprice(number, pricedecimals) =>
factor = math.pow(10, pricedecimals)
int(number * factor) / factor
percent(n1, n2) =>
((n1 - n2) / n2) * 100
dir1changed = ta.change(dir1)
if highs or lows
if dir1changed
add_to_zigzag(ziggyzags, dir1 == 1 ? highs : lows, bar_index)
else
update_zigzag(ziggyzags, dir1 == 1 ? highs : lows, bar_index, dir1)
// Retrace Targets: (A-C)+B script, see book page 75: "We can also calculate the upside target by obtaining the difference between points "B" and "Ref'
rtt = (ta.valuewhen(highs or lows,close,2) - ta.valuewhen(highs or lows,close,0)) + ta.valuewhen(highs or lows,close,1)
// Stop Loss: Calculated as the high for the leftbars variable ('Bars to the left' setting)
lsl = ta.lowest(low,leftbars)
ssl = ta.highest(high,leftbars)
if array.size(ziggyzags) >= 6
var line zzline1 = na
var label zzlabel1 = na
float val = array.get(ziggyzags, 0)
int point = math.round(array.get(ziggyzags, 1))
if ta.change(val) or ta.change(point)
float val1 = array.get(ziggyzags, 2)
int point1 = math.round(array.get(ziggyzags, 3))
plabel = "∆y " + str.tostring(percenttruncate(val-val1,percentdecimals))
+ ", " + str.tostring(percenttruncate(percent(val, val1),percentdecimals)) + ' %' // ∴ instead of ,
// Change in X
+ "\n⏱ ∆x " + str.tostring(point - point1) + " bars"
// RSI
+ "\n📍 RSI " + str.tostring(percenttruncate(prsi,percentdecimals))
// Targets
+ "\n🎯 " + str.tostring(rtt) + ", " +str.tostring(percenttruncate(percent(rtt, ta.valuewhen(highs or lows,close,0)),percentdecimals)) + " %"
// Stop
+ "\n🛑 " + str.tostring(highs?ssl:lsl) + ", " +str.tostring(percenttruncate(percent(highs?ssl:lsl, ta.valuewhen(highs or lows,close,0)),percentdecimals)) + " %"
if ta.change(val1) == 0 and ta.change(point1) == 0
line.delete(zzline1)
label.delete(zzlabel1)
if showline
zzline1 := line.new(x1=point, x2=point1, y1=val, y2=val1, color=dir1 == 1 ? upcolor : downcolor, width=zigwidth, style=zigstyle == '-----' ? line.style_dashed : line.style_dotted)
zzline1
labelcol = dir1 == 1 ? array.get(ziggyzags, 0) > out ? upcolor : downcolor : array.get(ziggyzags, 0) < out ? downcolor : upcolor
if showperc
zzlabel1 := label.new(x=point, y=val, text=str.tostring(truncateprice(close,pricedecimals)), size=pppsize, color=color.new(labelcol, 100), textcolor=dir1 == 1 ? downcolor : upcolor, style=dir1 == 1 ? label.style_label_down : label.style_label_up, tooltip=plabel)
zzlabel1
//-------------------------Heiken Ashi Candles--------------------------------//
// Code Author: © ?
// Optional Mathmatical Calcualtion to avoid the security function
hkClose = (open + high + low + close) / 4
hkOpen = float(na)
hkOpen := na(hkOpen[1]) ? (open + close) / 2 : (nz(hkOpen[1]) + nz(hkClose[1])) / 2
hkHigh = math.max(high, math.max(hkOpen, hkClose))
hkLow = math.min(low, math.min(hkOpen, hkClose))
candletype = input.string ("None",
"Candle Type",
options = ["Hollow", "Bars", "Candles", "None"],
group = grhaco,
tooltip = "User will have to 'Mute' the main series bar using the 👁 symbol when hovering over ticker id. The Complete RSI book pg 25: 'Build a chart using Japanese Candlesticks in whatever timeframe you prefer, print 30 pages of charts, identify the tops and bottoms, and begin looking for candlestick patterns.'")
BodyBull = input.color (brightgreen, "Body", inline="a", group=grhaco)
BodyBear = input.color (brightred, "Body", inline="a", group=grhaco)
BorderBull = input.color (color.new(brightgreen,100), "Border", inline="b", group=grhaco)
BorderBear = input.color (color.new(brightred,100), "Border", inline="b", group=grhaco)
WickBull = input.color (brightgreen, "Wick", inline="c", group=grhaco)
WickBear = input.color (brightred, "Wick", inline="c", group=grhaco)
hollow = candletype == "Hollow"
bars = candletype == "Bars"
candle = candletype == "Candles"
plotcandle(
hkOpen, hkHigh, hkLow, hkClose,
"Hollow Candles",
hollow ? hkClose < hkOpen ? BodyBear : na : candle ? hkClose < hkOpen ? BodyBear : BodyBull : na,
hollow or candle ? hkClose < hkOpen ? WickBear : WickBull : na,
bordercolor = hollow or candle ? hkClose < hkOpen ? BorderBear : BorderBull : na,
editable=false)
plotbar(
hkOpen, hkHigh, hkLow, hkClose,
"Bars",
bars ? hkClose < hkOpen ? BodyBear : BodyBull : na,
editable=false)
//-------------------------------Trend Lines----------------------------------//
// Code author: © LonesomeTheBlue
n = bar_index
src=close
showtl = input(false, "Show Trend Lines?", group=grtl)
prd = input.int(defval=8, title='Pivot Point Period', minval=5, maxval=50, group=grtl)
PPnum = input.int(defval=3, title='Number of Pivot Point to check', minval=2, maxval=3, group=grtl)
trendstyle = input.string(defval='.....', title='Trend Line Style', options=['.....', '-----'], group=grtl)
float ph = na
float pl = na
ph := ta.pivothigh(src, prd, prd)
pl := ta.pivotlow(src, prd, prd)
getloc(bar_i) =>
_ret = bar_index + prd - bar_i
_ret
t1pos = ta.valuewhen(ph, bar_index, 0)
t1val = nz(src[getloc(t1pos)])
t2pos = ta.valuewhen(ph, bar_index, 1)
t2val = nz(src[getloc(t2pos)])
t3pos = ta.valuewhen(ph, bar_index, 2)
t3val = nz(src[getloc(t3pos)])
b1pos = ta.valuewhen(pl, bar_index, 0)
b1val = nz(src[getloc(b1pos)])
b2pos = ta.valuewhen(pl, bar_index, 1)
b2val = nz(src[getloc(b2pos)])
b3pos = ta.valuewhen(pl, bar_index, 2)
b3val = nz(src[getloc(b3pos)])
getloval(l1, l2) =>
_ret1 = l1 == 1 ? b1val : l1 == 2 ? b2val : l1 == 3 ? b3val : 0
_ret2 = l2 == 1 ? b1val : l2 == 2 ? b2val : l2 == 3 ? b3val : 0
[_ret1, _ret2]
getlopos(l1, l2) =>
_ret1 = l1 == 1 ? b1pos : l1 == 2 ? b2pos : l1 == 3 ? b3pos : 0
_ret2 = l2 == 1 ? b1pos : l2 == 2 ? b2pos : l2 == 3 ? b3pos : 0
[_ret1, _ret2]
gethival(l1, l2) =>
_ret1 = l1 == 1 ? t1val : l1 == 2 ? t2val : l1 == 3 ? t3val : 0
_ret2 = l2 == 1 ? t1val : l2 == 2 ? t2val : l2 == 3 ? t3val : 0
[_ret1, _ret2]
gethipos(l1, l2) =>
_ret1 = l1 == 1 ? t1pos : l1 == 2 ? t2pos : l1 == 3 ? t3pos : 0
_ret2 = l2 == 1 ? t1pos : l2 == 2 ? t2pos : l2 == 3 ? t3pos : 0
[_ret1, _ret2]
var line l1 = na
var label l1a = na
var line l2 = na
var label l2a = na
var line l3 = na
var label l3a = na
var line t1 = na
var label t1a = na
var line t2 = na
var label t2a = na
var line t3 = na
var label t3a = na
line.delete(l1)
label.delete(l1a[1])
line.delete(l2)
label.delete(l2a[1])
line.delete(l3)
label.delete(l3a[1])
line.delete(t1)
label.delete(t1a[1])
line.delete(t2)
label.delete(t2a[1])
line.delete(t3)
label.delete(t3a[1])
countlinelo = 0
countlinehi = 0
for p1 = 1 to PPnum - 1 by 1
uv1 = 0.0
uv2 = 0.0
up1 = 0
up2 = 0
for p2 = PPnum to p1 + 1 by 1
[val1, val2] = getloval(p1, p2)
[pos1, pos2] = getlopos(p1, p2)
if val1 > val2
diff = (val1 - val2) / (pos1 - pos2)
hline = val2 + diff
lloc = bar_index
lval = src
valid = true
for x = pos2 + 1 - prd to bar_index by 1
if nz(src[getloc(x + prd)]) < hline
valid := false
valid
lloc := x
lval := hline
hline += diff
hline
if valid
uv1 := hline
uv2 := val2
up1 := lloc
up2 := pos2
break
dv1 = 0.0
dv2 = 0.0
dp1 = 0
dp2 = 0
for p2 = PPnum to p1 + 1 by 1
[val1, val2] = gethival(p1, p2)
[pos1, pos2] = gethipos(p1, p2)
if val1 < val2
diff = (val2 - val1) / (pos1 - pos2)
hline = val2 - diff
lloc = bar_index
lval = rsi
valid = true
for x = pos2 + 1 - prd to bar_index by 1
if nz(src[getloc(x + prd)]) > hline
valid := false
break
lloc := x
lval := hline
hline -= diff
hline
if valid
dv1 := hline
dv2 := val2
dp1 := lloc
dp2 := pos2
break
if up1 != 0 and up2 != 0 and showtl
countlinelo += 1
l1 := countlinelo == 1 ? line.new(up2 - prd, uv2, up1, uv1, color=green, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : l1
l2 := countlinelo == 2 ? line.new(up2 - prd, uv2, up1, uv1, color=green, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : l2
l3 := countlinelo == 3 ? line.new(up2 - prd, uv2, up1, uv1, color=green, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : l3
l3
if dp1 != 0 and dp2 != 0 and showtl
countlinehi += 1 // truncateprice(dp1-(dp2-prd),pricedecimals)
t1 := countlinehi == 1 ? line.new(dp2 - prd, dv2, dp1, dv1, color=red, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : t1
t2 := countlinehi == 2 ? line.new(dp2 - prd, dv2, dp1, dv1, color=red, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : t2
t3 := countlinehi == 3 ? line.new(dp2 - prd, dv2, dp1, dv1, color=red, style=trendstyle == '-----' ? line.style_dashed : line.style_dotted) : t3
t3
//------------------------------Fibonacci Retracements------------------------//
// Code Author: © TradeChartist
showfr = input(false, title='Show Fibonacci Retracements?', group=grfrt, tooltip="Hover over labels for additional info.\nPage 41: The level of the retracement is a strong indication of the trend strength.")
FP = input(21, title='Candles to Lookback', group=grfrt)
fibsize=input.string(size.tiny, title="Fibonacci Retracement Label Size", options=[size.normal, size.small, size.tiny], group=grfrt)
Reverse = input(false, title='Reverse Fibonacci Levels?', group=grfrt)
Mid_Color = input(#787b86, title='Lines & 50 Label Color', group=grfrt)
CurrentFib = input(false, 'Show Fib Level of Current Price', group=grfrt)
Current_Color = input(yellow, title='Current Fibonacci Level Label Color', group=grfrt)
LineStyle = input.string('-----', options=['.....', '-----'], title='Line Style', group=grfrt)
LineWidth = 1 // input.int(1, minval=1, maxval=3, title='Line Width', group=grfrt)
fiblinetransp = input.int(50, minval=1, maxval=100, title='Line Transparency', group=grfrt)
currentfiboffset = input.int(4, 'Current Fibonacci Level Horizontal Offset', group=grfrt, minval=-50, maxval=10)
Ext = false
FPeriod = FP
Fhigh = ta.highest(FPeriod)
Flow = ta.lowest(FPeriod)
FH = ta.highestbars(high, FPeriod)
FL = ta.lowestbars(low, FPeriod)
revfibs = not Reverse ? FL > FH : FL < FH
Fib_x(n) =>
revfibs ? (Fhigh - Flow) * n + Flow : Fhigh - (Fhigh - Flow) * n
Current = revfibs ? (close - Flow) / (Fhigh - Flow) : (Fhigh - close) / (Fhigh - Flow)
var label Current_Fib_Label = na
label.delete(Current_Fib_Label)
if CurrentFib and barstate.islast and showfr
Current_Fib_Label := label.new(bar_index + currentfiboffset, close, str.tostring(truncateprice(Current, pricedecimals)),
textcolor=Current_Color, color=color.new(#000000, 100), style=label.style_label_left, yloc=yloc.price,
size=fibsize, tooltip=str.tostring(truncateprice(close, pricedecimals)))
Current_Fib_Label
EXTEND = Ext ? extend.left : extend.none
STYLE = LineStyle == '.....' ? line.style_dotted : line.style_dashed
WIDTH = LineWidth
BB = FL < FH ? bar_index[-FL] : bar_index[-FH]
Fib_line(x) =>
var line ln = na
line.delete(ln)
if showfr
ln := line.new(BB, x, bar_index, x, color=color.new(Mid_Color,fiblinetransp), extend=EXTEND, style=STYLE, width=WIDTH)
ln
Fib0 = Fib_line(Fib_x(0))
Fib146 = Fib_line(Fib_x(0.146))
Fib236 = Fib_line(Fib_x(0.236))
Fib382 = Fib_line(Fib_x(0.382))
Fib500 = Fib_line(Fib_x(0.500))
Fib618 = Fib_line(Fib_x(0.618))
Fib786 = Fib_line(Fib_x(0.763))
Fib886 = Fib_line(Fib_x(0.854))
Fib1000 = Fib_line(Fib_x(1.000))
// Define labels
Fib_label(x, _txt, lcol, tip) =>
var label lbl = na
label.delete(lbl)
if showfr
lbl := label.new(bar_index, x, _txt, textcolor=lcol, color=color.new(#000000,100), style=label.style_label_left, yloc=yloc.price, size=fibsize, tooltip="📍 " + str.tostring(truncateprice(x, pricedecimals)) + tip)
lbl
// Display labels with Hayden targets
LFib0 = Fib_label(Fib_x(0), '0.0', brightgreen, ' = 0 %' + '\n🤑 Strongest Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0)-(Fhigh - Flow)):(Fib_x(0)+(Fhigh - Flow)), pricedecimals)))
LFib146 = Fib_label(Fib_x(0.146), '0.146', brightgreen, ' = 14.6 %' + '\n🥳 Very Strong Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.146)-(Fhigh - Flow)):(Fib_x(0.146)+(Fhigh - Flow)), pricedecimals)))
LFib236 = Fib_label(Fib_x(0.236), '0.236', brightgreen, ' = 23.6 %' + '\n🤩 Strong Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.236)-(Fhigh - Flow)):(Fib_x(0.236)+(Fhigh - Flow)), pricedecimals)))
LFib382 = Fib_label(Fib_x(0.382), '0.382', brightgreen, ' = 38.2 %' + '\n😎 Medium Strong Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.382)-(0.8*(Fhigh - Flow))):(Fib_x(0.382)+(0.8*(Fhigh - Flow))), pricedecimals)))
LFib500 = Fib_label(Fib_x(0.500), '0.5', Mid_Color, ' = 50 %' + '\n😐 Medium Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.5)-(0.8*(Fhigh - Flow))):(Fib_x(0.5)+(0.8*(Fhigh - Flow))), pricedecimals)))
LFib618 = Fib_label(Fib_x(0.618), '0.618', brightred, ' = 61.8 %' + '\n😕Medium Weak Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.618)-(0.8*(Fhigh - Flow))):(Fib_x(0.618)+(0.8*(Fhigh - Flow))), pricedecimals)))
LFib786 = Fib_label(Fib_x(0.763), '0.763', brightred, ' = 76.3 %' + '\n😬 Weak Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.763)-(0.8*(Fhigh - Flow))):(Fib_x(0.763)+(0.8*(Fhigh - Flow))), pricedecimals)))
LFib886 = Fib_label(Fib_x(0.854), '0.854', brightred, ' = 85.4 %' + '\n😨 Very Weak Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(0.854)-(0.8*(Fhigh - Flow))):(Fib_x(0.854)+(0.8*(Fhigh - Flow))), pricedecimals)))
LFib1000 = Fib_label(Fib_x(1.000), '1.0', brightred, ' = 100 %' + '\n😱 Invalidated Trend \n'+'🎯 '+ str.tostring(truncateprice(FL>FH?(Fib_x(1.0)-(0.8*(Fhigh - Flow))):(Fib_x(1.0)+(0.8*(Fhigh - Flow))), pricedecimals)))
// ------------------------- Trend State ------------------------------------ //
// Code Author: © Koalafied_3
showtrend = input(false, title='Show Hayden triple trend state background?',group=grhts,
tooltip = "Check this box if you want to see the Bull, Bear, or Chop trend state background according to Hayden.\nFor best results, these settings should match the settings in Hayden's Advanced RSI oscillator.\n(Page 56) 10 Lies That Traders Believe = The RSI is unable to indicate trend direction, because it's only a momentum indicator.")
ts1 = input.float(defval=67, title="Precise Bullish RSI Crossover 66 to 68", minval=66, maxval=68, step=0.001, group=grhts, tooltip="End of chop. Popular: 66, 66.666, or 67")
ts2 = input.float(defval=33, title="Precise Bearish RSI Crossunder 32 to 34", minval=32, maxval=34, step=0.001, group=grhts, tooltip="End of chop. Popular: 34, 33.333, or 33")
ts1a = input.float(defval=61, title="Precise Bullish RSI Crossover 60 to 62", minval=60, maxval=62, step=0.001, group=grhts, tooltip="End of bearish trend. Popular: 61, 60.618, 60.5, or 60")
ts2a = input.float(defval=39, title="Precise Bearish RSI Crossunder 38 to 40", minval=38, maxval=40, step=0.001, group=grhts, tooltip="End of bullish trend. Popular: 39, 39.5, 39.618, or 40")
// Trend State
var state = 0
if ta.crossover(rsi, ts1)
state := 1
state
if ta.crossunder(rsi, ts2)
state := 2
state
if state == 1 and ta.crossunder(rsi, ts2a)
state := 3
state
if state == 2 and ta.crossover(rsi, ts1a)
state := 3
state
state := state
bgcol=showtrend and state==1?green : showtrend and state==2?red : na
bgcolor(color.new(bgcol,80))
//-------------------------------Watermark------------------------------------//
// Watermark tooltips (hover)
q1 = "Look first / Then leap."
q2 = "TradeStation™ Charting by Omega Research and Epsilon Charting"
q3 = "Made w/ ❤ by © 🦶 BarefootJoey"
// Watermark Displays
str1 = "₸⩒ TradingView"
str2 = "TradeStation™"
str3 = "🦶 BarefootJoey"
// Need to toggle timeframe gaps if there are too many on MTF
showwatermark = input(true, 'Show Watermark?', group=grwm, tooltip="Hover over watermark for additional info.")
wmstring = input.string("TradingView", title="Watermark Display Text", options=["BarefootJoey", "TradeStation", "TradingView", "Custom"], group=grwm)
name = input(defval='Your name', title="Custom Watermark Text", group=grwm, tooltip="Emojis allowed!")
watermarktransp = input.int(30, 'Watermark Transparency', minval=0, maxval=100, group=grwm)
watermarkxoffset = input.int(-10, 'Watermark Horizontal Offset', group=grwm , minval=-50, maxval=5)
watermarklocation = input.string(yloc.belowbar, options=[yloc.belowbar, yloc.abovebar], title='Watermark Location', group=grwm)
wmsize = input.string(size.normal, title="Watermark Size", options=[size.normal, size.small, size.tiny], group=grwm)
whichwm = wmstring == "BarefootJoey" ? str3 :wmstring =="TradeStation"? str2 : wmstring == "TradingView" ? str1 : name
whichtt = wmstring == "TradeStation" ? q2 : wmstring == "TradingView"? q1 : q3
// Watermark Close
wmPrice = ta.valuewhen(bar_index + watermarkxoffset, close, 0)
// Label
if showwatermark
var label watermark = na
watermark := label.new(bar_index + watermarkxoffset, y=wmPrice, yloc=watermarklocation, size=wmsize, text=whichwm, style=label.style_none, textcolor=color.new(gray,watermarktransp),tooltip=whichtt)
label.delete(watermark[1])
// ------------------------ Advanced Data Ticker ---------------------------- //
showticker = input(true, "Show Tickers?", group=grtk)
datatype = input.string('None',
title = 'Ticker 1 Data Source?',
options = ['RSI to Price', "MA Price", 'Trend End', 'Trend State', 'ADX & DI+/-', "Watermark", "Volatility", "None"],
group = grtk)
datatype2 = input.string('ADX & DI+/-',
title = 'Ticker 2 Data Source?',
options = ['RSI to Price', "MA Price", 'Trend End', 'Trend State', 'ADX & DI+/-', "Watermark", "Volatility", "None"],
group = grtk)
// Code Conversion
r45maout = slowmaout
rsma = fastma
rwmacolv = slowcolv
rsmacolv = fastcolv
len_rsi = prsilen
targetsrc = src
price_by_rsi(level) =>
x1 = (len_rsi - 1) * (ta.rma(math.max(nz(targetsrc[1], targetsrc) - targetsrc, 0), len_rsi) * level / (100 - level) - ta.rma(math.max(targetsrc - nz(targetsrc[1], targetsrc), 0), len_rsi))
x1 >= 0 ? targetsrc + x1 : targetsrc + x1 * (100 - level) / level
// RSI to Price Target Inputs
obLevel1 = input.float(80, title='RSI to Price Target 1', minval=1, maxval=99, group=grtk,
tooltip ="Table #8 Fibonacci Bullish RSI Levels: 61.8, 66.67, 76.30, 85.42, 90.98, 94.43\n(Page 56) 10 Lies That Traders Believe = The RSI will generally 'top out' somewhere around the 70 level.")
osLevel1 = input.float(20, title='RSI to Price Target 2', minval=1, maxval=99, group=grtk,
tooltip ="Table #8 Fibonacci Bearish RSI Levels: 38.2, 33.33, 23.61, 14.59, 9.02, 5.57\n(Page 56) 10 Lies That Traders Believe = The RSI will generally 'bottom out' somewhere around the 30 level.")
// Functional Math and RSI Targets
// Code Author: @ LazyBear
ep = 2 * 14 - 1
auc = ta.ema(math.max(src - src[1], 0), ep)
adc = ta.ema(math.max(src[1] - src, 0), ep)
x1 = (14 - 1) * (adc * obLevel1 / (100 - obLevel1) - auc)
longrsitarget = x1 >= 0 ? src + x1 : src + x1 * (100 - obLevel1) / obLevel1
x2 = (14 - 1) * (adc * osLevel1 / (100 - osLevel1) - auc)
shortrsitarget = x2 >= 0 ? src + x2 : src + x2 * (100 - osLevel1) / osLevel1
// Text
tickerstateob = (str.tostring(obLevel1) + " 🎯 = " + str.tostring(truncateprice(longrsitarget,pricedecimals)))
tickerstateos = (str.tostring(osLevel1) + " 🎯 = " + str.tostring(truncateprice(shortrsitarget,pricedecimals)))
// Plots
roblcol = input.color(aqua, title="RSI to Price Target 1 Color", group=grtk)
roslcol = input.color(fuchsia, title="RSI to Price Target 2 Color", group=grtk)
// Shape Plots
plotshape(datatype=="RSI to Price" or datatype2=="RSI to Price" ?price_by_rsi(obLevel1):na, title="User-defined RSI to Price Target 1", location=location.absolute, style=shape.cross, color=color.new(roblcol, 0), show_last=1)
plotshape(datatype=="RSI to Price" or datatype2=="RSI to Price" ?price_by_rsi(osLevel1):na, title="User-defined RSI to Price Target 2", location=location.absolute, style=shape.cross, color=color.new(roslcol, 0), show_last=1)
// MA Price Targets
// Emoji Rating
erating = (slowmaout>slowmaout[1] and slowmaout>slowmaout[1])?" 🚀 ":
(slowmaout<slowmaout[1] and rsma<rsma[1])?" 💀 ":" 🪓 "
// Text
tickerstaterwma = ("45 "+ (r45ma == 'WMA' ? "WMA" : "EMA") + " = " + str.tostring(truncateprice(slowmaout, pricedecimals))) + " " + erating
tickerstatersma = ("9 SMA = " + str.tostring(truncateprice(fastma, pricedecimals)))
// Text Color
rwmatcol2=rwmacolv
rsmatcol2=rsmacolv
// Trend Ends Text
// Fib variables
fr1 = 0
fr3 = 14.59
fr5 = 23.61
fr7 = ts2
fr9 = ts2a
fr11 = 50
fr13 = ts1a
fr16 = ts1
fr18 = 76.3
fr20 = 85.41
fr21 = 100
tickerstateendbull = ("🐮 Bullish above " + str.tostring(truncateprice(price_by_rsi(fr9),pricedecimals)))
tickerstateendbear = ("🐻 Bearish below " + str.tostring(truncateprice(price_by_rsi(fr13),pricedecimals)))
tickerstateendbullchop = ("Bullish above " + str.tostring(truncateprice(price_by_rsi(fr16),pricedecimals)))
tickerstateendbearchop = ("🪓 Bearish below " + str.tostring(truncateprice(price_by_rsi(fr7),pricedecimals)))
// Trend State Text
bulltrend = rsi>r45maout and rsi>rsma and state==1
tickerstatebulltrend = ("📈 Bullish " + (bulltrend?"Trend 🚀":"Chop 🪓"))
beartrend = rsi<r45maout and rsi<rsma and state==2
tickerstatebeartrend = ("📉 Bearish " + (beartrend?"Trend 💀":"Chop 🪓"))
chopbear = state==3 and rsi<r45maout
tickerstatechoptrend = ("🪓 Chop with " + (chopbear?"Bearish 💀":"Bullish 🚀") + " Sentiment")
trendstatedisplay = state==1?tickerstatebulltrend:state==2?tickerstatebeartrend:state==3?tickerstatechoptrend:na
// Trend State Text Color
tstextcol = state==1 and bulltrend ?brightgreen :
state==1 and not bulltrend?green :
state==2 and beartrend ? brightred :
state==2 and not beartrend ? red :
state==3 and chopbear ? red :
state==3 and not chopbear ? green : na
// ADX & DI Data
// Code Author: Currently unknown. Please help identify the author if you know who it is.
[_, _, adx1] = ta.dmi(17, 4)
adxlen = 14
dilen = 14
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adx
adxHigh(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
plus
adxLow(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
minus
sig = adx(dilen, adxlen)
sigHigh = adxHigh(dilen, adxlen)
sigLow = adxLow(dilen, adxlen)
sigTop = sigHigh>sigLow?sigHigh:sigLow
// Text
adxtext = 'ADX ' + str.tostring(truncatepercent(adx1, percentdecimals))
+ (adx1>adx1[1] ? ' & 📈' : ' & 📉')
+ (adx1<25?' 💤':adx1>25 and adx1<50 ?' 💪':adx1>50 and adx1<75 ?' 🔥':adx1>75 and adx1<100 ?' 🚀':'')
ditext = 'DI ' + str.tostring(truncatepercent(sigTop, percentdecimals))
+ (sigTop>sigTop[1] and sigHigh>sigLow? ' & 📈 🐮' : sigTop<sigTop[1] and sigHigh>sigLow ? ' & 📉 🪓': sigTop>sigTop[1] and sigHigh<sigLow ? ' & 📈 🐻' : sigTop<sigTop[1] and sigHigh<sigLow ? ' & 📉 🪓':na)
// Text Color
adxtextcol = color.new(
sigHigh > sigLow and adx1 < 25 ? green:
sigHigh > sigLow and adx1 > 25 ? brightgreen:
sigHigh < sigLow and adx1 > 25 ? brightred:
sigHigh < sigLow and adx1 < 25 ? red:
gray, 0)
ditextcol = color.new(
sigHigh > sigLow and sigTop<sigTop[1] ? green:
sigHigh > sigLow and sigTop>sigTop[1] ? brightgreen:
sigHigh < sigLow and sigTop>sigTop[1] ? brightred:
sigHigh < sigLow and sigTop<sigTop[1] ? red:
gray, 0)
// Volatility
lowvolcol = input.color(color.rgb(250,237,56,1), "Low Volatility Gradient Color", group=grtk)
highvolcol = input.color(color.rgb(255,37,174,1), "High Volatility Gradient Color", group=grtk)
f_volatility() =>
atr = ta.atr(14)
stdAtr = 2*ta.stdev(atr,20)
smaAtr = ta.sma(atr,20)
topAtrDev = smaAtr+stdAtr
bottomAtrDev = smaAtr-stdAtr
calcDev = (atr-bottomAtrDev)/(topAtrDev-bottomAtrDev)
percentVol = (40*calcDev+30)
volatility = f_volatility()
volatilitydir = volatility>volatility[1]?" & 📈":" & 📉"
volemoji = volatility > 0 and volatility < 20 ? "😴" : volatility > 20 and volatility < 40 ? " 😐" : volatility > 40 and volatility < 60 ? " 😬" : volatility > 60 and volatility < 80 ? " 😮" : volatility > 80 and volatility < 100 ? " 😵" : " 🤯"
voltxt = "Volatility = " + str.tostring(truncatepercent(volatility, percentdecimals)) + " %" + volemoji + volatilitydir
volcol = color.from_gradient(volatility,25,75,lowvolcol,highvolcol)
// Dual Ticker Display
// Code Author: © dgtrd
watermark = input("Your name", title="Custom Trader WaterMark Text", group=grtk, tooltip="Emojis allowed!")
WMtxtcol = input(gray, title="WaterMark Text Color", group=grtk)
Ttransp=input(20, title="Ticker Text Transparency", group=grtk)
position = input.string(position.top_center, "Ticker 1 Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left], group=grtk)
size = input.string(size.small, "Ticker 1 Size", [size.tiny, size.small, size.normal, size.large, size.huge], group=grtk)
var table Ticker = na
Ticker := table.new(position, 2, 1)
if barstate.islast and showticker
table.cell(Ticker, 0, 0,
text = datatype=="RSI to Price"?tickerstateob:datatype=="MA Price"?tickerstaterwma:datatype=="Trend End" and state ==1?tickerstateendbull:datatype=="Trend End" and state ==3?tickerstateendbullchop:datatype=="ADX & DI+/-"?adxtext:datatype=="Watermark"?watermark:na, //datatype=="Trend State"?"Trend: ":
text_size = size,
text_color = color.new(datatype=="RSI to Price"?roblcol:datatype=="MA Price"?rwmatcol2:datatype=="Trend End" and (state==3 or state==1)?green:datatype=="ADX & DI+/-"?adxtextcol:gray,Ttransp),
tooltip=datatype=="Watermark"?q3:na)
table.cell(Ticker, 1, 0,
text = datatype=="RSI to Price"?tickerstateos:datatype=="MA Price"?tickerstatersma:datatype=="Trend End" and state ==2?tickerstateendbear:datatype=="Trend End" and state ==3?tickerstateendbearchop:datatype=="ADX & DI+/-"?ditext:datatype=="Trend State"?trendstatedisplay:datatype=="Volatility"?voltxt:na,
text_size = size,
text_color = color.new(datatype=="RSI to Price"?roslcol:datatype=="MA Price"?rsmatcol2:datatype=="Trend End" and (state==3 or state==2)?red:datatype=="ADX & DI+/-"?ditextcol:datatype=="Trend State"?tstextcol:datatype=="Volatility" ? volcol :gray,Ttransp))
position2 = input.string(position.bottom_center, "Ticker 2 Position", [position.top_center, position.top_right, position.middle_right, position.bottom_right, position.bottom_center, position.bottom_left, position.middle_left, position.top_left], group=grtk)
size2 = input.string(size.small, "Ticker 2 Size", [size.tiny, size.small, size.normal, size.large, size.huge], group=grtk)
var table Ticker2 = na
Ticker2 := table.new(position2, 2, 1)
if barstate.islast and showticker
table.cell(Ticker2, 0, 0,
text = datatype2=="RSI to Price"?tickerstateob:datatype2=="MA Price"?tickerstaterwma:datatype2=="Trend End" and state ==1?tickerstateendbull:datatype2=="Trend End" and state ==3?tickerstateendbullchop:datatype2=="ADX & DI+/-"?adxtext:datatype2=="Watermark"?watermark:na, //datatype=="Trend State"?"Trend: ":
text_size = size2,
text_color = color.new(datatype2=="RSI to Price"?roblcol:datatype2=="MA Price"?rwmatcol2:datatype2=="Trend End" and (state==3 or state==1)?green:datatype2=="ADX & DI+/-"?adxtextcol:gray,Ttransp),
tooltip=datatype=="Watermark"?q3:na)
table.cell(Ticker2, 1, 0,
text = datatype2=="RSI to Price"?tickerstateos:datatype2=="MA Price"?tickerstatersma:datatype2=="Trend End" and state ==2?tickerstateendbear:datatype2=="Trend End" and state ==3?tickerstateendbearchop:datatype2=="ADX & DI+/-"?ditext:datatype2=="Trend State"?trendstatedisplay:datatype2=="Volatility"?voltxt:na,
text_size = size2,
text_color = color.new(datatype2=="RSI to Price"?roslcol:datatype2=="MA Price"?rsmatcol2:datatype2=="Trend End" and (state==3 or state==2)?red:datatype2=="ADX & DI+/-"?ditextcol:datatype2=="Trend State"?tstextcol:datatype2=="Volatility" ? volcol :gray,Ttransp))
// EoS. Made w/ ❤ by © 🦶BarefootJoey |
predictive_moving_average | https://www.tradingview.com/script/Gjd2SKJF-predictive-moving-average/ | palitoj_endthen | https://www.tradingview.com/u/palitoj_endthen/ | 117 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © palitoj_endthen
//@version=5
indicator(title = 'John F. Ehlers - Predictive Moving Average', shorttitle = 'predictive_moving_average', overlay = true, timeframe = '', timeframe_gaps = true)
// input
src = input.source(ohlc4, title = 'Source', group = 'Source', tooltip = 'Determines the source of input data, default to ohlc4')
band = input.float(defval = 2, title = '%Band', group = 'Value', minval = 1, maxval = 100, step = 1, tooltip = 'Determines the % of applied band')
bar_color = input.bool(defval= true, title = 'Bar Color', group = 'Options', tooltip = 'Determines whether to apply bar color, base on crossover or crossunder of predict to trigger')
dynamic_band = input.bool(defval = false, title = 'Price Band', group = 'Options', tooltip = 'Determines whether to display price band (price-corridor)')
// predictive moving average
wma1 = 0.00
wma2 = 0.00
predict = 0.00
trigger = 0.00
wma1 := (7*src+6*src[1]+5*src[2]+4*src[3]+3*src[4]+2*src[5]+src[6])/28
wma2 := (7*wma1+6*wma1[1]+5*wma1[2]+4*wma1[3]+3*wma1[4]+2*wma1[5]+wma1[6])/28
predict := (2*wma1)-wma2
trigger := (4*predict+3*predict[1]+2*predict[2]+predict)/10
series_ = predict > trigger ? predict : trigger
upper = series_*(1+(band/100))
lower = series_*(1-(band/100))
// visualize
// color condition
color_con = predict > trigger and predict > predict[1] ? color.green : color.red
color_con_ = predict > trigger and predict > predict[1]
// bar color
barcolor(bar_color ? color_con : na)
// line type
plot(series_, color = color_con, style = plot.style_line, linewidth = 2)
p_up = plot(dynamic_band ? upper : na, color = color.new(color.yellow, 70))
p_low = plot(dynamic_band ? lower : na, color = color.new(color.yellow, 70))
// create alert
alertcondition((not color_con_[1] and color_con_), title = 'Entry', message = 'Buy/Long entry point detected')
alertcondition((color_con_[1] and not color_con_), title = 'Close', message = 'Sell/Short entry point detected')
// // strategy test
// percent_sl = input.float(defval = 3, title = 'Stop Loss', group = 'Value', tooltip = 'Determines the stop-loss percentage')
// long_condition = color_con_
// short_condition = not color_con_
// long_sl = 0.00
// long_sl := long_condition ? series_*(1-percent_sl/100) : nz(long_sl[1])
// if long_condition
// strategy.entry(id = 'long', direction = strategy.long)
// if not long_condition
// strategy.exit(id = 'exit-long', from_entry = 'long', stop = long_sl)
// plot(strategy.position_size > 0 ? long_sl : na, color = color.gray, style = plot.style_linebr) |
BTC SOPR Momentum: Onchain | https://www.tradingview.com/script/U7rQsEOb-BTC-SOPR-Momentum-Onchain/ | cryptoonchain | https://www.tradingview.com/u/cryptoonchain/ | 94 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MJShahsavar
//@version=5
indicator("BTC SOPR Momentum: Onchain")
R = input.symbol("BTC_SOPR", "Symbol")
src = request.security(R, 'D', close)
D = ta.sma(src, 14)
M = ta.rsi(D, 14)
h1=hline (78)
h2= hline (22)
h3= hline (55)
h4= hline (45)
h5=hline (50)
h6=hline (0)
h7=hline (100)
fill (h3, h4, color.black, transp = 60)
fill (h1, h7, color.red, transp = 60)
fill (h2, h6, color.blue, transp = 60)
plot (M, "hashColor" , M >= 80 ? color.blue : M <= 20 ? color.red : color.maroon, linewidth=1)
|
Harmonic Table Combo Point B | https://www.tradingview.com/script/5kA6kNQz-Harmonic-Table-Combo-Point-B/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 33 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
//@version=5
indicator('Harmonic Table Combo Point B', overlay = true)
// 0. Inputs
// 1. Variables, Switches and Arrays
// 2. Custom functions
// 3. Construct
// ————————————————————————————————————————————————————————————————————————————— 0. Inputs {
T0 = 'Small font size recommended for mobile app or multiple layout'
i_s_font = input.string('normal', 'Font size', options = ['tiny', 'small', 'normal', 'large', 'huge'], tooltip = T0)
i_s_Y = input.string('middle', 'Table Position', options = ['top', 'middle', 'bottom'], inline = '0')
i_s_X = input.string('center', '', options = ['left', 'center', 'right'], inline = '0')
i_f_value = input.float( 0.371, 'Value', minval = 0.371, maxval = 0.930, step = 0.001, tooltip = '0.371 <= Value <= 0.930')
i_s_ABC = input.string('All', 'ALT BAT / BAT / CRAB', options = ['All', 'ALT BAT', 'BAT', 'CRAB'], tooltip = 'Value = 0.382') // 'ALT BAT, BAT, CRAB'
i_s_BC = input.string('All', 'BAT / CRAB', options = ['All', 'BAT', 'CRAB'], tooltip = '0.383 <= Value <= 0.500') // 'BAT, CRAB'
i_s_CG = input.string('All', 'CRAB / GARTLEY', options = ['All', 'CRAB', 'GARTLEY'], tooltip = '0.599 <= Value <= 0.618') // 'CRAB', 'GARTLEY'
G2 = 'SPECIAL SITUATION (D = XA)'
T2 = 'Change value D = XA\n if'
i_f_gart = input.float(0.786, 'Gartley', options =[0.786, 0.886], group = G2, tooltip = T2 + 'Gartley was found.\nDefault : 0.786\nSpecial : 0.886')
i_f_crab = input.float(1.618, 'Crab / Deep Crab', options =[1.618, 1.902], group = G2, tooltip = T2 + 'Crab / Deep Crab was found.\nDefault : 1.618\nSpecial : 1.902')
// }
// ————————————————————————————————————————————————————————————————————————————— 1. Variables, Switches and Arrays {
p0 = math.rphi
p1 = math.phi
p2 = math.rphi + 2
p3 = math.rphi + 3
[bc1_gart, bc2_gart, sl_gart] = switch i_f_gart
// Output => bc1_gart, bc2_gart, sl_gart
0.786 => [ 1.130, p1, 1. ]
0.886 => [ p1, p2, 1.13 ]
var TBL = table.new(i_s_Y + '_' + i_s_X, columns = 10, rows = 9, border_width = 1)
title = array.from('INPUT\n(B=XA)', 'POSSIBLE', 'PRIORITY', 'COMPARISON', 'B = XA', 'C = AB', 'D = BC', 'D = XA', 'STOP\nLOSS')
str_ABC = 'ALT BAT, BAT, CRAB'
str_BC = 'BAT, CRAB'
str_CG = 'CRAB, GARTLEY'
// 0, 1, 2, 3, 4, 5, 6, 7
possible_animal = array.from('ALT BAT', str_ABC, str_BC, 'CRAB', str_CG, 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
priority_animal = array.from('ALT BAT', 'ALT BAT', 'BAT', 'CRAB', 'CRAB', 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
selected_animal = array.from('ALT BAT', i_s_ABC, i_s_BC, 'CRAB', i_s_CG, 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
b_min = array.from( .371, .382, .383, .501, .599, .619, .762, .886)
b_max = array.from( .381, .382, .5 , .598, p0, .637, .81 , .93 )
arr_bool = array.new_bool(8)
for _index = 0 to 7
array.set(arr_bool, _index, i_f_value >= array.get(b_min, _index) and i_f_value <= array.get(b_max, _index))
// 0, 1, 2, 3, 4, 5
animal_name = array.from('ALT BAT', 'BAT', 'CRAB', 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
arr_B_XA1 = array.from( .371, .382, .382, .599, .599, .886) // B = XA ==|=> Trade Identification
arr_B_XA2 = array.from( .382, .500, .618, .637, .637, .913) // |
arr_C_AB1 = array.from( .382, .382, .382, .382, .382, .382) // C = AB |
arr_C_AB2 = array.from( .886, .886, .886, .886, .886, .886) // ==|
arr_D_BC1 = array.from( 2. , p1, p2, bc1_gart, 1.618, 2. ) // D = BC ==|=> Trade Execution - PRZ (Potential Reversal Zone)
arr_D_BC2 = array.from( p3, p2, p3, bc2_gart, 2.24 , 3.618) // |
arr_D_XA = array.from( 1.13 , .886, i_f_crab, i_f_gart, 1.27 , i_f_crab) // D = XA ==|
arr_E_SL = array.from( 1.27 , 1.13 , 2. , sl_gart, 1.414, 2. ) // Stop Loss => Trade Management (Page 174)
// }
// ————————————————————————————————————————————————————————————————————————————— 2. Custom functions {
f_str(_id, string _value) => str.tostring(array.get(_id, array.indexof(animal_name, _value)), '0.000')
f_cell(int _column, int _row, string _text, bool _bool = true) =>
table.cell(TBL, _column, _row, _text, bgcolor = color.white, text_halign = _bool ? text.align_left : text.align_center, text_size = i_s_font)
f_set(int _column, int _row, string _text) => table.cell_set_text(TBL, _column, _row, _text)
// }
// ————————————————————————————————————————————————————————————————————————————— 3. Construct {
if barstate.islast
// row titles
for _row = 0 to 8
f_cell(0, _row, array.get(title, _row), false)
// row variables
new = array.get(possible_animal, array.indexof(arr_bool, array.includes(arr_bool, true)))
prior = array.get(priority_animal, array.indexof(arr_bool, array.includes(arr_bool, true)))
select = array.get(selected_animal, array.indexof(arr_bool, array.includes(arr_bool, true)))
split = str.split(new, ', ')
for _column = 0 to array.size(split) - 1
f_cell(_column + 1, 0, str.tostring(i_f_value, '0.000'), false)
f_cell(_column + 1, 1, new)
f_cell(_column + 1, 2, prior)
f_cell(_column + 1, 3, select)
// row ratios
for _index = 0 to array.size(split) - 1
f_cell(_index + 1, 3, array.get(split, _index) + '\n' + f_str( arr_D_XA, array.get(split, _index)) + ' XA') // Pattern index
f_cell(_index + 1, 4, f_str(arr_B_XA1, array.get(split, _index)) + ';\n' + f_str(arr_B_XA2, array.get(split, _index))) // B = XA
f_cell(_index + 1, 5, f_str(arr_C_AB1, array.get(split, _index)) + ';\n' + f_str(arr_C_AB2, array.get(split, _index))) // C = AB
f_cell(_index + 1, 6, f_str(arr_D_BC1, array.get(split, _index)) + ';\n' + f_str(arr_D_BC2, array.get(split, _index))) // D = BC
f_cell(_index + 1, 7, f_str( arr_D_XA, array.get(split, _index))) // D = XA
f_cell(_index + 1, 8, f_str( arr_E_SL, array.get(split, _index))) // E = SL
// Specific combo for ALT BAT / BAT / CRAB
if array.size(split) == 3
if i_s_ABC != 'All'
f_set( 0, 3, 'SELECTED')
if i_s_ABC == 'ALT BAT'
table.clear(TBL, 2, 0, 3, 8)
else if i_s_ABC == 'BAT'
table.clear(TBL, 1, 0, 1, 8)
table.clear(TBL, 3, 0, 3, 8)
else if i_s_ABC == 'CRAB'
table.clear(TBL, 1, 0, 2, 8)
else
for _row = 0 to array.size(split) - 1
table.merge_cells(TBL, 1, _row, array.size(split), _row)
// Combo for
// BAT / CRAB
// CRAB / GARTLEY
if array.size(split) == 2
pos1 = array.get(split, 1)
if i_s_BC != 'All' or i_s_CG != 'All'
f_set( 0, 3, 'SELECTED')
if i_s_BC == 'BAT' or i_s_CG == 'CRAB'
table.clear(TBL, 2, 0, 2, 8)
else if i_s_BC == 'CRAB'or i_s_CG == 'GARTLEY'
table.clear(TBL, 1, 0, 1, 8)
else
for _row = 0 to array.size(split) - 1
table.merge_cells(TBL, 1, _row, array.size(split), _row)
// CRAB / GARTLEY / BUTTERFLY / DEEP CRAB
if array.size(split) == 1
table.clear(TBL, 0, 1, 1, 2)
f_cell(0, 3, 'POSSIBLE', false)
// } |
atnX_2 | https://www.tradingview.com/script/Te8a87gL/ | abdllhatnx | https://www.tradingview.com/u/abdllhatnx/ | 36 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © melihtuna
// This strategy has been prepared with what investercoin taught us. Endless thanks to him.
//@version=5
indicator("atnX_2", overlay=true)
Ema5=ta.ema(close,5)
Ema10=ta.ema(close,10)
Rsi14=ta.rsi(close,14)
Rsi50=ta.rsi(close,21)
condition = input.string(title="Ichimoku Fiyat Davranışı", defval="Fiyat kapanışı bulut üstünde ise al", options=["Fiyat en yüksek değeri bulut içine girdiyse al", "Fiyat kapanışı bulut içinde ya da üstünde ise al", "Fiyat kapanışı bulut üstünde ise al"], group="Ichimoku Ayarlar")
conversionPeriods = input.int(9, minval=1, title="Conversion Line Length", group="Ichimoku Ayarlar")
basePeriods = input.int(26, minval=1, title="Base Line Length", group="Ichimoku Ayarlar")
laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length", group="Ichimoku Ayarlar")
displacement = input.int(26, minval=1, title="Displacement", group="Ichimoku Ayarlar")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
status=0
ichimokuConfirm = condition == "Fiyat kapanışı bulut üstünde ise al" ? close > leadLine1[displacement - 1] and close > leadLine2[displacement - 1] : condition == "Fiyat en yüksek değeri bulut içine girdiyse al" ? leadLine1[displacement - 1] > leadLine2[displacement - 1] ? ((high < leadLine1[displacement - 1] and high > leadLine2[displacement - 1]) or (close > leadLine2[displacement - 1])) : ((high > leadLine1[displacement - 1] and high < leadLine2[displacement - 1]) or (close > leadLine1[displacement - 1])) : leadLine1[displacement - 1] > leadLine2[displacement - 1] ? close > leadLine2[displacement - 1] : close > leadLine1[displacement - 1]
Stg_BuyCondition = ta.crossover(Ema5,Ema10) and ichimokuConfirm
Stg_SellCondition = ta.crossover(Ema10,Ema5)
intBuyCond = Stg_BuyCondition ? 1 : 0
intSellCond = Stg_SellCondition ? 1 : 0
chngBuy = ta.change(intBuyCond)
chngSell = ta.change(intSellCond)
status:= chngBuy and intBuyCond == 1 ? 1 : chngSell and intSellCond == 1 ? 0 : status[1]
p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7, title="Leading Span A")
p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A, title="Leading Span B")
fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))
plotshape(ta.change(status) and intBuyCond == 1, title="Buy", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.blue, textcolor=color.white)
plotshape(ta.change(status) and intSellCond == 1, title="Sell", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
alertcondition(ta.change(status) and intBuyCond == 1, title="Buy Alert")
alertcondition(ta.change(status) and intSellCond == 1, title="Sell Alert") |
CDC_BTC Rainbow Road | https://www.tradingview.com/script/GVD283Lu-CDC-BTC-Rainbow-Road/ | piriya33 | https://www.tradingview.com/u/piriya33/ | 305 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © piriya33
//@version=5
indicator("CDC_BTC Rainbow Road", overlay = true)
_price = input.source(close,"Price Source")
_malen = input.int(730,"MA Length",minval = 1, maxval = 999)
_mltpl = input.float(5,"Channel Multipler")
_lvl00 = input.float(0.5,"Level 00")
_lvl01 = input.float(0.618,"Level 01")
_lvl02 = input.float(0.786,"Level 02")
_lvl03 = input.float(0.887,"Level 03")
_lvl04 = input.float(1.618,"Level 04")
_lvl05 = input.float(2.618,"Level 05")
_lvl06 = input.float(4.236,"Level 06")
baseMA = ta.sma(_price,_malen)
peakMA = baseMA*_mltpl
bandwidth = peakMA-baseMA
top06 = (bandwidth*_lvl06)+baseMA
top05 = (bandwidth*_lvl05)+baseMA
top04 = (bandwidth*_lvl04)+baseMA
top03 = (bandwidth*_lvl03)+baseMA
top02 = (bandwidth*_lvl02)+baseMA
top01 = (bandwidth*_lvl01)+baseMA
midline = (bandwidth*_lvl00)+baseMA
bot01 = peakMA - (bandwidth*_lvl01)
bot02 = peakMA - (bandwidth*_lvl02)
bot03 = peakMA - (bandwidth*_lvl03)
sub01 = baseMA*_lvl01
color00 = #ff0040
color01 = #ff4400
color02 = #ffbf00
color03 = #bfff00
color04 = #40ff00
color05 = #00ff40
color06 = #00ffbf
color07 = #00bfff
color08 = #0040ff
color09 = #4000ff
color10 = #bf00ff
color11 = #ff00bf
lbot = plot(baseMA,"Lower Channel",color=color.gray,linewidth=2)
ltop = plot(peakMA,"Upper Channel",color=color.gray,linewidth=2)
lmid = plot(midline,color=color.gray,linewidth=1)
l11 = plot(top06,color=color11)
l10 = plot(top05,color=color10)
l09 = plot(top04,color=color09)
l07 = plot(top03,color=color07)
l06 = plot(top02,color=color06)
l05 = plot(top01,color=color05)
l03 = plot(bot01,color=color03)
l02 = plot(bot02,color=color02)
l01 = plot(bot03,color=color01)
lb1 = plot(sub01,color=color00)
fill(l11,l10,color=color.new(color11,90))
fill(l10,l09,color=color.new(color10,90))
fill(l09,ltop,color=color.new(color09,90))
fill(ltop,l07,color=color.new(color08,90))
fill(l07,l06,color=color.new(color07,90))
fill(l06,l05,color=color.new(color06,90))
fill(l05,lmid,color=color.new(color05,90))
fill(lmid,l03,color=color.new(color04,90))
fill(l03,l02,color=color.new(color03,90))
fill(l02,l01,color=color.new(color02,90))
fill(l01,lbot,color=color.new(color01,90))
|
Bitcoin Bottom Detector: W Timeframe | https://www.tradingview.com/script/a8BmKP73-Bitcoin-Bottom-Detector-W-Timeframe/ | cryptoonchain | https://www.tradingview.com/u/cryptoonchain/ | 92 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MJShahsavar
//@version=5
indicator("Bitcoin Bottom Detector: W Timeframe", timeframe = "W")
a= ta.sma(close, 200)
b=close/a
c= math.log10(b)
d= math.log10(c)
h0=hline (0.3, color=color.red, linewidth = 1)
h1=hline (-0.5, color=color.red, linewidth = 1)
h2= hline (-1, color=color.red, linewidth = 1)
h3= hline (-1.3, color=color.black, linewidth = 1)
h4= hline (-2.7, color=color.blue, linewidth = 1)
h5= hline (-0.2, color=color.red, linewidth = 1)
h6= hline (-1.8, color=color.blue, linewidth = 1)
fill (h0, h5, color.red, transp = 80)
fill (h5, h1, color.orange, transp = 80)
fill (h6, h3, color.aqua, transp = 80)
fill (h6, h4, color.blue, transp = 80)
plot (d, color = color.blue, linewidth=1) |
Pivot-Point Weighted Moving Average | https://www.tradingview.com/script/RzO0QrgL/ | EduardoMattje | https://www.tradingview.com/u/EduardoMattje/ | 18 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EduardoMattje
//@version=5
indicator("Pivot-Point Weighted Moving Average", "PPWMA", overlay=true)
var startingWeight = input.int(0, "Starting weight")
var length = input.int(21, "Length")
price = input.source(close, "Price source")
pivotPointAverage = 0.0
weight = startingWeight
if weight == 0
weight := math.floor(length * 2/3) - 1
sum = 0.0
sumWeight = 0.0
for ix = 1 to length
sum := sum + weight * price[ix - 1]
sumWeight := sumWeight + weight
weight := weight - 1
if sumWeight != 0
pivotPointAverage := sum / sumWeight
else
pivotPointAverage := 0.0
plot(pivotPointAverage)
|
Woodies CCI (SafeDay) v1.1 | https://www.tradingview.com/script/OOGRxtMd-Woodies-CCI-SafeDay-v1-1/ | SafeDayTrading | https://www.tradingview.com/u/SafeDayTrading/ | 29 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SafeDayTrading
//@Version=6
// Fixed the Histogram to only change trend color after gold bar condition to align with Woodies specifications
// Added ability for user to select colors for Turbo, CCI and Histogram
//@version=5
// Fixed Sidewinder calculations to include syminfo.mintick correction and compare correctly to Radians
// Made one adjustment to SideWWinder to align more closely with technical specs
// Notes on Indicator
// SideWinder (+/- 200 Line ) --> Trend Indication. Green - Strong Trend, Yellow --> Trending, Red --> Not Trending. Looks at absolute value of sum of rate of change for LSMA and ema34
// ChopZone (+/- 100 Line) --> Trend Direction. Turquoise --> UpTrend, Red --> Downtrend, Any Other Color --> Not Trending. Comparing price to ema 34
// LSMA (Zero Line) --> Price Direction (rate of change of LSMA) --> Green --> Up, Red --> Down, White --> near Std Dev.
// Buy Direction
// Sidewinder (Trending?)- Green (Stong Trend, Yellow - Trend, Red - Not Trending)
// ChopZone (Trend Direction?) = Turquoise (Price above ema34)
// LSMA (Direction of Avg Price Change) = Green (Green - Up, Red - Down, White - Near Std Dev)
// Sell Direction
// Sidewinder (Trending?)- Green (Stong Trend, Yellow - Trend, Red - Not Trending)
// ChopZone (Trend Direction?) = Red (Price above ema34, Red - price below ema34, Green - price above ema34)
// LSMA (Direction of Avg Price Change) = Red (Red - Down, Green - Up, White - Near Std Dev)
indicator(title='Woodies CCI (SafeDay) v1.2', shorttitle="Woodies CCI (SafeDay) v1.2", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
//declaration of variables
source = input(title='Source for CCI/Turbo/EMA', defval=close, group="CCI and Turbo Setup")
cci14Length = input.int(title='CCI Length', defval=14, minval=7, maxval=20, group= "CCI and Turbo Setup")
cciTurboLength = input.int(title='Turbo Length', defval=6, minval=3, maxval=14, group= "CCI and Turbo Setup")
cciColor = input(title="CCI Color", defval=#FF00FF, group= "CCI and Turbo Setup")
turboColor = input(title="Turbo Color", defval=#ffeb3b, group= "CCI and Turbo Setup")
// Histogram Setup
barsbt = input(title='Bars Before Trend', defval=4, group="Histogram Setup")
histBull = input(title="Histogram Bull Trend Color", defval = #008000, group="Histogram Setup")
histBear = input(title = "Histogram Bear Trend Color", defval=#FF0000, group="Histogram Setup")
histTrendStart = input(title = "Histogram Trend Start Color", defval= #ffff00, group="Histogram Setup")
histNoTrend = input(title = "Histogram Non Trend Color", defval = #c0c0c0, group="Histogram Setup")
// LSMA Setup for ZeroLine
src = input(defval=open, title='LSMA Source', group="LSMA Setup For ZeroLine")
length = input(title='LSMA Length', defval=25, group="LSMA Setup For ZeroLine")
offset = input(title='LSMA Offset', defval=0, group="LSMA Setup For ZeroLine")
// Chopzone and Sidewinder Setup
emal = input(title='EMA Length for ChopZone and SideWinder', defval=34, group="ChopZone and SideWinder Setup")
swhigh = input(title='Sidewinder Radians Higher Threshold ', defval=1.7453, group="ChopZone and SideWinder Setup") // 100 Degrees
swmid = input(title='Sidewinder Radians Middle Threshold', defval=1.0471, group="ChopZone and SideWinder Setup") // 60 Degrees -- Not Used
swlow = input(title='Sidewinder Radians Lower Threshold', defval=0.5235, group="ChopZone and SideWinder Setup") // 30 Degrees
// Setup of non user selectable colors for chopzone, lsma, sidewinder
colorTurquoise = #34dddd
colorDarkGreen = #006400
colorPaleGreen = #98fb98
colorDarkRed = #8B0000
colorLightOrange = #ffc04c
colorOrange = color.orange
colorBlack = color.black
colorLime = color.lime
colorRed = #FF0000
colorSilver = #c0c0c0
colorYellow = #ffff00
colorGreen = #008000
colorWhite = color.white
//Chopzone Calculations
avg = hlc3
pi = math.atan(1) * 4
periods = 30
highestHigh = ta.highest(periods)
lowestLow = ta.lowest(periods)
range_1 = 25 / (highestHigh - lowestLow) * lowestLow
ema34 = ta.ema(source, emal)
x1_ema34 = 0
x2_ema34 = 1
y1_ema34 = 0
y2_ema34 = (ema34[1] - ema34) / avg * range_1
c_ema34 = math.sqrt((x2_ema34 - x1_ema34) * (x2_ema34 - x1_ema34) + (y2_ema34 - y1_ema34) * (y2_ema34 - y1_ema34))
emaAngle_1 = math.round(180 * math.acos((x2_ema34 - x1_ema34) / c_ema34) / pi)
emaAngle = y2_ema34 > 0 ? -emaAngle_1 : emaAngle_1
chopZoneColor = emaAngle >= 5 ? colorTurquoise : emaAngle < 5 and emaAngle >= 3.57 ? colorDarkGreen : emaAngle < 3.57 and emaAngle >= 2.14 ? colorPaleGreen : emaAngle < 2.14 and emaAngle >= .71 ? colorLime : emaAngle <= -1 * 5 ? colorDarkRed : emaAngle > -1 * 5 and emaAngle <= -1 * 3.57 ? colorRed : emaAngle > -1 * 3.57 and emaAngle <= -1 * 2.14 ? colorOrange : emaAngle > -1 * 2.14 and emaAngle <= -1 * .71 ? colorLightOrange : colorYellow
// CCI and Turbo Calculations
cciTurbo = ta.cci(source, cciTurboLength)
cci14 = ta.cci(source, cci14Length)
// Histogram Calculations
BullGoldBar = false
BearGoldBar = false
var Trend = ""
BullCondition1 = ta.lowest(cci14, barsbt+1) >= 0
BearCondition1 = ta.highest(cci14, barsbt+1) < 0
BullGoldBar := cci14 >= 0 ? ((BullCondition1 and not(BullGoldBar[1]) and not(Trend == "BullTrend"))) : false
BearGoldBar := cci14 < 0 ? ((BearCondition1 and not(BearGoldBar[1]) and not(Trend == "BearTrend"))) : false
BullTrend = (cci14 >= 0 and BullGoldBar[1]) or (Trend[1] == "BullTrend")
BearTrend = (cci14 < 0 and BearGoldBar[1]) or (Trend[1] == "BearTrend")
Trend := cci14 >= 0 and BullTrend ? "BullTrend" : cci14 < 0 and BearTrend ?"BearTrend" : cci14 >= 0 and BearTrend ? "BearTrend" : "BullTrend"
histogramColor = (cci14 > 0) and (BullTrend) ? histBull : (cci14 < 0) and (BearTrend) ? histBear : (BullGoldBar or BearGoldBar) ? histTrendStart : histNoTrend
//LSMA Calculations
lsma = ta.linreg(src, length, offset)
lsmastd = ta.stdev(math.abs(lsma[1] - lsma), length)
colorLine = math.abs(lsma - lsma[1]) < lsmastd ? colorWhite : lsma < lsma[1] ? colorRed : colorGreen
//Sidewinder Calculations
sum = (ta.change(lsma) + ta.change(ema34)) / syminfo.mintick
//** radian angles
colorLineSW = math.abs(sum) > swhigh ? colorGreen : math.abs(sum) > swmid and math.abs(sum) < swhigh ? colorYellow : colorRed
//plots of CCI and Histogram
plot(cci14, title='Histogram', color=color.new(histogramColor, 50), style=plot.style_columns)
plot(cciTurbo, title='Turbo', color=color.new(turboColor, 0), style=plot.style_line, linewidth=3)
plot(cci14, title='CCI', color=color.new(cciColor, 0), style=plot.style_line, linewidth=3)
//plots of Chopzones
plot(100, title='plus chop zone', color=chopZoneColor, style=plot.style_line, linewidth=3, editable=false)
plot(-100, title='minus chop zone', color=chopZoneColor, style=plot.style_line, linewidth=3, editable=false)
//plot of LSMA
plot(0, title='LSMA line', color=colorLine, style=plot.style_line, linewidth=3, editable=false)
//plot of Sidewinder
plot(-200, title='minus Sidewinder', color=colorLineSW, style=plot.style_line, linewidth=3, editable=false)
plot(200, title='plus Sidewinder', color=colorLineSW, style=plot.style_line, linewidth=3, editable=false)
//hlines
hline(0, title='Zero Line', color=colorBlack, linestyle=hline.style_solid)
hline(200, title='+Sidewinder line', color=colorBlack, linestyle=hline.style_dotted)
hline(-200, title='-Sidewinder line', color=colorBlack, linestyle=hline.style_dotted)
hline(100, title='+chop zone line', color=colorBlack, linestyle=hline.style_dotted)
hline(-100, title='-chop zone line', color=colorBlack, linestyle=hline.style_dotted)
|
SMA Regime | https://www.tradingview.com/script/nPrWCeal-SMA-Regime/ | mslade50 | https://www.tradingview.com/u/mslade50/ | 8 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mslade50
//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mslade50
//@version=5
indicator("SMA Regime", overlay=false)
iSMA = input(200,"Period SMA")
hline(0)
smasample = ta.sma(close,iSMA)
smaslope = (smasample-ta.sma(close[1],iSMA))/smasample
iclose = close - smasample
plotcolor = (iclose<0 and smaslope<0) ? #880E4F:
(iclose>=0 and smaslope>0) ? #4CAF50:
(iclose<=0 and smaslope>0) ? #FFEB3B:
(iclose>=0 and smaslope<0) ? #FFEB3B: #787B86
plot(smaslope, title="Regime", color=plotcolor, linewidth=2, style=plot.style_area) |
Customized Multi EMA | https://www.tradingview.com/script/V3bmFg01-Customized-Multi-EMA/ | timecrutramer | https://www.tradingview.com/u/timecrutramer/ | 100 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © timecrutramer
//
// Plot several MA & EMA with only one script.
//
// Default MA : EMA
// SMA, EMA and Vegas could be set separately to show or not according to your needs.
//
// Default length: 25, 50, 100, 200.
// All of length are adjustable.
//
// Text and line colors can be set at the same time.
//@version=5
indicator(title='Custom Multi SMA & EMA', shorttitle='SMA & EMA', overlay=true)
// get user input length, color, etc.
bool isShowEMA = input.bool(true, title='Display EMA', group="MA")
bool isShowSMA = input.bool(false, title='Display SMA', group="MA")
length1 = input.int(25, title='Length 1', minval=1, group='MA Length')
length2 = input.int(50, title='Length 2', minval=1, group='MA Length')
length3 = input.int(100, title='Length 3', minval=1, group='MA Length')
length4 = input.int(200, title='Length 4', minval=1, group='MA Length')
lengthEmaVegasFilter = 12
colorL1 = input.color(color.silver, title='Color 1', group='MA Color')
colorL2 = input.color(color.aqua, title='Color 2', group='MA Color')
colorL3 = input.color(color.orange, title='Color 3', group='MA Color')
colorL4 = input.color(color.red, title='Color 4', group='MA Color')
// calc deduct
deductBarOffset = input(0, title='Bar offset', group='Deduct')
deductBar1 = length1 + deductBarOffset
deductBar2 = length2 + deductBarOffset
deductBar3 = length3 + deductBarOffset
deductBar4 = length4 + deductBarOffset
deductBarEmaVegasFilter = lengthEmaVegasFilter + deductBarOffset
bool isShowVegas = input.bool(false, title='Display Vegas', group="Vegas") // limit to TF: (timeframe.period == '60' or timeframe.period == '240' or timeframe.period == 'D')
colorVegas144 = input.color(color.yellow, title='Vegas 144', group='Vegas')
colorVegas169 = input.color(color.yellow, title='Vegas 169', group='Vegas')
colorVegasFilter = input.color(color.purple, title='Vegas filter', group='Vegas')
// generate ema data
ema1 = isShowEMA ? ta.ema(close, length1) : na
ema2 = isShowEMA ? ta.ema(close, length2) : na
ema3 = isShowEMA ? ta.ema(close, length3) : na
ema4 = isShowEMA ? ta.ema(close, length4) : na
// draw ema
plot(ema1, 'ema1', color=color.new(colorL1, 0))
plot(ema2, 'ema2', color=color.new(colorL2, 0))
plot(ema3, 'ema3', color=color.new(colorL3, 0))
plot(ema4, 'ema4', color=color.new(colorL4, 0), linewidth=4)
// generate sma data
sma1 = isShowSMA ? ta.sma(close, length1) : na
sma2 = isShowSMA ? ta.sma(close, length2) : na
sma3 = isShowSMA ? ta.sma(close, length3) : na
sma4 = isShowSMA ? ta.sma(close, length4) : na
// draw sma
plot(sma1, 'sma1', color=color.new(colorL1, 50))
plot(sma2, 'sma2', color=color.new(colorL2, 50))
plot(sma3, 'sma3', color=color.new(colorL3, 50))
plot(sma4, 'sma4', color=color.new(colorL4, 50), linewidth=4)
// draw deduct
cond = barstate.islast
plot(cond ? low[length1] : na, color=color.new(color.yellow, 0), linewidth=5, offset=-deductBar1, style=plot.style_circles, show_last=1)
plot(cond ? low[length2] : na, color=color.new(color.yellow, 0), linewidth=5, offset=-deductBar2, style=plot.style_circles, show_last=1)
plot(cond ? low[length3] : na, color=color.new(color.yellow, 0), linewidth=5, offset=-deductBar3, style=plot.style_circles, show_last=1)
plot(cond ? low[length4] : na, color=color.new(color.yellow, 0), linewidth=5, offset=-deductBar4, style=plot.style_circles, show_last=1)
plot(cond ? low[lengthEmaVegasFilter] : na, color=color.new(color.fuchsia, 0), linewidth=5, offset=-deductBarEmaVegasFilter, style=plot.style_circles, show_last=1)
// draw vegas tunnel
emaVegasFilter = isShowVegas ? ta.ema(close, lengthEmaVegasFilter) : na
emaVegas144 = isShowVegas ? ta.ema(close, 144) : na
emaVegas169 = isShowVegas ? ta.ema(close, 169) : na
plot(emaVegasFilter, 'emaVegasFilter', color=color.new(colorVegasFilter, 50))
plot(emaVegas144, 'Vegas144', color.new(colorVegas144, 0))
plot(emaVegas169, 'Vegas169', color.new(colorVegas169, 0))
// add label to lines
var labelEMA1 = label.new(x = bar_index, y = ema1, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL1, 0), text = str.format("EMA {0}", length1))
var labelEMA2 = label.new(x = bar_index, y = ema2, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL2, 0), text = str.format("EMA {0}", length2))
var labelEMA3 = label.new(x = bar_index, y = ema3, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL3, 0), text = str.format("EMA {0}", length3))
var labelEMA4 = label.new(x = bar_index, y = ema4, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL4, 0), text = str.format("EMA {0}", length4))
var labelSMA1 = label.new(x = bar_index, y = sma1, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL1, 50), text = str.format("SMA {0}", length1))
var labelSMA2 = label.new(x = bar_index, y = sma2, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL2, 50), text = str.format("SMA {0}", length2))
var labelSMA3 = label.new(x = bar_index, y = sma3, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL3, 50), text = str.format("SMA {0}", length3))
var labelSMA4 = label.new(x = bar_index, y = sma4, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorL4, 50), text = str.format("SMA {0}", length4))
var labelVegasFilter = label.new(x = bar_index, y = emaVegasFilter, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorVegasFilter, 0), text = "Vegas filter")
var labelVegas144 = label.new(x = bar_index, y = emaVegas144, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorVegas144, 0), text = "Vegas 144")
var labelVegas169 = label.new(x = bar_index, y = emaVegas169, style = label.style_label_left, color = color.rgb(0, 0, 0, 100), textcolor = color.new(colorVegas169, 0), text = "Vegas 169")
label.set_xy(labelEMA1, x = bar_index, y = ema1)
label.set_xy(labelEMA2, x = bar_index, y = ema2)
label.set_xy(labelEMA3, x = bar_index, y = ema3)
label.set_xy(labelEMA4, x = bar_index, y = ema4)
label.set_xy(labelSMA1, x = bar_index, y = sma1)
label.set_xy(labelSMA2, x = bar_index, y = sma2)
label.set_xy(labelSMA3, x = bar_index, y = sma3)
label.set_xy(labelSMA4, x = bar_index, y = sma4)
label.set_xy(labelVegasFilter, x = bar_index, y = emaVegasFilter)
label.set_xy(labelVegas144, x = bar_index, y = emaVegas144)
label.set_xy(labelVegas169, x = bar_index, y = emaVegas169)
|
LNL Keltner Exhaustion | https://www.tradingview.com/script/QUqhvRZH-LNL-Keltner-Exhaustion/ | lnlcapital | https://www.tradingview.com/u/lnlcapital/ | 117 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// L&L Keltner Exhaustion
//
// With the Keltner Exhaustion wedges, you can easily see the Keltner Channel extremes witout using the actual bands. This resolves the constant issue of Bands vs. EMAs
//
// The defaults are set to 3 ATR and 4 ATR (the extremes are set to purple)
//
// Created by © L&L Capital
//
indicator(title="LNL Keltner Exhaustion", shorttitle = "Keltner Exhaustion", overlay=true)
// Inputs
length = input(21, title = "MidLine Keltner Length")
atrlength = input(21, title = "ATR Keltner Length")
mult = input(3, title = "ATR Keltner Factor")
mult1 = input(4, title = "ATR Keltner Factor Extreme")
// Keltner Calculations
ma = ta.ema(close, length)
rangema = ta.ema(ta.tr, atrlength)
upper = ma + rangema * mult // UPPER MID BAND
lower = ma - rangema * mult // LOWER MID BAND
upperX = ma + rangema * mult1 // UPPER MID BAND EXTREME
lowerX = ma - rangema * mult1 // LOWER MID BAND EXTREME
// Plots
UpperKeltner = high > upper
plotchar(UpperKeltner, title = "Upper Keltner", char = '˄', location = location.abovebar, size = size.tiny, color = #ff0000)
LowerKeltner = low < lower
plotchar(LowerKeltner, title = "Lower Keltner", char = '˅', location = location.belowbar, size = size.tiny, color = #009900)
UpperKeltnerX = high > upperX
plotchar(UpperKeltnerX, title = "Upper Keltner Extreme", char = '˄', location = location.abovebar, size = size.tiny, color = #bd53ce)
LowerKeltnerX = low < lowerX
plotchar(LowerKeltnerX, title = "Lower Keltner Extreme", char = '˅', location = location.belowbar, size = size.tiny, color = #bd53ce)
// EMAs
ema8 = input.int(defval=8, title='EMA Length')
ema13 = input.int(defval=13, title='EMA Length')
ema21 = input.int(defval=21, title='EMA Length')
ema34 = input.int(defval=34, title='EMA Length')
ema55 = input.int(defval=55, title='EMA Length')
ema89 = input.int(defval=89,title='EMA Length')
ema200 = input.int(defval=200, title='EMA Length')
ema8d = ta.ema(close, ema8)
ema13d = ta.ema(close, ema13)
ema21d = ta.ema(close, ema21)
ema34d = ta.ema(close, ema34)
ema55d = ta.ema(close, ema55)
ema89d = ta.ema(close, ema89)
ema200d = ta.ema(close, ema200)
plot(ema8d, title='EMA 8', color=color.new(color.green, 0), linewidth=1, display = display.none)
plot(ema13d, title='EMA 13', color=color.new(color.orange, 0), linewidth=1, display = display.none)
plot(ema21d, title='EMA 21', color=color.new(color.yellow, 0), linewidth=2, display = display.none)
plot(ema34d, title='EMA 34', color=color.new(color.purple, 0), linewidth=1, display = display.none)
plot(ema55d, title='EMA 55', color=color.new(color.red, 0), linewidth=1, display = display.none)
plot(ema89d, title='EMA 89', color=color.new(color.aqua, 0), linewidth=1, display = display.none)
plot(ema200d, title='EMA 200', color=color.new(color.blue, 0), linewidth=2, display = display.none)
|
Range Marker | https://www.tradingview.com/script/GdiF7EAb-Range-Marker/ | poch3ng | https://www.tradingview.com/u/poch3ng/ | 9 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © poch3ng
//@version=5
indicator("Range Marker", shorttitle="RM", overlay=true)
style_group = "Style"
setting_group = "Setting"
c_bar = input.int(title="Bar Back", defval=20, group=style_group)
c_color = input.color(title="Mark Color", defval=color.purple, group=style_group)
c_transparent = input.int(title="Transparent", defval=80, group=style_group)
c_bar_enabled = input.bool(title="Bar Count", defval=false, group=setting_group)
c_limit_enabled = input.bool(title="Limit Timeframe", defval=false, group=setting_group)
c_timeframe = input.timeframe(title="Timeframe Period", defval="60", group=setting_group)
f_countbar(period)=>
bull_bar = 0
for i=0 to period
if(close[i] >= open[i])
bull_bar +=1
[bull_bar, period-bull_bar]
[bull, bear] = f_countbar(2*c_bar)
if(c_bar_enabled)
lab = label.new(bar_index, na, str.tostring(bull/(2*c_bar)*100) + "%\n🠇", yloc = yloc.abovebar, style = label.style_none, textcolor = color.black, size = size.normal)
label.delete(lab[1])
if(timeframe.period == c_timeframe or c_limit_enabled == false)
myBox = box.new(left=bar_index-c_bar, top=ta.highest(close,c_bar),
right=bar_index, bottom=ta.lowest(close,c_bar),
bgcolor=color.new(c_color, c_transparent),
border_width=0)
box.delete(myBox[1])
|
Historical Volatility Ratio | https://www.tradingview.com/script/U8gpgwVf-Historical-Volatility-Ratio/ | DreWill1738 | https://www.tradingview.com/u/DreWill1738/ | 40 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DreWill1738
//@version=4
study("Historical Volatility Ratio")
st = close/close[1]
logst = log(st)
period1 = input(30, minval = 1)
period2 = input(50, minval = 1)
st1 = stdev(st, period1)
st2 = stdev(st, period2)
HVR = st1/st2
plot(HVR)
l1 = input(1.4, maxval = 99999)
l2 = input(0.5, maxval = 99999)
plot(l1, color=color.red)
plot(l2, color=color.red)
|
JMA filter 2 | https://www.tradingview.com/script/gGq4j6Si-JMA-filter-2/ | RafaelZioni | https://www.tradingview.com/u/RafaelZioni/ | 468 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RafaelZioni
//@version=5
indicator('JMA filter 2')
length = input(title='Length', defval=35)
phase = 0
power = 2
src = close
atrLength = 30
mult = 1.5
fastLength = 5
fastPhase = 100
fastPower = 2
calc_jma(_src, _length, _phase, _power) =>
phaseRatio = _phase < -100 ? 0.5 : _phase > 100 ? 2.5 : _phase / 100 + 1.5
beta = 0.45 * (_length - 1) / (0.45 * (_length - 1) + 2)
alpha = math.pow(beta, _power)
e0 = 0.0
e0 := (1 - alpha) * _src + alpha * nz(e0[1])
e1 = 0.0
e1 := (_src - e0) * (1 - beta) + beta * nz(e1[1])
jma = 0.0
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
jma
jma = calc_jma(src, length, phase, power)
p = jma / close
p2 = p / -1
z = p2 - p + 2
x = z * 100
Fast = input(2)
Slow = input(4)
C = input(5)
co(sFast, sSlow, f, l, lC) =>
fastC = ta.sma(sFast, f)
slowC = ta.sma(sSlow, l)
cC = fastC + slowC
ta.sma(cC, lC)
x1 = co(x, x, Fast, Slow, C)
col = x1 >= 0 ? color.lime : color.red
plot(x1, linewidth=2, color=col)
plot(0)
trel = input(-50)
plot(trel, linewidth=2, color=color.new(color.gray, 0))
treh = input(45)
plot(treh, linewidth=2, color=color.new(color.gray, 0))
down = ta.crossunder(x1, treh)
up = ta.crossover(x1, trel)
plotshape(up, title='UP', style=shape.xcross, color=color.new(color.green, 0), location=location.bottom, textcolor=color.new(color.black, 0), text='UP', size=size.tiny)
plotshape(down, title='down', style=shape.cross, color=color.new(color.red, 0), location=location.top, textcolor=color.new(color.black, 0), text='Down', size=size.tiny)
|
Floating RSI Indicator | https://www.tradingview.com/script/ow2P1Y2q-Floating-RSI-Indicator/ | TradingTail | https://www.tradingview.com/u/TradingTail/ | 39 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mayurssupe
//@version=5
indicator("Floating RSI",overlay=true)
_rsiLabels = input.bool(defval = false,title="RSI Labels",group = "Options",tooltip = "it calculates the RSI value of bar and it will display on the top of the bar")
rsiZones = input.string(defval="60/40",title="RSI Zones",options=["60/40","50/50","70/30","80/20"],group="RSI")
rsiPeriod = input.int(defval=9,title="RSI Period",group="RSI")
_source = input.source(defval=close,title="RSI Source",group="RSI")
black = input.color(defval=color.black,title="Black",group="Colors")
white = input.color(defval=color.white,title="White",group="Colors")
red = input.color(defval=color.red,title="Red",group="Colors")
green = input.color(defval=color.green,title="Green",group="Colors")
silver = input.color(defval=color.silver,title="Silver",group="Colors")
//Defining RSI
rsi = ta.rsi(_source,rsiPeriod)
//defining values as per the rsi Zones
var int rsiOB = 0
var int rsiOS = 0
if(rsiZones == "60/40")
rsiOB:=60
rsiOS:=40
else if(rsiZones =="50/50")
rsiOB :=50
rsiOS :=50
else if(rsiZones =="70/30")
rsiOB :=70
rsiOS :=30
else if(rsiZones =="80/20")
rsiOB :=80
rsiOS :=20
var string GP2 = "Display Table"
string i_tableYpos = input.string("middle", "Panel position", inline = "11", options = ["top", "middle", "bottom"], group = GP2)
string i_tableXpos = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GP2)
var table t = table.new(i_tableYpos + "_" + i_tableXpos, 9, 9, border_width=1,frame_width=1)
_CalcTf = input.timeframe(defval="D",title="High Minus Low TF",options=['D','W','M'],group="Table")
//Gaps value
prevDayClose = request.security(syminfo.tickerid,"D",close)[1]// previous day last day candle close
nextdayOpen = request.security(syminfo.tickerid,"D",open) // next day candle open
_gaps = nz(nextdayOpen - prevDayClose)
var string gapStatus = na
var color bgcolor = na
if(prevDayClose > nextdayOpen)
gapStatus:="▼"
bgcolor:=red
else if(prevDayClose < nextdayOpen)
gapStatus:="▲"
bgcolor:= green
highC = high
LowC = low
closeC = close
_Calc = (high - low)
_Calc_pts = request.security(syminfo.tickerid, _CalcTf, _Calc)
_CalcOpen = (close - open)
atr = ta.atr(14)
// Trend Stregth Using Adx
[diplus, diminus, adx] = ta.dmi(14, 14)
weak = adx >= 0 and adx <= 20
strong = adx >= 20.05 and adx <= 49.99
ExtremeStrong = adx >= 50 and adx <= 60
danger = adx >= 60 and adx <= 100
var string adxSign = na
var color adxS = na
if(weak)
adxSign :="Weak"
adxS:= color.gray
else if(strong)
adxSign :="Good"
adxS:= color.green
else if(ExtremeStrong)
adxSign :="Strong"
adxS:= color.purple
else if(danger)
adxSign :="Exhausted"
adxS:= color.red
else
adxSign:= "0"
if barstate.isrealtime or barstate.islast or barstate.isconfirmed
table.cell(t, 0, 1, 'RSI',bgcolor=black,text_color=white)
table.cell(t, 0, 2, "ATR",bgcolor=black,text_color=white)
table.cell(t, 0, 3, 'High - Low',bgcolor=black,text_color=white)
table.cell(t, 0, 4, 'Body Len',bgcolor=black,text_color=white)
table.cell(t, 0, 5, "Today Gap",bgcolor=black,text_color=white)
table.cell(t, 0, 6, "Trend Stregth",bgcolor=black,text_color=white)
table.cell(t, 1, 1, str.tostring(math.round(rsi, 0)),bgcolor=rsi > rsiOB ? green : rsi < rsiOS ? red : color.orange,text_color=color.white)
table.cell(t, 1, 2, str.tostring(math.round(atr, 3)),bgcolor=black ,text_color=white)
table.cell(t, 1, 3, str.tostring(math.round(_Calc_pts, 3)),bgcolor=black ,text_color=white)
table.cell(t, 1, 4, str.tostring(math.round(_CalcOpen, 3)),bgcolor=black ,text_color=white)
table.cell(t, 1, 5, str.tostring(math.round(_gaps, 0))+ " " +gapStatus,bgcolor=bgcolor ,text_color=white)
table.cell(t, 1, 6, str.tostring(adxSign),bgcolor=adxS ,text_color=white)
//Labels of RSI
t1 =str.tostring(math.round(rsi, 2))
label.new(_rsiLabels and bar_index ? bar_index : na,rsi,text=str.tostring(t1),yloc = yloc.abovebar,color=rsi > rsiOB ? color.aqua : rsi < rsiOS ? color.rgb(255, 69, 116, 20) : black,textcolor=color.white,style=label.style_label_down,size=size.small) |
Stacked EMAs | https://www.tradingview.com/script/GjP2IT5g-Stacked-EMAs/ | lnlcapital | https://www.tradingview.com/u/lnlcapital/ | 145 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// Stacked EMAs
//
// Stacked EMAs & Stacked Weekly EMAs Label + 7 daily and 2 MTF weekly EMAs
//
// Created by © L&L Capital
//
indicator("Stacked EMAs", overlay = true)
// Inputs
ema8 = input.int(defval=8, title='EMA Length')
ema13 = input.int(defval=13, title='EMA Length')
ema21 = input.int(defval=21, title='EMA Length')
ema34 = input.int(defval=34, title='EMA Length')
ema55 = input.int(defval=55, title='EMA Length')
ema89 = input.int(defval=89,title='EMA Length')
ema200 = input.int(defval=200, title='EMA Length')
ema8we = input.int(defval=8, title='EMA Weekly Length')
ema21we = input.int(defval=21, title='EMA Weekly Length')
ema34we = input.int(defval=34, title='EMA Weekly Length')
ema55we = input.int(defval=55, title='EMA Weekly Length')
// EMAs
ema8d = ta.ema(close, ema8)
ema13d = ta.ema(close, ema13)
ema21d = ta.ema(close, ema21)
ema34d = ta.ema(close, ema34)
ema55d = ta.ema(close, ema55)
ema89d = ta.ema(close, ema89)
ema200d = ta.ema(close, ema200)
ema8w = request.security(syminfo.tickerid, 'W', ta.ema(close, ema8we))
ema21w = request.security(syminfo.tickerid, 'W', ta.ema(close, ema21we))
ema34w = request.security(syminfo.tickerid, 'W', ta.ema(close, ema34we))
ema55w = request.security(syminfo.tickerid, 'W', ta.ema(close, ema55we))
// Plots
plot(ema8d, title='EMA 8', color=color.new(color.green, 0), linewidth=1)
plot(ema13d, title='EMA 13', color=color.new(color.orange, 0), linewidth=1)
plot(ema21d, title='EMA 21', color=color.new(color.yellow, 0), linewidth=2)
plot(ema34d, title='EMA 34', color=color.new(color.purple, 0), linewidth=1)
plot(ema55d, title='EMA 55', color=color.new(color.red, 0), linewidth=1)
plot(ema89d, title='EMA 89', color=color.new(color.aqua, 0), linewidth=1)
plot(ema200d, title='EMA 200', color=color.new(color.blue, 0), style=plot.style_circles, linewidth = 1)
plot(ema8w, title='EMA 8 Weekly', color=color.new(color.green, 0), linewidth=2, display=display.none)
plot(ema21w, title='EMA 21 Weekly', color=color.new(color.white, 0), linewidth=2, display=display.none)
// Stacked EMAs & Stacked Weekly EMAs Table
string tableYposInput = input.string("top", "Panel position", inline = "11", options = ["top", "middle", "bottom"])
string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"])
color bullColorInput = input.color(color.new(color.green, 0), "Bullish", inline = "12")
color bearColorInput = input.color(color.new(color.red, 0), "Bearish", inline = "12")
color neutColorInput = input.color(color.new(color.yellow, 0), "Neutral", inline = "12")
EMAsLabel = string ("Stacked EMAs")
LabelColor = neutColorInput
if ema8d > ema21d and ema21d > ema34d and ema34d > ema55d
LabelColor := bullColorInput
if ema8d < ema21d and ema21d < ema34d and ema34d < ema55d
LabelColor := bearColorInput
WEMAsLabel = string ("Stacked Weekly EMAs")
LabelColorW = neutColorInput
if ema8w > ema21w and ema21w > ema34w and ema34w > ema55w
LabelColorW := bullColorInput
if ema8w < ema21w and ema21w < ema34w and ema34w < ema55w
LabelColorW := bearColorInput
Table = table.new(tableYposInput + "_" + tableXposInput, columns=3, rows=1, bgcolor=color.gray)
if barstate.islast
table.cell(table_id=Table, column=1, row=0, text=EMAsLabel, height=0, text_color=color.white, text_halign=text.align_left, text_valign= text.align_center, bgcolor=LabelColor)
table.cell(table_id=Table, column=2, row=0, text=WEMAsLabel, height=0,text_color=color.white, text_halign=text.align_left, text_valign=text.align_center, bgcolor=LabelColorW)
|
TUE ADX/MACD Confluence V1.0 | https://www.tradingview.com/script/A37vsAuW-TUE-ADX-MACD-Confluence-V1-0/ | TradersUltimateEdge | https://www.tradingview.com/u/TradersUltimateEdge/ | 1,511 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Written by TradersUltimateEdge
// Code provided open source, feel free to use it for any purpose except resale
//@version=5
indicator("TUE ADX/MACD Confluence V1.0", overlay=true)
showsignals = input(true, title="Show BUY/SELL Signals")
showcandlecolors = input(true, title="Show Candle Colors")
length = input(14, title="ADX Length")
smoothing = input(10, title="ADX Smoothing")
macdsource = input(close, title="MACD Source")
macdfast = input(12, title="MACD Fast Length")
macdslow = input(26, title="MACD Slow Length")
macdsignal = input(9, title="MACD Signal Length")
colorup = input(color.green, title="Up Candle Color")
colordown = input(color.red, title="Down Candle Color")
/////////////////////////////////////////////////////////////////////////////////////////////// ADX AND MACD CALC
[diplus, diminus, adx] = ta.dmi(length, smoothing)
[macdline, signalline, histline] = ta.macd(macdsource, macdfast, macdslow, macdsignal)
//////////////////////////////////////////////////////////////////////////////////////////////TRADE CALC
longcheck = diplus > diminus and macdline > signalline
shortcheck = diminus > diplus and signalline > macdline
int trade = 0
//Open from nothing
if trade == 0 and longcheck
trade := 1
else if trade == 0 and shortcheck
trade := -1
//Reversal
else if trade == 1 and shortcheck
trade := -1
else if trade == -1 and longcheck
trade := 1
//Keep status quo until crossover
else
trade := trade[1]
//////////////////////////////////////////////////////////////////////////////////////////////PLOT
colors = longcheck ? colorup : shortcheck ? colordown : color.white
plotcandle(open, high, low, close, color = showcandlecolors ? colors : na)
plotshape(trade[1] != 1 and trade == 1 and showsignals, style=shape.labelup, text='BUY', textcolor=color.white, color=color.green, size=size.small, location=location.belowbar)
plotshape(trade[1] != -1 and trade == -1 and showsignals, style=shape.labeldown, text='SELL', textcolor=color.white, color=color.red, size=size.small, location=location.abovebar)
///////////////////////////////////////////////////////////////////////////////////////////// ALERTS
alertcondition(trade[1] != 1 and trade == 1, "LONG")
alertcondition(trade[1] != -1 and trade == -1, "SHORT")
|
BlackMEX - Production Cost | https://www.tradingview.com/script/QGWJo5sM-BlackMEX-Production-Cost/ | ferGOD | https://www.tradingview.com/u/ferGOD/ | 45 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capriole_charles
//@version=4
study("BlackMEX",overlay=true)
// NOTES
// Bitcoin's Value as determined by Joules of energy input only
// Calculations per Medium article EV = (Energy-in) / (Supply Growth Rate) * (Fiat Factor)
// Historic Energy Efficiency data can only be entered monthly due to processing speed constraints of below data load and should be considred an estimate only.
// Energy Efficiency Data requires manual updating. Currently accurate as of 28 December 2019
// INPUTS
fiat_factor = input(2.0,"Fiat Factor - A Constant Representing the Fiat USD value of a Joule (mult by 10^-15).")
lost = input(defval=1000000, title="Lost Bitcoins", type=input.integer)
raw = input(true, "Plot Energy Value Raw")
sma = input(true, "Plot Energy Value SMA")
len = input(20,"Energy Value SMA length (days)")
mv=input(false,"Plot MA bands")
// DATA & FUNCTIONS
energy_efficiency() =>
// Average Bitcoin Mining Hardware Energy Efficiency (J/GH)
// Uses Bitcoin Mining Hardware Manufacturer Spec Energy Efficiency (J/GH)
// Data Source: Bitcoin Wiki and CBECI
d = dayofmonth
m = month
y = year
e = float(na)
e := d==15 and m==1 and y==2011? 7946.83220938736 :
d==15 and m==2 and y==2011? 7919.41839243041 :
d==15 and m==3 and y==2011? 7632.98344069555 :
d==15 and m==4 and y==2011? 7481.77369210883 :
d==15 and m==5 and y==2011? 7235.83629484419 :
d==15 and m==6 and y==2011? 7004.3958189483 :
d==15 and m==7 and y==2011? 7424.80653864182 :
d==15 and m==8 and y==2011? 7424.80653864182 :
d==15 and m==9 and y==2011? 6376.1280731424 :
d==15 and m==10 and y==2011? 5194.95515659859 :
d==15 and m==11 and y==2011? 4638.22732855883 :
d==15 and m==12 and y==2011? 4726.69553622754 :
d==15 and m==1 and y==2012? 4804.10521793766 :
d==15 and m==2 and y==2012? 4016.5564250286 :
d==15 and m==3 and y==2012? 3158.62595648445 :
d==15 and m==4 and y==2012? 2803.23990550415 :
d==15 and m==5 and y==2012? 2730.11445159239 :
d==15 and m==6 and y==2012? 2725.35546233546 :
d==15 and m==7 and y==2012? 2725.35546233546 :
d==15 and m==8 and y==2012? 2725.35546233546 :
d==15 and m==9 and y==2012? 2725.35546233546 :
d==15 and m==10 and y==2012? 2725.35546233546 :
d==15 and m==11 and y==2012? 2657.33647784477 :
d==15 and m==12 and y==2012? 2693.23055902333 :
d==15 and m==1 and y==2013? 2567.31168809632 :
d==15 and m==2 and y==2013? 2010.50635911607 :
d==15 and m==3 and y==2013? 1457.30785659375 :
d==15 and m==4 and y==2013? 1189.03510277857 :
d==15 and m==5 and y==2013? 1119.03463573955 :
d==15 and m==6 and y==2013? 930.746036826081 :
d==15 and m==7 and y==2013? 48.3605281757209 :
d==15 and m==8 and y==2013? 45.4898976813005 :
d==15 and m==9 and y==2013? 43.1908956549566 :
d==15 and m==10 and y==2013? 39.9239675902243 :
d==15 and m==11 and y==2013? 35.9404616591799 :
d==15 and m==12 and y==2013? 32.5475862305335 :
d==15 and m==1 and y==2014? 29.1884018211459 :
d==15 and m==2 and y==2014? 26.0481147720191 :
d==15 and m==3 and y==2014? 16.3168605075398 :
d==15 and m==4 and y==2014? 8.89876391490287 :
d==15 and m==5 and y==2014? 8.78751371891833 :
d==15 and m==6 and y==2014? 8.60464060736008 :
d==15 and m==7 and y==2014? 7.81762586226057 :
d==15 and m==8 and y==2014? 7.0815417915592 :
d==15 and m==9 and y==2014? 6.7522551823933 :
d==15 and m==10 and y==2014? 6.27172203804964 :
d==15 and m==11 and y==2014? 5.15937443536947 :
d==15 and m==12 and y==2014? 4.52574122013518 :
d==15 and m==1 and y==2015? 2.85085483477115 :
d==15 and m==2 and y==2015? 1.60069849097814 :
d==15 and m==3 and y==2015? 1.53698379742013 :
d==15 and m==4 and y==2015? 1.4800675401877 :
d==15 and m==5 and y==2015? 1.47013611727757 :
d==15 and m==6 and y==2015? 1.45622339117475 :
d==15 and m==7 and y==2015? 1.32267865317551 :
d==15 and m==8 and y==2015? 1.13655134648048 :
d==15 and m==9 and y==2015? 0.997126082644854 :
d==15 and m==10 and y==2015? 0.888779078658476 :
d==15 and m==11 and y==2015? 0.887188142202356 :
d==15 and m==12 and y==2015? 0.878722281644594 :
d==15 and m==1 and y==2016? 0.855124269986229 :
d==15 and m==2 and y==2016? 0.847352818483432 :
d==15 and m==3 and y==2016? 0.833440627395937 :
d==15 and m==4 and y==2016? 0.785069524089441 :
d==15 and m==5 and y==2016? 0.747064212787211 :
d==15 and m==6 and y==2016? 0.678588928027975 :
d==15 and m==7 and y==2016? 0.445662312187738 :
d==15 and m==8 and y==2016? 0.26875945705385 :
d==15 and m==9 and y==2016? 0.26875945705385 :
d==15 and m==10 and y==2016? 0.26875945705385 :
d==15 and m==11 and y==2016? 0.26875945705385 :
d==15 and m==12 and y==2016? 0.26875945705385 :
d==15 and m==1 and y==2017? 0.26875945705385 :
d==15 and m==2 and y==2017? 0.240957775799832 :
d==15 and m==3 and y==2017? 0.155416876823419 :
d==15 and m==4 and y==2017? 0.140777777777778 :
d==15 and m==5 and y==2017? 0.141666666666667 :
d==15 and m==6 and y==2017? 0.141666666666667 :
d==15 and m==7 and y==2017? 0.140111105161705 :
d==15 and m==8 and y==2017? 0.137102226664446 :
d==15 and m==9 and y==2017? 0.13439641795264 :
d==15 and m==10 and y==2017? 0.131811367043751 :
d==15 and m==11 and y==2017? 0.130574258325383 :
d==15 and m==12 and y==2017? 0.124543446458589 :
d==15 and m==1 and y==2018? 0.123202512380174 :
d==15 and m==2 and y==2018? 0.125217779998889 :
d==15 and m==3 and y==2018? 0.127373807540674 :
d==15 and m==4 and y==2018? 0.130214592703648 :
d==15 and m==5 and y==2018? 0.12419969325682 :
d==15 and m==6 and y==2018? 0.119652587499354 :
d==15 and m==7 and y==2018? 0.118646953462924 :
d==15 and m==8 and y==2018? 0.116439991605504 :
d==15 and m==9 and y==2018? 0.113189853989414 :
d==15 and m==10 and y==2018? 0.107168798944558 :
d==15 and m==11 and y==2018? 0.102537771579842 :
d==15 and m==12 and y==2018? 0.101373824945235 :
d==15 and m==1 and y==2019? 0.0994042769348746 :
d==15 and m==2 and y==2019? 0.0982868686868687 :
d==15 and m==3 and y==2019? 0.0973011667058178 :
d==15 and m==4 and y==2019? 0.0944657760184726 :
d==15 and m==5 and y==2019? 0.0912386349930043 :
d==15 and m==6 and y==2019? 0.0895277777777777 :
d==22 and m==6 and y==2019? 0.0891875 :
d==29 and m==6 and y==2019? 0.0888472222222222 :
d==6 and m==7 and y==2019? 0.0876992398408638 :
d==13 and m==7 and y==2019? 0.0859502543336175 :
d==20 and m==7 and y==2019? 0.0842012688263711 :
d==27 and m==7 and y==2019? 0.0824522833191248 :
d==3 and m==8 and y==2019? 0.0811829347983412 :
d==10 and m==8 and y==2019? 0.0808609628587791 :
d==17 and m==8 and y==2019? 0.0805389909192169 :
d==24 and m==8 and y==2019? 0.0802170189796548 :
d==31 and m==8 and y==2019? 0.0797022684742928 :
d==7 and m==9 and y==2019? 0.0779249977286423 :
d==14 and m==9 and y==2019? 0.0761004322996338 :
d==21 and m==9 and y==2019? 0.0742758668706253 :
d==28 and m==9 and y==2019? 0.0724513014416168 :
d==5 and m==10 and y==2019? 0.0719328264639189 :
d==12 and m==10 and y==2019? 0.0717619207683073 :
d==19 and m==10 and y==2019? 0.0715910150726957 :
d==26 and m==10 and y==2019? 0.0714201093770842 :
d==2 and m==11 and y==2019? 0.0709366687280973 :
d==9 and m==11 and y==2019? 0.0699111276025562 :
d==16 and m==11 and y==2019? 0.0688855864770151 :
d==23 and m==11 and y==2019? 0.0678600453514739 :
d==30 and m==11 and y==2019? 0.0669541414141414 :
d==7 and m==12 and y==2019? 0.0666392649903288 :
d==14 and m==12 and y==2019? 0.0663032559638943 :
d==21 and m==12 and y==2019? 0.0659672469374597 :
d==28 and m==12 and y==2019? 0.0656312379110251 :
d==4 and m==1 and y==2020? 0.0651329223081883 :
d==11 and m==1 and y==2020? 0.0646368858800774 :
d==18 and m==1 and y==2020? 0.0641408494519665 :
d==25 and m==1 and y==2020? 0.0636448130238556 :
d==1 and m==2 and y==2020? 0.0631837727272728 :
d==8 and m==2 and y==2020? 0.0624330317812269 :
d==15 and m==2 and y==2020? 0.0616822908351811 :
d==22 and m==2 and y==2020? 0.0609315498891353 :
d==29 and m==2 and y==2020? 0.0601808089430894 :
d==7 and m==3 and y==2020? 0.0598767435728412 :
d==14 and m==3 and y==2020? 0.0595650582289607 :
d==21 and m==3 and y==2020? 0.0592533728850803 :
d==28 and m==3 and y==2020? 0.0589416875411998 :
d==4 and m==4 and y==2020? 0.0586456728603604 :
d==11 and m==4 and y==2020? 0.0583054476351351 :
d==18 and m==4 and y==2020? 0.0579652224099099 :
d==25 and m==4 and y==2020? 0.0576249971846847 :
d==2 and m==5 and y==2020? 0.0572197474747475 :
d==9 and m==5 and y==2020? 0.0563079797979798 :
d==16 and m==5 and y==2020? 0.0553962121212121 :
d==23 and m==5 and y==2020? 0.0544844444444445 :
d==30 and m==5 and y==2020? 0.0535726767676768 :
d==6 and m==6 and y==2020? 0.0530256363025416 :
d==13 and m==6 and y==2020? 0.0525220914793092 :
d==20 and m==6 and y==2020? 0.0520185466560769 :
d==27 and m==6 and y==2020? 0.0515150018328446 :
d==4 and m==7 and y==2020? 0.051296875 :
d==11 and m==7 and y==2020? 0.0513260416666667 :
d==18 and m==7 and y==2020? 0.0513552083333333 :
d==25 and m==7 and y==2020? 0.051384375 :
d==1 and m==8 and y==2020? 0.051409375 :
d==8 and m==8 and y==2020? 0.0513488541666667 :
d==15 and m==8 and y==2020? 0.0512883333333333 :
d==22 and m==8 and y==2020? 0.0512278125 :
d==29 and m==8 and y==2020? 0.0511672916666667 :
d==5 and m==9 and y==2020? 0.0510874242424243 :
d==12 and m==9 and y==2020? 0.0510248484848485 :
d==19 and m==9 and y==2020? 0.0509622727272727 :
d==26 and m==9 and y==2020? 0.050899696969697 :
d==3 and m==10 and y==2020? 0.0508960743207941 :
d==10 and m==10 and y==2020? 0.0507566709117032 :
d==17 and m==10 and y==2020? 0.0506172675026123 :
d==24 and m==10 and y==2020? 0.0504778640935214 :
d==31 and m==10 and y==2020? 0.0502856388888889 :
d==7 and m==11 and y==2020? 0.0503010087365592 :
d==14 and m==11 and y==2020? 0.0503182029569893 :
d==21 and m==11 and y==2020? 0.0503353971774193 :
d==28 and m==11 and y==2020? 0.0503525913978494 :
d==5 and m==12 and y==2020? 0.0502937849462366 :
d==12 and m==12 and y==2020? 0.0502187921146954 :
d==19 and m==12 and y==2020? 0.0501437992831542 :
d==26 and m==12 and y==2020? 0.0500688064516129 :
d==2 and m==1 and y==2021? 0.0498510370370371 :
d==9 and m==1 and y==2021? 0.0495261851851852 :
d==16 and m==1 and y==2021? 0.0492013333333334 :
d==23 and m==1 and y==2021? 0.0488764814814815 :
d==30 and m==1 and y==2021? 0.048560462962963 :
d==6 and m==2 and y==2021? 0.0479725925925926 :
d==13 and m==2 and y==2021? 0.0473847222222222 :
d==20 and m==2 and y==2021? 0.0467968518518518 :
d==27 and m==2 and y==2021? 0.0462089814814815 :
d==6 and m==3 and y==2021? 0.0455328703703704 :
d==13 and m==3 and y==2021? 0.0447038888888889 :
d==20 and m==3 and y==2021? 0.0438749074074074 :
d==27 and m==3 and y==2021? 0.0430459259259259 :
d==3 and m==4 and y==2021? 0.0425722222222222 :
d==10 and m==4 and y==2021? 0.0425722222222222 :
d==17 and m==4 and y==2021? 0.0425722222222222 :
d==24 and m==4 and y==2021? 0.0425722222222222 :
d==1 and m==5 and y==2021? 0.0425722222222222 :
d==8 and m==5 and y==2021? 0.0430975272331155 :
d==15 and m==5 and y==2021? 0.0436228322440087 :
d==22 and m==5 and y==2021? 0.044148137254902 :
d==29 and m==5 and y==2021? 0.0446734422657952 :
d==5 and m==6 and y==2021? 0.0446461554621849 :
d==12 and m==6 and y==2021? 0.0443300402661064 : na
e
energy_value(hr_live) =>
// HR on TV only has "yesterday's" value --> use "lookahead_on" when running live (on current bar), to pull forward yesterdays data
hr_hist = security("QUANDL:BCHAIN/HRATE", "D", close,gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
stock = security("QUANDL:BCHAIN/TOTBC", "D", close,gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
stock12m = security("QUANDL:BCHAIN/TOTBC", "D", close[365],gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
HR_raw = float(na)
HR_raw := barstate.isrealtime ? hr_live : hr_hist
energy_eff = float(na)
energy_eff := na(energy_efficiency()) ? energy_eff[1] : energy_efficiency()
energy_in = (HR_raw * 1000) * energy_eff
flow = stock - stock12m
SF = (stock-lost)/flow
seconds_per_year = 365.25*24*60*60
supply_growth_rate = (1.0/SF)/seconds_per_year // supply growth rate per second (inflation rate)
energy_value = (energy_in)/(supply_growth_rate)*(fiat_factor/pow(10,15))
energy_value
// CALCULATE
ev = security("QUANDL:BCHAIN/HRATE", "D", energy_value(close),gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
ev_sma = security("QUANDL:BCHAIN/HRATE", "D", sma(energy_value(close),len),gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
// PLOT
plot(raw?ev:na,color=color.red,linewidth=1,transp=70,title="")
plot(sma?ev_sma:na,color=color.red,linewidth=2,title="SMA")
//
//
//
//
//************************************************************************************************************************************
//************************************************************************************************************************************
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capriole_charles
//@version=4
// INPUTS
p_og = input(0.05,"Ave. Electricity Cost $USD KWh (Pre June 2019)")
p_china = input(0.04,"Ave. Electricity Cost $USD KWh (Pre China Exodus 2021")
p_new = input(0.05,"Ave. Electricity Cost $USD KWh (Post May 2021")
elec_pct = input(0.60,"% electricity to Total Mining Costs")
plot_mp = input(true,"Plot BTC Miner Price (Close + Transaction Fee Revenue / BTC)")
plot_tc = input(true,"Plot Production & Electricity Cost Curves")
labels = input(false,"Plot Annual Profit Margin Labels?")
use_f = input(false,"Inflation factor")
f = input(0.06,"Post-Corona Inflation factor")
// DATA
fees = security("QUANDL:BCHAIN/TRFUS","D",close)
elec_consumption() =>
// Cambridge Bitcoin Electricity Consumption Index (CBECI) - Bitcoin's global electricity consumption in TwH.
// NB: Uses MONTHLY averages of raw data from CBECI. TV script run-time is too slow with Daily/Weekly data here.
// This requires manual updating once a month for ongoing accuracy.
d = dayofmonth
m = month
y = year
e = float(na)
e := d==1 and m==1 and y==2012? 0.0448897733333333 :
d==8 and m==1 and y==2012? 0.0467732066666667 :
d==22 and m==1 and y==2012? 0.0499167266666667 :
d==5 and m==2 and y==2012? 0.0516129533333333 :
d==19 and m==2 and y==2012? 0.0526943266666667 :
d==4 and m==3 and y==2012? 0.05538186 :
d==18 and m==3 and y==2012? 0.0580128533333333 :
d==1 and m==4 and y==2012? 0.0611542533333333 :
d==15 and m==4 and y==2012? 0.05900928 :
d==29 and m==4 and y==2012? 0.05795294 :
d==13 and m==5 and y==2012? 0.06452278 :
d==27 and m==5 and y==2012? 0.06054668 :
d==10 and m==6 and y==2012? 0.0604923266666667 :
d==24 and m==6 and y==2012? 0.06490944 :
d==8 and m==7 and y==2012? 0.0670409266666667 :
d==22 and m==7 and y==2012? 0.0712722266666667 :
d==5 and m==8 and y==2012? 0.0780710533333333 :
d==19 and m==8 and y==2012? 0.08622184 :
d==2 and m==9 and y==2012? 0.0957779533333333 :
d==16 and m==9 and y==2012? 0.105795213333333 :
d==30 and m==9 and y==2012? 0.113526666666667 :
d==14 and m==10 and y==2012? 0.114823266666667 :
d==28 and m==10 and y==2012? 0.121561133333333 :
d==11 and m==11 and y==2012? 0.128912466666667 :
d==25 and m==11 and y==2012? 0.1279656 :
d==9 and m==12 and y==2012? 0.132210866666667 :
d==23 and m==12 and y==2012? 0.1144392 :
d==6 and m==1 and y==2013? 0.120510733333333 :
d==20 and m==1 and y==2013? 0.115101733333333 :
d==3 and m==2 and y==2013? 0.117235733333333 :
d==17 and m==2 and y==2013? 0.103566966666667 :
d==3 and m==3 and y==2013? 0.109349686666667 :
d==17 and m==3 and y==2013? 0.124549266666667 :
d==31 and m==3 and y==2013? 0.172383133333333 :
d==14 and m==4 and y==2013? 0.213046733333333 :
d==28 and m==4 and y==2013? 0.241923066666667 :
d==12 and m==5 and y==2013? 0.275134666666667 :
d==26 and m==5 and y==2013? 0.306536266666667 :
d==9 and m==6 and y==2013? 0.394398933333333 :
d==23 and m==6 and y==2013? 0.4976452 :
d==7 and m==7 and y==2013? 0.582760133333333 :
d==21 and m==7 and y==2013? 0.7401676 :
d==4 and m==8 and y==2013? 0.908156133333333 :
d==18 and m==8 and y==2013? 1.28042666666667 :
d==1 and m==9 and y==2013? 0.534310466666667 :
d==15 and m==9 and y==2013? 0.391327333333333 :
d==29 and m==9 and y==2013? 0.5588032 :
d==13 and m==10 and y==2013? 0.764947933333333 :
d==27 and m==10 and y==2013? 1.3118052 :
d==10 and m==11 and y==2013? 1.91040266666667 :
d==24 and m==11 and y==2013? 2.39963266666667 :
d==8 and m==12 and y==2013? 2.99599333333333 :
d==22 and m==12 and y==2013? 4.11922 :
d==5 and m==1 and y==2014? 5.27489066666667 :
d==19 and m==1 and y==2014? 7.14739266666667 :
d==2 and m==2 and y==2014? 8.90992733333333 :
d==16 and m==2 and y==2014? 11.0466933333333 :
d==2 and m==3 and y==2014? 7.66129533333333 :
d==16 and m==3 and y==2014? 2.928136 :
d==30 and m==3 and y==2014? 3.55123333333333 :
d==13 and m==4 and y==2014? 4.35657733333333 :
d==27 and m==4 and y==2014? 5.25784666666667 :
d==11 and m==5 and y==2014? 5.83622733333333 :
d==25 and m==5 and y==2014? 6.94009533333333 :
d==8 and m==6 and y==2014? 7.97694666666667 :
d==22 and m==6 and y==2014? 9.47082666666667 :
d==6 and m==7 and y==2014? 10.1856406666667 :
d==20 and m==7 and y==2014? 6.81052933333333 :
d==3 and m==8 and y==2014? 7.12624 :
d==17 and m==8 and y==2014? 7.97746666666667 :
d==31 and m==8 and y==2014? 7.722336 :
d==14 and m==9 and y==2014? 1.62927266666667 :
d==28 and m==9 and y==2014? 1.79479733333333 :
d==12 and m==10 and y==2014? 1.85550666666667 :
d==26 and m==10 and y==2014? 1.89836 :
d==9 and m==11 and y==2014? 2.08068933333333 :
d==23 and m==11 and y==2014? 2.12267133333333 :
d==7 and m==12 and y==2014? 2.03810866666667 :
d==21 and m==12 and y==2014? 1.72866733333333 :
d==4 and m==1 and y==2015? 1.83967066666667 :
d==18 and m==1 and y==2015? 1.902684 :
d==1 and m==2 and y==2015? 1.85248266666667 :
d==15 and m==2 and y==2015? 1.959152 :
d==1 and m==3 and y==2015? 2.06469933333333 :
d==15 and m==3 and y==2015? 2.09730533333333 :
d==29 and m==3 and y==2015? 2.10092 :
d==12 and m==4 and y==2015? 2.14148066666667 :
d==26 and m==4 and y==2015? 2.11196933333333 :
d==10 and m==5 and y==2015? 2.078068 :
d==24 and m==5 and y==2015? 2.145618 :
d==7 and m==6 and y==2015? 2.09108066666667 :
d==21 and m==6 and y==2015? 2.194054 :
d==5 and m==7 and y==2015? 2.186602 :
d==19 and m==7 and y==2015? 2.267548 :
d==2 and m==8 and y==2015? 2.32644866666667 :
d==16 and m==8 and y==2015? 2.355268 :
d==30 and m==8 and y==2015? 2.40752866666667 :
d==13 and m==9 and y==2015? 2.56722266666667 :
d==27 and m==9 and y==2015? 2.59675 :
d==11 and m==10 and y==2015? 2.723812 :
d==25 and m==10 and y==2015? 2.71067066666667 :
d==8 and m==11 and y==2015? 2.85210933333333 :
d==22 and m==11 and y==2015? 3.03022866666667 :
d==6 and m==12 and y==2015? 3.39929466666667 :
d==20 and m==12 and y==2015? 3.98623133333333 :
d==3 and m==1 and y==2016? 4.50523 :
d==17 and m==1 and y==2016? 4.933306 :
d==31 and m==1 and y==2016? 5.44452133333333 :
d==14 and m==2 and y==2016? 6.76244066666667 :
d==28 and m==2 and y==2016? 6.95727866666667 :
d==13 and m==3 and y==2016? 7.16674333333333 :
d==27 and m==3 and y==2016? 7.24838533333333 :
d==10 and m==4 and y==2016? 7.59466 :
d==24 and m==4 and y==2016? 8.03744733333333 :
d==8 and m==5 and y==2016? 8.04669333333333 :
d==22 and m==5 and y==2016? 8.575128 :
d==5 and m==6 and y==2016? 8.75916066666667 :
d==19 and m==6 and y==2016? 9.00681933333333 :
d==3 and m==7 and y==2016? 9.36009866666667 :
d==17 and m==7 and y==2016? 9.46875666666667 :
d==31 and m==7 and y==2016? 8.01446666666667 :
d==14 and m==8 and y==2016? 7.53580333333333 :
d==28 and m==8 and y==2016? 7.733898 :
d==11 and m==9 and y==2016? 7.87172933333333 :
d==25 and m==9 and y==2016? 8.36815333333333 :
d==9 and m==10 and y==2016? 9.015172 :
d==23 and m==10 and y==2016? 8.90605 :
d==6 and m==11 and y==2016? 9.13996866666667 :
d==20 and m==11 and y==2016? 9.65543933333333 :
d==4 and m==12 and y==2016? 10.1403306666667 :
d==18 and m==12 and y==2016? 10.79038 :
d==1 and m==1 and y==2017? 11.3003666666667 :
d==15 and m==1 and y==2017? 12.10902 :
d==29 and m==1 and y==2017? 13.9971133333333 :
d==12 and m==2 and y==2017? 11.8909206666667 :
d==26 and m==2 and y==2017? 9.31708666666667 :
d==12 and m==3 and y==2017? 9.86065 :
d==26 and m==3 and y==2017? 10.3007733333333 :
d==9 and m==4 and y==2017? 7.24762 :
d==23 and m==4 and y==2017? 7.68320933333333 :
d==7 and m==5 and y==2017? 8.29340133333333 :
d==21 and m==5 and y==2017? 9.45574933333333 :
d==4 and m==6 and y==2017? 14.5437 :
d==18 and m==6 and y==2017? 16.2587 :
d==2 and m==7 and y==2017? 16.08918 :
d==16 and m==7 and y==2017? 17.9574866666667 :
d==30 and m==7 and y==2017? 14.9784533333333 :
d==13 and m==8 and y==2017? 14.0673133333333 :
d==27 and m==8 and y==2017? 17.6895533333333 :
d==10 and m==9 and y==2017? 18.6930666666667 :
d==24 and m==9 and y==2017? 20.69434 :
d==8 and m==10 and y==2017? 21.5257466666667 :
d==22 and m==10 and y==2017? 23.8291866666667 :
d==5 and m==11 and y==2017? 25.94404 :
d==19 and m==11 and y==2017? 24.5501666666667 :
d==3 and m==12 and y==2017? 28.0661066666667 :
d==17 and m==12 and y==2017? 31.0909466666667 :
d==31 and m==12 and y==2017? 33.61164 :
d==14 and m==1 and y==2018? 33.3194666666667 :
d==28 and m==1 and y==2018? 37.2621666666667 :
d==11 and m==2 and y==2018? 39.83868 :
d==25 and m==2 and y==2018? 34.0908333333333 :
d==11 and m==3 and y==2018? 36.35522 :
d==25 and m==3 and y==2018? 38.6891266666667 :
d==8 and m==4 and y==2018? 36.9834333333333 :
d==22 and m==4 and y==2018? 36.3653933333333 :
d==6 and m==5 and y==2018? 36.9741866666667 :
d==20 and m==5 and y==2018? 36.2525266666667 :
d==3 and m==6 and y==2018? 39.6266866666667 :
d==17 and m==6 and y==2018? 42.9442866666667 :
d==1 and m==7 and y==2018? 46.8299533333333 :
d==15 and m==7 and y==2018? 44.0931866666667 :
d==29 and m==7 and y==2018? 46.5117733333333 :
d==12 and m==8 and y==2018? 51.6115333333333 :
d==26 and m==8 and y==2018? 52.88186 :
d==9 and m==9 and y==2018? 53.53606 :
d==23 and m==9 and y==2018? 52.26566 :
d==7 and m==10 and y==2018? 54.2591266666667 :
d==21 and m==10 and y==2018? 49.32842 :
d==4 and m==11 and y==2018? 49.3347733333333 :
d==18 and m==11 and y==2018? 46.1241 :
d==2 and m==12 and y==2018? 38.5558133333333 :
d==16 and m==12 and y==2018? 30.9474466666667 :
d==30 and m==12 and y==2018? 33.21604 :
d==13 and m==1 and y==2019? 36.9950533333333 :
d==27 and m==1 and y==2019? 34.83958 :
d==10 and m==2 and y==2019? 35.0500933333333 :
d==24 and m==2 and y==2019? 35.4441 :
d==10 and m==3 and y==2019? 35.9794066666667 :
d==24 and m==3 and y==2019? 37.2053866666667 :
d==7 and m==4 and y==2019? 38.1241066666667 :
d==21 and m==4 and y==2019? 38.6097133333333 :
d==5 and m==5 and y==2019? 40.98594 :
d==19 and m==5 and y==2019? 41.5870866666667 :
d==2 and m==6 and y==2019? 45.8937066666667 :
d==16 and m==6 and y==2019? 46.9439933333333 :
d==30 and m==6 and y==2019? 49.2081066666667 :
d==14 and m==7 and y==2019? 56.2514066666667 :
d==28 and m==7 and y==2019? 56.63712 :
d==11 and m==8 and y==2019? 60.3306466666667 :
d==25 and m==8 and y==2019? 60.5889466666667 :
d==8 and m==9 and y==2019? 64.10794 :
d==22 and m==9 and y==2019? 70.9877866666667 :
d==6 and m==10 and y==2019? 71.6044066666666 :
d==20 and m==10 and y==2019? 69.7132133333333 :
d==3 and m==11 and y==2019? 68.3367666666667 :
d==17 and m==11 and y==2019? 67.1753266666667 :
d==1 and m==12 and y==2019? 65.7259666666667 :
d==15 and m==12 and y==2019? 62.8617666666667 :
d==29 and m==12 and y==2019? 62.7077733333333 :
d==12 and m==1 and y==2020? 68.22666 :
d==26 and m==1 and y==2020? 72.07338 :
d==9 and m==2 and y==2020? 74.5989666666667 :
d==23 and m==2 and y==2020? 76.2619933333333 :
d==8 and m==3 and y==2020? 79.4506866666667 :
d==22 and m==3 and y==2020? 68.7661266666667 :
d==5 and m==4 and y==2020? 54.9826466666667 :
d==19 and m==4 and y==2020? 66.4887 :
d==3 and m==5 and y==2020? 67.6403466666667 :
d==17 and m==5 and y==2020? 73.33354 :
d==31 and m==5 and y==2020? 52.1350333333333 :
d==14 and m==6 and y==2020? 53.85798 :
d==28 and m==6 and y==2020? 54.2859733333333 :
d==12 and m==7 and y==2020? 56.9790133333333 :
d==26 and m==7 and y==2020? 54.9029866666667 :
d==9 and m==8 and y==2020? 59.41582 :
d==23 and m==8 and y==2020? 63.73672 :
d==6 and m==9 and y==2020? 62.8713933333333 :
d==20 and m==9 and y==2020? 65.73894 :
d==4 and m==10 and y==2020? 65.8654733333333 :
d==18 and m==10 and y==2020? 64.7199866666667 :
d==1 and m==11 and y==2020? 60.9787333333333 :
d==15 and m==11 and y==2020? 65.9051533333333 :
d==29 and m==11 and y==2020? 80.4638533333333 :
d==13 and m==12 and y==2020? 81.26956 :
d==27 and m==12 and y==2020? 82.89574 :
d==10 and m==1 and y==2021? 98.42008 :
d==24 and m==1 and y==2021? 106.3038 :
d==7 and m==2 and y==2021? 106.528133333333 :
d==21 and m==2 and y==2021? 110.938466666667 :
d==7 and m==3 and y==2021? 111.518733333333 :
d==21 and m==3 and y==2021? 113.947466666667 :
d==4 and m==4 and y==2021? 119.531533333333 :
d==18 and m==4 and y==2021? 120.342066666667 :
d==2 and m==5 and y==2021? 108.69154 :
d==16 and m==5 and y==2021? 127.397466666667 :
d==30 and m==5 and y==2021? 109.282866666667 :
d==13 and m==6 and y==2021? 102.673546666667 :
d==27 and m==6 and y==2021? 81.9444333333333 :
d==11 and m==7 and y==2021? 63.6538866666667 :
d==25 and m==7 and y==2021? 69.75506 :
d==8 and m==8 and y==2021? 76.5859266666667 :
d==22 and m==8 and y==2021? 84.7868666666667 :
d==5 and m==9 and y==2021? 92.0367733333333 :
d==19 and m==9 and y==2021? 97.33628 :
d==3 and m==10 and y==2021? 99.3566133333333 :
d==17 and m==10 and y==2021? 102.828706666667 :
d==31 and m==10 and y==2021? 109.406533333333 :
d==14 and m==11 and y==2021? 115.639 :
d==28 and m==11 and y==2021? 116.424333333333 :
d==12 and m==12 and y==2021? 120.5624 :
d==26 and m==12 and y==2021? 120.825266666667 :
d==9 and m==1 and y==2022? 122.812266666667 :
d==23 and m==1 and y==2022? 130.533733333333 :
d==6 and m==2 and y==2022? 129.958733333333 :
d==20 and m==2 and y==2022? 135.468666666667 :
d==6 and m==3 and y==2022? 133.200466666667 : na
e
btc_mined_per_day() =>
blocks_per_day = 144
block_reward = time < timestamp(2012,11,28,0,0) ? 50 :
time < timestamp(2016,7,9,0,0) ? 25 :
time < timestamp(2020,5,11,19,0) ? 12.5 :
time < timestamp(2024,5,12,0,0) ? 6.25 : 3.125 // 2024 estimate
btc_per_day = blocks_per_day*block_reward
btc_per_day
// CALCULATIONS
miner_price = close + fees/btc_mined_per_day()
elec = float(na)
elec := na(elec_consumption()) ? elec[1] : elec_consumption()
p = time < timestamp(2019,6,30,0,0) ? p_og :
time < timestamp(2021,4,20,0,0) ? p_china : p_new
btc_elec_cost = float(na)
btc_elec_cost := (elec/365.25)*pow(10,9) / btc_mined_per_day() * p //convert: --> days --> KwH --> Per BTC --> * Price/KwH
b = barssince(time == timestamp(2020, 3, 1, 00, 00))
btc_elec_cost := (use_f and time >= timestamp(2020, 3, 1, 00, 00) ? pow((1+f),b/365) : 1.0)*btc_elec_cost
total_cost = btc_elec_cost/elec_pct
margin = ((miner_price/total_cost)-1.0)*100.0
profit_margin = round(sma(margin,365))
m = ''
m := profit_margin > 0 ? "+" : ''
// PLOT
a = plot(plot_tc ? btc_elec_cost : na,color=color.red,linewidth=2,title=" Electricity")
tc = plot(plot_tc ? total_cost : na,color=color.purple,linewidth=1,title=" Total")
fill(a,tc,color=color.red,transp=70)
mp = plot(plot_mp ? miner_price : close,color=(plot_mp ? color.green : na),linewidth=2,title="Price")
clr = ((plot_mp ? miner_price : close) < total_cost) ? color.red : na
fill(mp,tc,color=clr,transp=20)
// LABELS
if labels and (barstate.islast or (dayofmonth ==1 and month ==1) and profit_margin)
label.new(bar_index, btc_elec_cost, style=label.style_labelup,
text="Margin (p.a.)\n" + m + tostring(profit_margin) +"%",
textcolor=color.white,color=color.green)
//
//
//************************************************************************************************************************************
//************************************************************************************************************************************
//
//@version=4
//
// An indicator by @Quantadelic aka Pinescript Pleb aka Stealer of Alpha & Destroyer of Discords
//
// "I drink your milkshake! I drink it up."
//
// No rights reserved, copy, paste, do what you want.
//
// 13/02/2020: edited by @mabonyi to include coloured zones and remove the intercept/slope variables from indicator displays
//
// INPUTS
DarkOrLight = input("Light", title="Dark mode or Light mode?", options=["Dark", "Light"])
ShowFibs = input("Y", title="Show Fibonacci Levels?", options=["Y","N"])
ShowExtensions= input("N", title="Show Curve Projections?", options=["Y","N"])
//
// Made fixed so that they aren't clogging up the display
HighIntercept = 1.06930947
HighSlope = 0.00076
LowIntercept = -3.0269716
LowSlope = 0.001329
//
//HighIntercept = input(1.06930947, title="Top Curve Intercept", step=0.001)
//HighSlope = input(0.00076, title="Top Curve Slope", step=0.00001)
//LowIntercept = input(-3.0269716, title="Bottom Curve Intercept", step=0.001)
//LowSlope = input(0.001329, title="Bottom Curve Slope", step=0.00001)
//
// TIME CALCS
TimeIndex = time < 1279670400000 ? 3.0 : (time - 1279670400000) / 86400000
Weight = (log10(TimeIndex + 10) * TimeIndex * TimeIndex - TimeIndex) / 30000
TimeDelta = time - time[1]
// TOP OF CHANNEL INTERCEPT & SLOPE CALCS
HighSlopeCum = HighSlope * TimeIndex
HighLogDev = TimeIndex > 2 ? log(Weight) + HighIntercept + HighSlopeCum : na
// BOTTOM OF CHANNEL INTERCEPT & SLOPE CALCS
LowSlopeCum = LowSlope * TimeIndex
LowLogDev = TimeIndex > 2 ? log(Weight) + LowIntercept + LowSlopeCum : na
// TOTAL CHANNEL LOG RANGE
LogRange = HighLogDev - LowLogDev
// FIBONACCI LEVELS
Fib9098Calc = (LogRange * 0.9098) + LowLogDev
Fib8541Calc = (LogRange * 0.8541) + LowLogDev
Fib7639Calc = (LogRange * 0.7639) + LowLogDev
Fib618Calc = (LogRange * 0.618) + LowLogDev
MidCalc = (LogRange * 0.5) + LowLogDev
Fib382Calc = (LogRange * 0.382) + LowLogDev
Fib2361Calc = (LogRange * 0.2361) + LowLogDev
Fib1459Calc = (LogRange * 0.1459) + LowLogDev
Fib0902Calc = (LogRange * 0.0902) + LowLogDev
NegFib0902Calc = LowLogDev - (LogRange * 0.0902)
NegFib1459Calc = LowLogDev - (LogRange * 0.1459)
// SCALE LOG VARIABLES TO LINEAR
HighDev = pow(2.718281828459, HighLogDev)
Fib9098Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib9098Calc) : na
Fib8541Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib8541Calc) : na
Fib7639Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib7639Calc) : na
Fib618Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib618Calc) : na
MidDev = pow(2.718281828459, MidCalc)
Fib382Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib382Calc) : na
Fib2361Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib2361Calc) : na
Fib1459Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib1459Calc) : na
Fib0902Dev = ShowFibs == "Y" ? pow(2.718281828459, Fib0902Calc) : na
LowDev = pow(2.718281828459, LowLogDev)
NegFib0902Dev = ShowFibs == "Y" ? pow(2.718281828459, NegFib0902Calc) : na
NegFib1459Dev = ShowFibs == "Y" ? pow(2.718281828459, NegFib1459Calc) : na
// COLOR SCHEME
ColorScheme = DarkOrLight == "Dark" ? color(color.white) : color(color.black)
// PLOTS
p10000 = plot(HighDev, color=ColorScheme, transp=0, title="100% - Top of Channel")
p9098 = plot(Fib9098Dev, color=ColorScheme, transp=50, title="90.98% - Fibonacci Level")
p8541 = plot(Fib8541Dev, color=ColorScheme, transp=50, title="85.41% - Fibonacci Level")
p7639 = plot(Fib7639Dev, color=ColorScheme, transp=50, title="76.39% - Fibonacci Level")
p6180 = plot(Fib618Dev, color=ColorScheme, transp=50, title="61.80% - Fibonacci Level")
p5000 = plot(MidDev, color=ColorScheme, transp=0, title="50% - Middle of Channel")
p3820 = plot(Fib382Dev, color=ColorScheme, transp=50, title="38.20% - Fibonacci Level")
p2361 = plot(Fib2361Dev, color=ColorScheme, transp=50, title="23.61% - Fibonacci Level")
p1459 = plot(Fib1459Dev, color=ColorScheme, transp=50, title="14.59% - Fibonacci Level")
p902 = plot(Fib0902Dev, color=ColorScheme, transp=50, title="9.02% - Fibonacci Level")
p0 = plot(LowDev, color=ColorScheme, transp=0, title="0% - Bottom of Channel")
pn0902 = plot(NegFib0902Dev, color=color.white, transp=50, title="-9.02% - Fibonacci Level")
pn1459 = plot(NegFib1459Dev, color=color.white, transp=25, title="-14.59% - Fibonacci Level")
fill(p0, p2361, color=color.black, transp=80, title="Oversold Zone")
fill(p3820, p6180, color=color.white, transp=80, title="Transition Zone")
fill(p8541, p10000, color=color.black, transp=80, title="Overbought Zone")
//////////////////////////////////////////////////////////
// //
// CURVE EXTENSION DRAWING FUNCTION & HELPER VARIABLES //
// //
//////////////////////////////////////////////////////////
// CURVE EXTENSION FUNCTION
ExtenZe(_i, _slope, _intercept) =>
TI = ((time + TimeDelta *_i) -1279670400000) / 86400000
W = (log10(TI + 10) * TI * TI - TI) / 30000
HSC = _slope * TI
HLD = log(W) + _intercept + HSC
HD = pow(2.718281828459, HLD)
HD
// VARIABLES FOR ADJUSTING LENGTH OF CURVE EXTENSIONS RELATIVE TO CHART TIME-FRAME
ForLoopStep = timeframe.ismonthly == 1 ? ceil( 12 / timeframe.multiplier) :
timeframe.isweekly == 1 ? ceil(26 / timeframe.multiplier) :
timeframe.isdaily == 1 ? ceil(91 / timeframe.multiplier) :
(timeframe.isminutes == 1) and (timeframe.multiplier > 59) ? ceil(10080 / timeframe.multiplier) : na
ForLoopMax = na(ForLoopStep) ? na : ForLoopStep * 13
// MID CURVE SLOPE & INTERCEPT
MidSlope = (HighSlope + LowSlope) * 0.5
MidIntercept = (HighIntercept + LowIntercept) * 0.5
// CHECK IF LAST BAR & "Show Curve Projections" IS CHECKED, THEN DRAW CURVE EXTENZES
if barstate.islast and ShowExtensions == "Y"
for i = 0 to ForLoopMax-1 by ForLoopStep
line.new(time + TimeDelta * i, ExtenZe(i, HighSlope, HighIntercept), time + TimeDelta * (i + ForLoopStep), ExtenZe(i + ForLoopStep, HighSlope, HighIntercept), xloc=xloc.bar_time, color=ColorScheme)
line.new(time + TimeDelta * i, ExtenZe(i, LowSlope, LowIntercept), time + TimeDelta * (i + ForLoopStep), ExtenZe(i + ForLoopStep, LowSlope, LowIntercept), xloc=xloc.bar_time, color=ColorScheme)
line.new(time + TimeDelta * i, ExtenZe(i, MidSlope, MidIntercept), time + TimeDelta * (i + ForLoopStep), ExtenZe(i + ForLoopStep, MidSlope, MidIntercept), xloc=xloc.bar_time, color=ColorScheme)
//************************************************************************************************************************************
//************************************************************************************************************************************ |
Real Indicator | https://www.tradingview.com/script/UcsUDTqr-Real-Indicator/ | mablue | https://www.tradingview.com/u/mablue/ | 333 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mablue (Masoud Azizi)
// Real indicator is an indicator to convert ohlcv charts to one oscilator!
// there is an effective thing in all charts: "Volume", and I used this thing to mix it by price
// Buy: on crossing above to bollinger-lower-band (on UpTrends)
// Sell: on crossing under bollinger-upper-band (on DownTrends)
// use an sma 200 to determine trends ;)
//@version=5
indicator(title="Real Indicator", shorttitle="REAL", precision=3, timeframe="", timeframe_gaps=true)
timeperiod = input.int(20, minval=3)
rv = input.float(0.25, "Real Variance", options=[0.05,0.10,0.25,0.5,0.75,0.90])
bbv = input.float(2, "Bollinger Bands Variance",minval=0.1,step=0.1)
Fast_BB_Color = input.color(color.red)
BB_Color = input.color(color.green)
Slow_BB_Color = input.color(color.blue)
Real_Color = input.color(color.gray)
real(time_period) =>
// ta.hma((close/close[1]-1)*(volume[1]/volume[2]),time_period)
// ta.hma(close >= close[1] ? close*volume : -close*volume,time_period)
ta.hma((close/close[1]-1)*(volume/volume[1]),time_period)
r1 = real(math.round(timeperiod*(1-rv)))
r2 = real(timeperiod)
r3 = real(math.round(timeperiod*(1+rv)))
r = (r1+r2+r3)/3
[middle1, upper1, lower1] = ta.bb(r1, timeperiod, bbv)
[middle2, upper2, lower2] = ta.bb(r2, timeperiod, bbv)
[middle3, upper3, lower3] = ta.bb(r3, timeperiod, bbv)
pr = plot(r, "Real", color=Real_Color)
pr1 = plot(r1, "Real 1", color=Fast_BB_Color,display=display.none)
pr2 = plot(r2, "Real 2", color=BB_Color,display=display.none)
pr3 = plot(r3, "Real 3", color=Slow_BB_Color,display=display.none)
// hline(0)
pm1 = plot(middle1,"Middle 1", color=Fast_BB_Color,display=display.none)
pm2 = plot(middle2,"Middle 2", color=BB_Color,display=display.none)
pm3 = plot(middle3,"Middle 3", color=Slow_BB_Color,display=display.none)
pu1 = plot(upper1,"Upper 1", color=Fast_BB_Color,display=display.none)
pu2 = plot(upper2,"Upper 2", color=BB_Color,display=display.none)
pu3 = plot(upper3,"Upper 3", color=Slow_BB_Color,display=display.none)
pl1 = plot(lower1,"Lower 1", color=Fast_BB_Color,display=display.none)
pl2 = plot(lower2,"Lower 2", color=BB_Color,display=display.none)
pl3 = plot(lower3,"Lower 3", color=Slow_BB_Color,display=display.none)
fill(pu1, pm1, title = "BB 1 BG U", color=color.new(Fast_BB_Color, 85))
fill(pl1, pm1, title = "BB 1 BG D", color=color.new(Fast_BB_Color, 80))
fill(pu2, pm2, title = "BB 2 BG U", color=color.new(BB_Color, 85))
fill(pl2, pm2, title = "BB 2 BG D", color=color.new(BB_Color, 80))
fill(pu3, pm3, title = "BB 3 BG U", color=color.new(Slow_BB_Color, 85))
fill(pl3, pm3, title = "BB 3 BG D", color=color.new(Slow_BB_Color, 80))
fill(pr1, pu1, color = r1 > upper1 ? color.new(Fast_BB_Color, 70) : color.new(Fast_BB_Color, 100),display=display.none)
fill(pr1, pl1, color = r1 < lower1 ? color.new(Fast_BB_Color, 70) : color.new(Fast_BB_Color, 100),display=display.none)
fill(pr2, pu2, color = r2 > upper2 ? color.new(BB_Color, 70) : color.new(BB_Color, 100),display=display.none)
fill(pr2, pl2, color = r2 < lower2 ? color.new(BB_Color, 70) : color.new(BB_Color, 100),display=display.none)
fill(pr3, pu3, color = r3 > upper3 ? color.new(Slow_BB_Color, 70) : color.new(Slow_BB_Color, 100),display=display.none)
fill(pr3, pl3, color = r3 < lower3 ? color.new(Slow_BB_Color, 70) : color.new(Slow_BB_Color, 100),display=display.none)
fill(pr, pu3, color = r > upper1 ? color.new(color.red, 66) : color.new(color.red, 100),display=display.all)
fill(pr, pl3, color = r < lower1 ? color.new(color.green, 66) : color.new(color.green, 100),display=display.all)
fill(pr, pu3, color = r > upper2 ? color.new(color.red, 66) : color.new(color.red, 100),display=display.all)
fill(pr, pl3, color = r < lower2 ? color.new(color.green, 66) : color.new(color.green, 100),display=display.all)
fill(pr, pu3, color = r > upper3 ? color.new(color.red, 66) : color.new(color.red, 100),display=display.all)
fill(pr, pl3, color = r < lower3 ? color.new(color.green, 66) : color.new(color.green, 100),display=display.all)
|
Moving Averages & Pivots | https://www.tradingview.com/script/jkpxiYqF-Moving-Averages-Pivots/ | TheGypsyTrader | https://www.tradingview.com/u/TheGypsyTrader/ | 25 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TheGypsyTrader
//@version=5
indicator(title="Moving Averages & Pivots", shorttitle="EMA/SMA/Pivots", overlay=true)
// MOVING AVERAGES //
src = input(close, title="Source")
len1 = input(14, title="EMA1")
out1 = ta.ema(src, len1)
plot(out1, color=#33ffff, transp=0, linewidth=1, title="EMA1")
len2 = input(21, title="EMA2")
out2 = ta.ema(src, len2)
plot(out2, color=#ffff33, transp=0, linewidth=1, title="EMA2")
len3 = input(55, title="EMA3")
out3 = ta.ema(src, len3)
plot(out3, color=#ff33ff, transp=0, linewidth=1, title="EMA3")
len4 = input(100, title="SMA1")
out4 = ta.sma(src, len4)
plot(out4, color=#ffffff, transp=0, linewidth=1, style=plot.style_cross, title="SMA1")
len5 = input(200, title="SMA2")
out5 = ta.sma(src, len5)
plot(out5, color=#ff3333, transp=0, linewidth=1, style=plot.style_cross, title="SMA2")
// PIVOT POINTS //
AUTO = "Auto"
DAILY = "Daily"
WEEKLY = "Weekly"
MONTHLY = "Monthly"
QUARTERLY = "Quarterly"
YEARLY = "Yearly"
BIYEARLY = "Biyearly"
TRIYEARLY = "Triyearly"
QUINQUENNIALLY = "Quinquennially"
DECENNIALLY = "Decennially"
TRADITIONAL = "Traditional"
FIBONACCI = "Fibonacci"
WOODIE = "Woodie"
CLASSIC = "Classic"
DEMARK = "DM"
CAMARILLA = "Camarilla"
kind = input.string(title="Type", defval="Traditional", options=[TRADITIONAL, FIBONACCI, WOODIE, CLASSIC, DEMARK, CAMARILLA])
pivot_time_frame = input.string(title="Pivots Timeframe", defval=AUTO, options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY, BIYEARLY, TRIYEARLY, QUINQUENNIALLY, DECENNIALLY])
look_back = input.int(title="Number of Pivots Back", defval=1, minval=1, maxval=5000)
is_daily_based = input.bool(title="Use Daily-based Values", defval=true, tooltip="When this option is unchecked, Pivot Points will use intraday data while calculating on intraday charts. If Extended Hours are displayed on the chart, they will be taken into account during the pivot level calculation. If intraday OHLC values are different from daily-based values (normal for stocks), the pivot levels will also differ.")
show_labels = input.bool(title="Show Labels", defval=true, group="labels")
show_prices = input.bool(title="Show Prices", defval=false, group="labels")
position_labels = input.string("Right", "Labels Position", options=["Left", "Right"], group="labels")
line_width = input.int(title="Line Width", defval=1, minval=1, maxval=100, group="levels")
var DEF_COLOR = #FB8C00
var arr_time = array.new_int()
var p = array.new_float()
p_color = input.color(#ff33ff, "P ", inline="P", group="levels")
p_show = input.bool(true, "", inline="P", group="levels")
var r1 = array.new_float()
var s1 = array.new_float()
s1_color = input.color(DEF_COLOR, "S1", inline="S1/R1" , group="levels")
s1_show = input.bool(true, "", inline="S1/R1", group="levels")
r1_color = input.color(DEF_COLOR, " R1", inline="S1/R1", group="levels")
r1_show = input.bool(true, "", inline="S1/R1", group="levels")
var r2 = array.new_float()
var s2 = array.new_float()
s2_color = input.color(DEF_COLOR, "S2", inline="S2/R2", group="levels")
s2_show = input.bool(true, "", inline="S2/R2", group="levels")
r2_color = input.color(DEF_COLOR, " R2", inline="S2/R2", group="levels")
r2_show = input.bool(true, "", inline="S2/R2", group="levels")
var r3 = array.new_float()
var s3 = array.new_float()
s3_color = input.color(DEF_COLOR, "S3", inline="S3/R3", group="levels")
s3_show = input.bool(true, "", inline="S3/R3", group="levels")
r3_color = input.color(DEF_COLOR, " R3", inline="S3/R3", group="levels")
r3_show = input.bool(true, "", inline="S3/R3", group="levels")
var r4 = array.new_float()
var s4 = array.new_float()
s4_color = input.color(DEF_COLOR, "S4", inline="S4/R4", group="levels")
s4_show = input.bool(true, "", inline="S4/R4", group="levels")
r4_color = input.color(DEF_COLOR, " R4", inline="S4/R4", group="levels")
r4_show = input.bool(true, "", inline="S4/R4", group="levels")
var r5 = array.new_float()
var s5 = array.new_float()
s5_color = input.color(DEF_COLOR, "S5", inline="S5/R5", group="levels")
s5_show = input.bool(true, "", inline="S5/R5", group="levels")
r5_color = input.color(DEF_COLOR, " R5", inline="S5/R5", group="levels")
r5_show = input.bool(true, "", inline="S5/R5", group="levels")
pivotX_open = float(na)
pivotX_open := nz(pivotX_open[1], open)
pivotX_high = float(na)
pivotX_high := nz(pivotX_high[1], high)
pivotX_low = float(na)
pivotX_low := nz(pivotX_low[1], low)
pivotX_prev_open = float(na)
pivotX_prev_open := nz(pivotX_prev_open[1])
pivotX_prev_high = float(na)
pivotX_prev_high := nz(pivotX_prev_high[1])
pivotX_prev_low = float(na)
pivotX_prev_low := nz(pivotX_prev_low[1])
pivotX_prev_close = float(na)
pivotX_prev_close := nz(pivotX_prev_close[1])
get_pivot_resolution() =>
resolution = "M"
if pivot_time_frame == AUTO
if timeframe.isintraday
resolution := timeframe.multiplier <= 15 ? "D" : "W"
else if timeframe.isweekly or timeframe.ismonthly
resolution := "12M"
else if pivot_time_frame == DAILY
resolution := "D"
else if pivot_time_frame == WEEKLY
resolution := "W"
else if pivot_time_frame == MONTHLY
resolution := "M"
else if pivot_time_frame == QUARTERLY
resolution := "3M"
else if pivot_time_frame == YEARLY or pivot_time_frame == BIYEARLY or pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIALLY or pivot_time_frame == DECENNIALLY
resolution := "12M"
resolution
var lines = array.new_line()
var labels = array.new_label()
draw_line(i, pivot, col) =>
if array.size(arr_time) > 1
array.push(lines, line.new(array.get(arr_time, i), array.get(pivot, i), array.get(arr_time, i + 1), array.get(pivot, i), color=col, xloc=xloc.bar_time, width=line_width))
draw_label(i, y, txt, txt_color) =>
if (show_labels or show_prices) and not na(y)
display_text = (show_labels ? txt : "") + (show_prices ? str.format(" ({0})", math.round_to_mintick(y)) : "")
label_style = position_labels == "Left" ? label.style_label_right : label.style_label_left
x = position_labels == "Left" ? array.get(arr_time, i) : array.get(arr_time, i + 1)
array.push(labels, label.new(x = x, y=y, text=display_text, textcolor=txt_color, style=label_style, color=#00000000, xloc=xloc.bar_time))
traditional() =>
pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3
array.push(p, pivotX_Median)
array.push(r1, pivotX_Median * 2 - pivotX_prev_low)
array.push(s1, pivotX_Median * 2 - pivotX_prev_high)
array.push(r2, pivotX_Median + 1 * (pivotX_prev_high - pivotX_prev_low))
array.push(s2, pivotX_Median - 1 * (pivotX_prev_high - pivotX_prev_low))
array.push(r3, pivotX_Median * 2 + (pivotX_prev_high - 2 * pivotX_prev_low))
array.push(s3, pivotX_Median * 2 - (2 * pivotX_prev_high - pivotX_prev_low))
array.push(r4, pivotX_Median * 3 + (pivotX_prev_high - 3 * pivotX_prev_low))
array.push(s4, pivotX_Median * 3 - (3 * pivotX_prev_high - pivotX_prev_low))
array.push(r5, pivotX_Median * 4 + (pivotX_prev_high - 4 * pivotX_prev_low))
array.push(s5, pivotX_Median * 4 - (4 * pivotX_prev_high - pivotX_prev_low))
fibonacci() =>
pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3
pivot_range = pivotX_prev_high - pivotX_prev_low
array.push(p, pivotX_Median)
array.push(r1, pivotX_Median + 0.382 * pivot_range)
array.push(s1, pivotX_Median - 0.382 * pivot_range)
array.push(r2, pivotX_Median + 0.618 * pivot_range)
array.push(s2, pivotX_Median - 0.618 * pivot_range)
array.push(r3, pivotX_Median + 1 * pivot_range)
array.push(s3, pivotX_Median - 1 * pivot_range)
woodie() =>
pivotX_Woodie_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_open * 2)/4
pivot_range = pivotX_prev_high - pivotX_prev_low
array.push(p, pivotX_Woodie_Median)
array.push(r1, pivotX_Woodie_Median * 2 - pivotX_prev_low)
array.push(s1, pivotX_Woodie_Median * 2 - pivotX_prev_high)
array.push(r2, pivotX_Woodie_Median + 1 * pivot_range)
array.push(s2, pivotX_Woodie_Median - 1 * pivot_range)
pivot_point_r3 = pivotX_prev_high + 2 * (pivotX_Woodie_Median - pivotX_prev_low)
pivot_point_s3 = pivotX_prev_low - 2 * (pivotX_prev_high - pivotX_Woodie_Median)
array.push(r3, pivot_point_r3)
array.push(s3, pivot_point_s3)
array.push(r4, pivot_point_r3 + pivot_range)
array.push(s4, pivot_point_s3 - pivot_range)
classic() =>
pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close)/3
pivot_range = pivotX_prev_high - pivotX_prev_low
array.push(p, pivotX_Median)
array.push(r1, pivotX_Median * 2 - pivotX_prev_low)
array.push(s1, pivotX_Median * 2 - pivotX_prev_high)
array.push(r2, pivotX_Median + 1 * pivot_range)
array.push(s2, pivotX_Median - 1 * pivot_range)
array.push(r3, pivotX_Median + 2 * pivot_range)
array.push(s3, pivotX_Median - 2 * pivot_range)
array.push(r4, pivotX_Median + 3 * pivot_range)
array.push(s4, pivotX_Median - 3 * pivot_range)
demark() =>
pivotX_Demark_X = pivotX_prev_high + pivotX_prev_low * 2 + pivotX_prev_close
if pivotX_prev_close == pivotX_prev_open
pivotX_Demark_X := pivotX_prev_high + pivotX_prev_low + pivotX_prev_close * 2
if pivotX_prev_close > pivotX_prev_open
pivotX_Demark_X := pivotX_prev_high * 2 + pivotX_prev_low + pivotX_prev_close
array.push(p, pivotX_Demark_X / 4)
array.push(r1, pivotX_Demark_X / 2 - pivotX_prev_low)
array.push(s1, pivotX_Demark_X / 2 - pivotX_prev_high)
camarilla() =>
pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3
pivot_range = pivotX_prev_high - pivotX_prev_low
array.push(p, pivotX_Median)
array.push(r1, pivotX_prev_close + pivot_range * 1.1 / 12.0)
array.push(s1, pivotX_prev_close - pivot_range * 1.1 / 12.0)
array.push(r2, pivotX_prev_close + pivot_range * 1.1 / 6.0)
array.push(s2, pivotX_prev_close - pivot_range * 1.1 / 6.0)
array.push(r3, pivotX_prev_close + pivot_range * 1.1 / 4.0)
array.push(s3, pivotX_prev_close - pivot_range * 1.1 / 4.0)
array.push(r4, pivotX_prev_close + pivot_range * 1.1 / 2.0)
array.push(s4, pivotX_prev_close - pivot_range * 1.1 / 2.0)
r5_val = pivotX_prev_high / pivotX_prev_low * pivotX_prev_close
array.push(r5, r5_val)
array.push(s5, 2 * pivotX_prev_close - r5_val)
calc_pivot() =>
if kind == TRADITIONAL
traditional()
else if kind == FIBONACCI
fibonacci()
else if kind == WOODIE
woodie()
else if kind == CLASSIC
classic()
else if kind == DEMARK
demark()
else if kind == CAMARILLA
camarilla()
resolution = get_pivot_resolution()
SIMPLE_DIVISOR = -1
custom_years_divisor = switch pivot_time_frame
BIYEARLY => 2
TRIYEARLY => 3
QUINQUENNIALLY => 5
DECENNIALLY => 10
=> SIMPLE_DIVISOR
calc_high(prev, curr) =>
if na(prev) or na(curr)
nz(prev, nz(curr, na))
else
math.max(prev, curr)
calc_low(prev, curr) =>
if not na(prev) and not na(curr)
math.min(prev, curr)
else
nz(prev, nz(curr, na))
calc_OHLC_for_pivot(custom_years_divisor) =>
if custom_years_divisor == SIMPLE_DIVISOR
[open, high, low, close, open[1], high[1], low[1], close[1], time[1], time_close]
else
var prev_sec_open = float(na)
var prev_sec_high = float(na)
var prev_sec_low = float(na)
var prev_sec_close = float(na)
var prev_sec_time = int(na)
var curr_sec_open = float(na)
var curr_sec_high = float(na)
var curr_sec_low = float(na)
var curr_sec_close = float(na)
if year(time_close) % custom_years_divisor == 0
curr_sec_open := open
curr_sec_high := high
curr_sec_low := low
curr_sec_close := close
prev_sec_high := high[1]
prev_sec_low := low[1]
prev_sec_close := close[1]
prev_sec_time := time[1]
for i = 2 to custom_years_divisor
prev_sec_open := nz(open[i], prev_sec_open)
prev_sec_high := calc_high(prev_sec_high, high[i])
prev_sec_low := calc_low(prev_sec_low, low[i])
prev_sec_time := nz(time[i], prev_sec_time)
[curr_sec_open, curr_sec_high, curr_sec_low, curr_sec_close, prev_sec_open, prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time, time_close]
[sec_open, sec_high, sec_low, sec_close, prev_sec_open, prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time, sec_time] = request.security(syminfo.tickerid, resolution, calc_OHLC_for_pivot(custom_years_divisor), lookahead = barmerge.lookahead_on)
sec_open_gaps_on = request.security(syminfo.tickerid, resolution, open, gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
is_change_years = custom_years_divisor > 0 and ta.change(time(resolution)) and year(time_close) % custom_years_divisor == 0
var is_change = false
var uses_current_bar = timeframe.isintraday and kind == WOODIE
var change_time = int(na)
is_time_change = (ta.change(time(resolution)) and custom_years_divisor == SIMPLE_DIVISOR) or is_change_years
if is_time_change
change_time := time
var start_time = time
var was_last_premarket = false
var start_calculate_in_premarket = false
is_last_premarket = barstate.islast and session.ispremarket and time_close > sec_time and not was_last_premarket
if is_last_premarket
was_last_premarket := true
start_calculate_in_premarket := true
if session.ismarket
was_last_premarket := false
without_time_change = barstate.islast and array.size(arr_time) == 0
is_can_calc_pivot = (not uses_current_bar and is_time_change and session.ismarket) or (ta.change(sec_open) and not start_calculate_in_premarket) or is_last_premarket or (uses_current_bar and not na(sec_open_gaps_on)) or without_time_change
enough_bars_for_calculate = prev_sec_time >= start_time or is_daily_based
if is_can_calc_pivot and enough_bars_for_calculate
if array.size(arr_time) == 0 and is_daily_based
pivotX_prev_open := prev_sec_open[1]
pivotX_prev_high := prev_sec_high[1]
pivotX_prev_low := prev_sec_low[1]
pivotX_prev_close := prev_sec_close[1]
pivotX_open := sec_open[1]
pivotX_high := sec_high[1]
pivotX_low := sec_low[1]
array.push(arr_time, start_time)
calc_pivot()
if is_daily_based
if is_last_premarket
pivotX_prev_open := sec_open
pivotX_prev_high := sec_high
pivotX_prev_low := sec_low
pivotX_prev_close := sec_close
pivotX_open := open
pivotX_high := high
pivotX_low := low
else
pivotX_prev_open := prev_sec_open
pivotX_prev_high := prev_sec_high
pivotX_prev_low := prev_sec_low
pivotX_prev_close := prev_sec_close
pivotX_open := sec_open
pivotX_high := sec_high
pivotX_low := sec_low
else
pivotX_prev_high := pivotX_high
pivotX_prev_low := pivotX_low
pivotX_prev_open := pivotX_open
pivotX_prev_close := close[1]
pivotX_open := open
pivotX_high := high
pivotX_low := low
if barstate.islast and not is_change and array.size(arr_time) > 0 and not without_time_change
array.set(arr_time, array.size(arr_time) - 1, change_time)
else if without_time_change
array.push(arr_time, start_time)
else
array.push(arr_time, nz(change_time, time))
calc_pivot()
if array.size(arr_time) > look_back
if array.size(arr_time) > 0
array.shift(arr_time)
if array.size(p) > 0 and p_show
array.shift(p)
if array.size(r1) > 0 and r1_show
array.shift(r1)
if array.size(s1) > 0 and s1_show
array.shift(s1)
if array.size(r2) > 0 and r2_show
array.shift(r2)
if array.size(s2) > 0 and s2_show
array.shift(s2)
if array.size(r3) > 0 and r3_show
array.shift(r3)
if array.size(s3) > 0 and s3_show
array.shift(s3)
if array.size(r4) > 0 and r4_show
array.shift(r4)
if array.size(s4) > 0 and s4_show
array.shift(s4)
if array.size(r5) > 0 and r5_show
array.shift(r5)
if array.size(s5) > 0 and s5_show
array.shift(s5)
is_change := true
else if not is_daily_based
pivotX_high := math.max(pivotX_high, high)
pivotX_low := math.min(pivotX_low, low)
if barstate.islast and not is_daily_based and array.size(arr_time) == 0
runtime.error("Not enough intraday data to calculate Pivot Points. Lower the Pivots Timeframe or turn on the 'Use Daily-based Values' option in the indicator settings.")
if barstate.islast and array.size(arr_time) > 0 and is_change
is_change := false
if custom_years_divisor > 0
last_pivot_time = array.get(arr_time, array.size(arr_time) - 1)
pivot_timeframe = str.tostring(12 * custom_years_divisor) + "M"
estimate_pivot_time = last_pivot_time + timeframe.in_seconds(pivot_timeframe) * 1000
array.push(arr_time, estimate_pivot_time)
else
array.push(arr_time, time_close(resolution))
for i = 0 to array.size(lines) - 1
if array.size(lines) > 0
line.delete(array.shift(lines))
if array.size(lines) > 0
label.delete(array.shift(labels))
for i = 0 to array.size(arr_time) - 2
if array.size(p) > 0 and p_show
draw_line(i, p, p_color)
draw_label(i, array.get(p, i), "P", p_color)
if array.size(r1) > 0 and r1_show
draw_line(i, r1, r1_color)
draw_label(i, array.get(r1, i), "R1", r1_color)
if array.size(s1) > 0 and s1_show
draw_line(i, s1, s1_color)
draw_label(i, array.get(s1, i), "S1", s1_color)
if array.size(r2) > 0 and r2_show
draw_line(i, r2, r2_color)
draw_label(i, array.get(r2, i), "R2", r2_color)
if array.size(s2) > 0 and s2_show
draw_line(i, s2, s2_color)
draw_label(i, array.get(s2, i), "S2", s2_color)
if array.size(r3) > 0 and r3_show
draw_line(i, r3, r3_color)
draw_label(i, array.get(r3, i), "R3", r3_color)
if array.size(s3) > 0 and s3_show
draw_line(i, s3, s3_color)
draw_label(i, array.get(s3, i), "S3", s3_color)
if array.size(r4) > 0 and r4_show
draw_line(i, r4, r4_color)
draw_label(i, array.get(r4, i), "R4", r4_color)
if array.size(s4) > 0 and s4_show
draw_line(i, s4, s4_color)
draw_label(i, array.get(s4, i), "S4", s4_color)
if array.size(r5) > 0 and r5_show
draw_line(i, r5, r5_color)
draw_label(i, array.get(r5, i), "R5", r5_color)
if array.size(s5) > 0 and s5_show
draw_line(i, s5, s5_color)
draw_label(i, array.get(s5, i), "S5", s5_color)
|
Exponential Top and Bottom Finder | https://www.tradingview.com/script/euf83scu-Exponential-Top-and-Bottom-Finder/ | spacekadet17 | https://www.tradingview.com/u/spacekadet17/ | 181 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spacekadet17
//
//@version=5
indicator(title="Exponential Top and Bottom Finder", shorttitle="ETPF", format=format.price, precision=4, overlay = true)
// time frame?
tfc = 1
if timeframe.isdaily
tfc := 24
// indicators: price normalized alma, its 1st and 2nd derivatives and stochastic versions
ema = ta.alma(close,140,1.1,6)
dema = (ema-ema[1])/ema
stodema = ta.ema(ta.ema(ta.stoch(dema,dema,dema,100),3),3)
d2ema = ta.ema(dema-dema[1],21)
stod2ema = ta.ema(ta.ema(ta.stoch(d2ema,d2ema,d2ema,100),3),3)
ind = (close-ta.ema(close,120*24/tfc))/close
heat = ta.ema(ta.stoch(ind,ind,ind,120*24/tfc),3)
index = ta.ema(heat,7*24/tfc)
condpeak = stodema>stod2ema and dema>0 and d2ema<0.0001 and stodema>50 and stod2ema>50 and stod2ema<80 and index>70 and ind>0.2 ? true : false
condbottom = stodema<stod2ema and dema<0 and d2ema>-0.0005 and stodema<40 and stod2ema>30 and index<35 and ind<-0.2 ? true : false
plotshape(condpeak, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.tiny)
plotshape(condbottom, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.tiny)
|
Bollinger Band Width Percentile - Multi Time Frame | https://www.tradingview.com/script/uOPkVxXE-Bollinger-Band-Width-Percentile-Multi-Time-Frame/ | EltAlt | https://www.tradingview.com/u/EltAlt/ | 172 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EltAlt
//@version=5
// -----------------------------------------------------------------------------
//
// Title: Bollinger Band Width Percentile - Multi Time Frame
// Authors: @EltAlt
// Revision: v1.02
// Date: 06-June-2022
//
// Description
// =============================================================================
// My plan with this indicator was when trading at short timeframes, to modify my expectations on the potential impact of short term volatility based on volatility in
// longer timeframes, and when trading on longer timeframes to attempt to find an optimal entry point based on shorter term volatility.
//
// =============================================================================
//
// I would gladly accept any suggestions to improve the script.
// If you encounter any problems please share them with me.
//
// Thanks to The_Caretaker for "Bollinger Band Width Percentile" upon which this multi time frame version is based.
//
// Changlog
// =============================================================================
//
// 1.00 • First public release
// 1.01 • Added bar color options
// • Cleaned up the inputs
// 1.02 • Added Auto timeframe setting.
//
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
//
indicator('Bollinger Band Width Percentile - Multi Time Frame', 'BBWP MTF',
overlay=false,
format=format.percent,
precision=2,
max_bars_back = 1000)
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Inputs
chartTicker=syminfo.tickerid
charttf = timeframe.period
source = input.source (defval = close, title ='Price Source', inline='1', group='General Properties')
basistype = input.string (defval = 'SMA', title =' BBPW Basis Type', options=['SMA', 'EMA', 'VWMA'], inline='1', group='General Properties')
stfalerttrans = input.int (defval = 50, minval = 1, maxval = 100, title = 'Alert Transparency: Single TF', inline='2', group='General Properties')
alerttrans = input.int (defval = 50, minval = 1, maxval = 100, title = 'All TF', inline='2', group='General Properties')
barcolors = input.string (defval = 'Standard', title ='Price Chart Bar Colors', options=['Standard', 'From Short TF BBWP', 'From Medium TF BBWP', 'From Long TF BBWP'], inline='3', group='General Properties')
// Short Time Frame BBWP
bbwpse = input.bool(defval = true, title ='Enable', inline='1', group= 'Short Time Frame BBWP')
bbwpstf = input.string(defval = 'Chart', title =' Timeframe', inline='1', group= 'Short Time Frame BBWP', options = ['Chart', '1', '3', '5', '10', '15', '30', '45', '60', '120', '180', '240', '720', 'D', '3D', '5D', 'W'])
bbwpsle = input.int (defval = 13, title = 'Length', minval=1, inline='2', group='Short Time Frame BBWP')
bbwpslk = input.int (defval = 252, title = ' Lookback', minval=1, inline='2', group='Short Time Frame BBWP')
bbwpsmal = input.int(defval = 5, title ='MA', inline='3', group= 'Short Time Frame BBWP')
bbwpsmat = input.string (defval = 'SMA', title = ' MA Type', options=['SMA', 'EMA', 'VWMA'], inline='3', group='Short Time Frame BBWP')
bbwpspt = input.string (defval = 'Solid Line', title = 'Plot Type', options=['Solid Line', 'Background', 'Hidden', 'Average S M', 'Average S L', 'Average M L', 'Average S M L'], inline='4', group='Short Time Frame BBWP')
bbwpspw = input.int (defval = 2, title= ' Width', minval=1, maxval=14, inline='4', group='Short Time Frame BBWP')
bbwpspc = input.string (defval = 'Color from Medium', title = 'Plot Color', options=['RGB Spectrum', 'RB Spectrum', 'RG Spectrum', 'Solid Color', 'Color from Medium', 'Color from Long'], inline='5', group='Short Time Frame BBWP')
bbwpsppc = input.color (defval = #FFFF00, title = ' Solid Color', inline='5', group='Short Time Frame BBWP')
bbwpsmapt = input.string (defval = 'Solid Line', title = 'MA Plot', options=['Solid Line', 'Hidden'], inline='6', group='Short Time Frame BBWP')
bbwpsmapw = input.int (defval = 1, title = 'MA Width', inline='6', group='Short Time Frame BBWP')
bbwpsmappc = input.color (defval = #FFFFFFFF, title = 'MA Color', inline='6', group='Short Time Frame BBWP')
shortalertstip = 'Short timeframe alerts will appear in the bottom third of the chart. If enforced by all other enabled alerts a full length alert will plot.'
shortalerts = input.bool (defval = true, title = 'Short TF Alerts', inline='a1', group='Short Time Frame BBWP', tooltip = shortalertstip)
shtalertsma = input.bool (defval = true, title = 'MA Filter', inline='a1', group='Short Time Frame BBWP')
shtalertsri = input.bool (defval = false, title = 'and', inline='a1', group='Short Time Frame BBWP')
shtalertsripc = input.float (defval = 1, maxval=100, minval=0, title = 'Moving %', inline='a1', group='Short Time Frame BBWP', step=0.1)
shortupperlevel = input.int ( 98, 'Short Term Extreme High', minval=1, inline='a3', group='Short Time Frame BBWP')
shortlowerlevel = input.int ( 2, 'Low', minval=1, inline='a3', group='Short Time Frame BBWP')
// Medium Time Frame BBWP
bbwpme = input.bool(defval = true, title ='Enable', inline='1', group= 'Medium Time Frame BBWP')
bbwpmtf = input.string(defval = 'Auto', title =' Timeframe', inline='1', group= 'Medium Time Frame BBWP', options = ['Auto', '5', '10', '15', '30', '45', '60', '120', '180', '240', '720', 'D', '3D', '5D', 'W', '2W'])
bbwpmle = input.int (defval = 13, title = 'Length', minval=1, inline='2', group='Medium Time Frame BBWP')
bbwpmlk = input.int (defval = 252, title = ' Lookback', minval=1, inline='2', group='Medium Time Frame BBWP')
bbwpmmal = input.int(defval = 5, title ='MA', inline='3', group= 'Medium Time Frame BBWP')
bbwpmmat = input.string (defval = 'SMA', title = ' MA Type', options=['SMA', 'EMA', 'VWMA'], inline='3', group='Medium Time Frame BBWP')
bbwpmpt = input.string (defval = 'Hidden', title = 'Plot Type', options=['Solid Line', 'Hidden', 'Average S M', 'Average S L', 'Average M L', 'Average S M L'], inline='4', group='Medium Time Frame BBWP')
bbwpmpw = input.int (defval = 2, title= ' Width', minval=1, maxval=4, inline='4', group='Medium Time Frame BBWP')
bbwpmpc = input.string (defval = 'RG Spectrum', title = 'Plot Color', options=['RGB Spectrum', 'RB Spectrum', 'RG Spectrum', 'Solid Color', 'Color from Long'], inline='5', group='Medium Time Frame BBWP')
bbwpmppc = input.color (defval = #FFFF00, title = ' Solid Color', inline='5', group='Medium Time Frame BBWP')
bbwpmmapt = input.string (defval = 'Hidden', title = 'MA Plot', options=['Solid Line', 'Hidden'], inline='6', group='Medium Time Frame BBWP')
bbwpmmappc = input.color (defval = #FFFFFFCF, title = 'MA Color', inline='6', group='Medium Time Frame BBWP')
bbwpmmapw = input.int (defval = 1, title = 'MA Width', inline='6', group='Medium Time Frame BBWP')
mediumalertstip = 'Medium timeframe alerts will appear in the middle third of the chart. If enforced by all other enabled alerts a full length alert will plot.'
mediumalerts = input.bool (defval = true, title = 'Medium TF Alerts', inline='m', group='Medium Time Frame BBWP', tooltip = mediumalertstip)
medalertsma = input.bool (defval = true, title = 'MA Filter', inline='m', group='Medium Time Frame BBWP')
medalertsri = input.bool (defval = false, title = 'and', inline='m', group='Medium Time Frame BBWP')
medalertsripc = input.float (defval = 1, maxval=100, minval=0, title = 'Moving %', inline='m', group='Medium Time Frame BBWP', step=0.1)
mediumupperlevel = input.int ( 98, 'Medium Term Extreme High', minval=1, inline='m2', group='Medium Time Frame BBWP')
mediumlowerlevel = input.int ( 2, 'Low', minval=1, inline='m2', group='Medium Time Frame BBWP')
// Long Time Frame BBWP
bbwple = input.bool(defval = true, title ='Enable', inline='1', group= 'Long Time Frame BBWP')
bbwpltf = input.string(defval = 'Auto', title =' Timeframe', inline='1', group= 'Long Time Frame BBWP', options = ['Auto', '5', '10', '15', '30', '45', '60', '120', '180', '240', '720', 'D', '3D', '5D', 'W', '2W', 'M'])
bbwplle = input.int (defval = 13, title = 'Length', minval=1, inline='2', group='Long Time Frame BBWP')
bbwpllk = input.int (defval = 252, title = ' Lookback', minval=1, inline='2', group='Long Time Frame BBWP')
bbwplmal = input.int(defval = 5, title ='MA', inline='3', group= 'Long Time Frame BBWP')
bbwplmat = input.string (defval = 'SMA', title = ' MA Type', options=['SMA', 'EMA', 'VWMA'], inline='3', group='Long Time Frame BBWP')
bbwplpt = input.string (defval = 'Background', title = 'Plot Type', options=['Solid Line', 'Background', 'Hidden', 'Average S M', 'Average S L', 'Average M L', 'Average S M L'], inline='4', group='Long Time Frame BBWP')
bbwplpw = input.int (defval = 2, title= ' Width', minval=1, maxval=4, inline='4', group='Long Time Frame BBWP')
bbwplpc = input.string (defval = 'RG Spectrum', title = 'Plot Color', options=['RGB Spectrum', 'RB Spectrum', 'RG Spectrum', 'Solid Color'], inline='5', group='Long Time Frame BBWP')
bbwplppc = input.color (defval = #FFFF00, title = ' Solid Color', inline='5', group='Long Time Frame BBWP')
bbwplmapt = input.string (defval = 'Hidden', title = 'MA Plot', options=['Solid Line', 'Hidden'], inline='6', group='Long Time Frame BBWP')
bbwplmappc = input.color (defval = #FFFFFF99, title = 'MA Color', inline='6', group='Long Time Frame BBWP')
bbwplmapw = input.int (defval = 1, title = 'MA Width', inline='6', group='Long Time Frame BBWP')
bbwplbga = input.int (defval = 75, maxval=100, minval=0, title = 'Background Transparency Above MA', inline='7', group='Long Time Frame BBWP')
bbwplbgb = input.int (defval = 90, maxval=100, minval=0, title = 'Below MA', inline='7', group='Long Time Frame BBWP')
linebackground = input.bool (defval = true, title = 'Highlight Lines in Background Mode', inline = '8', group = 'Long Time Frame BBWP')
highlightcolor = input.color (defval = #00000088, title = 'With Color', inline = '8', group = 'Long Time Frame BBWP')
longalertstip = 'Long timeframe alerts will appear in the top third of the chart. If enforced by all other enabled alerts a full length alert will plot.'
longalerts = input.bool (defval = true, title = 'Long TF Alerts', inline='l', group='Long Time Frame BBWP', tooltip = longalertstip)
lngalertsma = input.bool (defval = true, title = 'MA Filter', inline='l', group='Long Time Frame BBWP')
lngalertsri = input.bool (defval = false, title = 'and', inline='l', group='Long Time Frame BBWP')
lngalertsripc = input.float (defval = 1, maxval=100, minval=0, title = 'Moving %', inline='l', group='Long Time Frame BBWP', step=0.1)
longupperlevel = input.int ( 98, 'Long Term Extreme High', minval=1, inline='l2', group='Long Time Frame BBWP')
longlowerlevel = input.int ( 2, 'Low', minval=1, inline='l2', group='Long Time Frame BBWP')
backtesttip = 'You can use the Backtest Signal to simulate trades in a backtester, set the values here to match what your backtester is expecting.\nAlert values are totaled and plotted to display.none, if you need to see them for testing change the Style Settings for the Backtest Signal plot.'
hghalertval = input.float (defval = -3, title = 'All Timeframes Alert Value High', inline='1', group='Backtestable Alerts', tooltip='backtesttip')
lowalertval = input.float (defval = 3, title = 'Low', inline='1', group='Backtestable Alerts')
hghalertshtval = input.float (defval = -2, title = 'Short Term Alert Value High', inline='2', group='Backtestable Alerts')
lowalertshtval = input.float (defval = 2, title = 'Low', inline='2', group='Backtestable Alerts')
hghalertmedval = input.float (defval = -1, title = 'Medium Term Alert Value High', inline='3', group='Backtestable Alerts')
lowalertmedval = input.float (defval = 1, title = 'Low', inline='3', group='Backtestable Alerts')
hghalertlngval = input.float (defval = -1, title = 'Long Term Alert Value High', inline='4', group='Backtestable Alerts')
lowalertlngval = input.float (defval = 1, title = 'Low', inline='4', group='Backtestable Alerts')
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Functions
f_ma (_type, _source, _length) => _type == 'VWMA' ? ta.vwma ( _source, _length ) : _type == 'EMA' ? ta.ema ( _source, _length ) : ta.sma ( _source, _length )
f_mas (_type, _source, _length, _tf) => request.security(chartTicker, _tf, f_ma ( _type, _source, _length ))
f_bbw(_src, _length, _type) =>
float basis = f_ma ( _type, _src, _length )
float dev = ta.stdev(_src, _length)
_bbw = ((basis + dev) - (basis - dev)) / basis
//_bbw = ta.bbw(_src,_length,1)
f_percentrank(_source, _lookback) =>
_count = 0.0
for _i = 1 to _lookback by 1
_count += ( _source[_i] > _source ? 0 : 1 )
_count
_return = ( _count / _lookback) * 100
f_bbwp ( _source, _length, _lookback, _type ) =>
_bbw = f_bbw(_source, _length, _type)
_len = bar_index < _lookback ? bar_index : _lookback
_bbwp = f_percentrank (_bbw, _len)
_return = bar_index >= _length ? _bbwp : na
f_bbwps(_length, _lookback, _tf) => float _bbw = request.security(chartTicker, _tf, f_bbwp(source, _length, _lookback, basistype))
f_plotaverages (_type, _S, _M, _L) =>
switch _type
'Average S M' => (_S + _M) / 2
'Average S L' => (_S + _L) / 2
'Average M L' => (_M + _L) / 2
'Average S M L' => (_S + _M + _L) / 3
f_color (_type, _solidcolor, _percent) =>
_color = switch _type
'RGB Spectrum' => _percent >= 50 ? color.from_gradient(_percent, 50, 100, #0AFF00, #FF2900): color.from_gradient(_percent, 0, 49, #0000FF, #0AFF00)
'RB Spectrum' => color.from_gradient(_percent, 0, 100, #0000FF, #FF2900)
'RG Spectrum' => color.from_gradient(_percent, 0, 100, #00FF00, #FF0000)
'Solid Line' => _solidcolor
'Solid Color' => _solidcolor
'Background' => color.from_gradient(_percent, 0, 100, #00FF00, #FF0000)
'Hidden' => na
f_hghalert (_source, _level, _mafilter, _movingaverage, _rising, _percent) =>
_alert = _source > _level ?
_mafilter ?
_source < _movingaverage ?
_rising ?
_source < (_source[1] * (1 - _percent/100)) ? true
: false
: true
: false
: true
: false
f_tfhghalert (_tf, _source, _level, _mafilter, _movingaverage, _rising, _percent) =>
_alert = request.security(chartTicker, _tf, f_hghalert (_source, _level, _mafilter, _movingaverage, _rising, _percent))
f_lowalert (_source, _level, _mafilter, _movingaverage, _rising, _percent) =>
_alert = _source < _level ?
_mafilter ?
_source > _movingaverage ?
_rising ?
_source > (_source[1] * (1 + _percent/100)) ? true
: false
: true
: false
: true
: false
f_tflowalert (_tf, _source, _level, _mafilter, _movingaverage, _rising, _percent) =>
_alert = request.security(chartTicker, _tf, f_lowalert (_source, _level, _mafilter, _movingaverage, _rising, _percent))
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Logic
bbwpstfc = bbwpstf == 'Chart' ? charttf : bbwpstf
bbwpmtfc = bbwpmtf == 'Auto' ?
charttf == '1' ? '5' :
charttf == '3' ? '10' :
charttf == '5' ? '15' :
charttf == '10' ? '30' :
charttf == '15' ? '60' :
charttf == '30' ? '120' :
charttf == '45' ? '120' :
charttf == '60' ? '240' :
charttf == '120' ? '480' :
charttf == '180' ? '720' :
charttf == '240' ? 'D' :
charttf == '720' ? 'D' :
charttf == 'D' ? '3D' :
charttf == '3D' ? 'W' :
charttf == '5D' ? '2W' :
charttf == 'W' ? 'M' :
na :
bbwpmtf
bbwpltfc = bbwpltf == 'Auto' ?
charttf == '1' ? '15' :
charttf == '3' ? '30' :
charttf == '5' ? '45' :
charttf == '10' ? '120' :
charttf == '15' ? '240' :
charttf == '30' ? '480' :
charttf == '45' ? '720' :
charttf == '60' ? 'D' :
charttf == '120' ? '2D' :
charttf == '180' ? '3D' :
charttf == '240' ? '4D' :
charttf == '720' ? '5D' :
charttf == 'D' ? 'W' :
charttf == '3D' ? '2W' :
charttf == '5D' ? 'M' :
charttf == 'W' ? '2M' :
na :
bbwpltf
bbwps = bbwpse ? bbwpstf == 'Chart' ? f_bbwp(source, bbwpsle, bbwpslk, basistype) : f_bbwps(bbwpsle, bbwpslk, bbwpstfc) : na
bbwpm = bbwpme ? f_bbwps(bbwpmle, bbwpmlk, bbwpmtfc) : na
bbwpl = bbwple ? f_bbwps(bbwplle, bbwpllk, bbwpltfc) : na
bbwpsplot = bbwpspt == 'Average S M'
or bbwpspt == 'Average S L'
or bbwpspt == 'Average M L'
or bbwpspt == 'Average S M L'
? f_plotaverages (bbwpspt, bbwps, bbwpm, bbwpl)
: bbwps
bbwpmplot = bbwpmpt == 'Average S M'
or bbwpmpt == 'Average S L'
or bbwpmpt == 'Average M L'
or bbwpmpt == 'Average S M L'
? f_plotaverages (bbwpmpt, bbwps, bbwpm, bbwpl)
: bbwpm
bbwplplot = bbwplpt == 'Average S M'
or bbwplpt == 'Average S L'
or bbwplpt == 'Average M L'
or bbwplpt == 'Average S M L'
? f_plotaverages (bbwplpt, bbwps, bbwpm, bbwpl)
: bbwpl
bbwpsma = bbwpsmal > 1 ? bbwpstf == 'Chart' ? f_ma (bbwpsmat, bbwpsplot, bbwpsmal) : f_mas (bbwpsmat, bbwpsplot, bbwpsmal, bbwpstfc) : na
bbwpmma = bbwpmmal > 1 ? f_mas (bbwpmmat, bbwpmplot, bbwpmmal, bbwpmtfc) : na
bbwplma = bbwplmal > 1 ? f_mas (bbwplmat, bbwplplot, bbwplmal, bbwpltfc) : na
c_bbwps = bbwpspt != 'Hidden' ?
bbwpspc == 'Color from Medium' ?
bbwpme ? f_color(bbwpmpc, bbwpmppc, bbwpm)
: na
: bbwpspc == 'Color from Long' ?
bbwple ? f_color(bbwplpc, bbwplppc, bbwpl)
: na
: f_color(bbwpspc, bbwpsppc, bbwpsplot)
: na
c_bbwpm = bbwpmpt != 'Hidden' ?
bbwpmpc == 'Color from Long' ?
bbwple ? f_color(bbwplpc, bbwplppc, bbwpl)
: na
: f_color(bbwpmpc, bbwpmppc, bbwpm)
:na
c_bbwpl = bbwplpt != 'Hidden' ? f_color(bbwplpc, bbwplppc, bbwplplot) : na
plotbackground = bbwple and bbwplpt == 'Background' ? true : false
c_bbwpsma = bbwpspt == 'Hidden' or bbwpsmapt == 'Hidden' ? na : bbwpsmappc
c_bbwpmma = bbwpmpt == 'Hidden' or bbwpmmapt == 'Hidden' ? na : bbwpmmappc
c_bbwplma = bbwplpt == 'Hidden' or bbwplpt == 'Background' or bbwplmapt == 'Hidden' ? na : bbwplmappc
plotshortbackground = plotbackground and linebackground and bbwpspt != 'Hidden' ? bbwpsplot : na
plotmediumbackground = plotbackground and linebackground and bbwpmpt != 'Hidden' ? bbwpmplot : na
highcolor = color.red
lowcolor = bbwpspc == 'RGB Spectrum' or bbwpspc == 'RB Spectrum' ? color.blue : color.green
bool hghalertsht = false
bool lowalertsht = false
if bbwpstf == 'Chart'
hghalertsht := bbwpse and shortalerts ? f_hghalert (bbwpsplot, shortupperlevel, shtalertsma, bbwpsma, shtalertsri, shtalertsripc) : false
lowalertsht := bbwpse and shortalerts ? f_lowalert (bbwpsplot, shortlowerlevel, shtalertsma, bbwpsma, shtalertsri, shtalertsripc) : false
else
hghalertsht := bbwpse and shortalerts ? f_tfhghalert (bbwpstfc, bbwpsplot, shortupperlevel, shtalertsma, bbwpsma, shtalertsri, shtalertsripc) : false
lowalertsht := bbwpse and shortalerts ? f_tflowalert (bbwpstfc, bbwpsplot, shortlowerlevel, shtalertsma, bbwpsma, shtalertsri, shtalertsripc) : false
hghalertmed = bbwpme and mediumalerts ? f_tfhghalert (bbwpmtfc, bbwpmplot, mediumupperlevel, medalertsma, bbwpmma, medalertsri, medalertsripc) : false
lowalertmed = bbwpme and mediumalerts ? f_tflowalert (bbwpmtfc, bbwpm, mediumlowerlevel, medalertsma, bbwpmma, medalertsri, medalertsripc) : false
hghalertlng = bbwple and longalerts ? f_tfhghalert (bbwpltfc, bbwplplot, longupperlevel, lngalertsma, bbwplma, lngalertsri, lngalertsripc) : false
lowalertlng = bbwple and longalerts ? f_tflowalert (bbwpltfc, bbwpl, longlowerlevel, lngalertsma, bbwplma, lngalertsri, lngalertsripc) :false
hghalert = ((bbwpse and shortalerts) or (bbwpme and mediumalerts) or (bbwple and longalerts))
and ( bbwpse and shortalerts ? hghalertsht : true )
and ( bbwpme and mediumalerts ? hghalertmed : true )
and ( bbwple and longalerts ? hghalertlng : true )
lowalert = ((bbwpse and shortalerts) or (bbwpme and mediumalerts) or (bbwple and longalerts))
and ( bbwpse and shortalerts ? lowalertsht : true )
and ( bbwpme and mediumalerts ? lowalertmed : true )
and ( bbwple and longalerts ? lowalertlng : true )
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Plots
bgcolor (plotbackground ? color.new(c_bbwpl, bbwplplot > bbwplma ? bbwplbga : bbwplbgb) : na)
barcolor (barcolors == 'From Short TF BBWP' ? f_color(bbwpspc, bbwpsppc, bbwps)
: barcolors == 'From Medium TF BBWP' ? f_color(bbwpmpc, bbwpmppc, bbwpm)
: barcolors == 'From Long TF BBWP' ? f_color(bbwplpc, bbwplppc, bbwpl)
: na)
p_bbwpsbk = plot ( plotshortbackground, 'BBWP Short Time Frame Background', highlightcolor, bbwpspw+3)
p_bbwpmbk = plot ( plotmediumbackground, 'BBWP Medium Time Frame Background', highlightcolor, bbwpmpw+3)
p_bbwps = plot ( bbwpsplot, 'BBWP Short Time Frame', c_bbwps, bbwpspw, plot.style_line)
p_bbwpsma = plot ( bbwpsma, 'BBWP Short MA', c_bbwpsma, bbwpsmapw, plot.style_line, 0 )
p_bbwpm = plot ( bbwpmplot, 'BBWP Medium Time Frame', c_bbwpm, bbwpmpw, plot.style_line)
p_bbwpmma = plot ( bbwpmma, 'BBWP Medium MA', c_bbwpmma, bbwpmmapw, plot.style_line, 0 )
p_bbwpl = plot ( plotbackground ? na : bbwplplot, 'BBWP Long Time Frame', c_bbwpl, bbwplpw, plot.style_line)
p_bbwplma = plot ( plotbackground ? na : bbwplma, 'BBWP Long MA', c_bbwplma, bbwplmapw, plot.style_line, 0 )
p_scaleHi = hline ( 100, 'Scale High', highcolor, hline.style_solid )
p_midLine = hline ( 50, 'Mid-Line', color.silver, hline.style_dashed )
p_scaleLo = hline ( 0, 'Scale Low', lowcolor, hline.style_solid )
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ============ Alerts
p_lowalertsht = plot ( lowalertsht ? 33 : na, 'Short Timeframe Low', color.new(lowcolor, stfalerttrans), 1, plot.style_columns, histbase=0)
p_lowalertmed = plot ( lowalertmed ? 66 : na, 'Medium Timeframe Low', color.new(lowcolor, stfalerttrans), 1, plot.style_columns, histbase=33)
p_lowalertlng = plot ( lowalertlng ? 100 : na, 'Long Timeframe Low', color.new(lowcolor, stfalerttrans), 1, plot.style_columns, histbase=66)
p_hghalertsht = plot ( hghalertsht ? 33 : na, 'Short Timeframe High', color.new(highcolor, stfalerttrans), 1, plot.style_columns, histbase=0)
p_hghalertmed = plot ( hghalertmed ? 66 : na, 'Medium Timeframe High', color.new(highcolor, stfalerttrans), 1, plot.style_columns, histbase=33)
p_hghalertlng = plot ( hghalertlng ? 100 : na, 'Long Timeframe High', color.new(highcolor, stfalerttrans), 1, plot.style_columns, histbase=66)
p_hghalertall = plot ( hghalert ? 100 : na, 'Extreme High', color.new(highcolor, alerttrans), 1, plot.style_columns, histbase=0)
p_lowalertall = plot ( lowalert ? 100 : na, 'Extreme Low', color.new(lowcolor, alerttrans), 1, plot.style_columns, histbase=0)
float alertlevel = 0
alertlevel += hghalert ? hghalertval : 0
alertlevel += lowalert ? lowalertval : 0
alertlevel += hghalertsht ? hghalertshtval : 0
alertlevel += lowalertsht ? lowalertshtval : 0
alertlevel += hghalertmed ? hghalertmedval : 0
alertlevel += lowalertmed ? lowalertmedval : 0
alertlevel += hghalertlng ? hghalertlngval : 0
alertlevel += lowalertlng ? lowalertlngval : 0
p_alertsignal = plot (alertlevel, 'Backtest Signal', style=plot.style_columns, display=display.none) |
Double RSI For Kate | https://www.tradingview.com/script/RY82Mtbz-Double-RSI-For-Kate/ | CaryKentGordon | https://www.tradingview.com/u/CaryKentGordon/ | 113 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CaryKentGordon
//@version=5
indicator("Double RSI KE")
//Get rsi
rsi1_ = ta.rsi (close, 25)
rsi2_ = ta.rsi(close, 100)
//plot rsi's
plot(rsi1_, "RSI1", rsi1_< rsi2_ ? color.red : color.green)
Rsi1_ = input(25, "RSI 1 Period")
plot(rsi2_, "RSI2", color.white)
Rsi2_ = input(100, "RSI 2 Period") |
Donchian Anchored Vwap + Handoffs | https://www.tradingview.com/script/p9vJ5m5s-Donchian-Anchored-Vwap-Handoffs/ | elScipio | https://www.tradingview.com/u/elScipio/ | 108 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aj7919
// Credit to trader dysrupt for their Anchored VWAP Hand-off script for the AVWAP handoff code
//@version=5
indicator("Donchian Anchored Vwap + Handoffs", shorttitle="DAVWAP 1.0", overlay=true)
/////////////////////////////////////////////////////////////////////////////// INPUTS
length = input.int(20, title = "Donchian Lookback", minval=1)
vws=input.source(high, "VWAP High Source")
vws2 = input.source(low, "VWAP Low Source")
avwaps = input.bool (true, "Display AVWAPS")
donc = input.bool (false, "Display Donchian Highs and Lows")
labels = input.bool (false, "Show High/Low Breaches Price Labels")
// COLOUR INPUTS
bull = input(color.new(color.green, 0), title='Bull Color')
bear = input(color.new(color.red, 0), title='Bear Color')
//basiscol = input(color.new(color.white, 50), title='Avg VWAP')
devcol = input(color.new(color.gray, 50), title='Average Color')
none = color.new(color.black,100)
/////////////////////////////////////////////////////////////////////////////// Determine Donchian Highs and Lows for initial AVWAP High and AVWAP Low
l = ta.lowest(length)
h = ta.highest(length)
basis = math.avg(h, l)
/////////////////////////////////////////////////////////////////////////////// INITIAL ANCHORED VWAP FROM HIGH
start = high >= h //ta.cross(high,h)
sumSrc = vws * volume
sumVol = volume
sumSrc := start ? sumSrc : sumSrc + sumSrc[1]
sumVol := start ? sumVol : sumVol + sumVol[1]
out1=sumSrc / sumVol
if start
labels == true ? label.new(bar_index, na, text=str.tostring(close), yloc=yloc.abovebar) : na
/////////////////////////////////////////////////////////////////////////////// VWAP HIGH HAND OFF 1
start2 = high >= out1 and high < h // start == false ? ta.cross(high,out1) : na
sumSrc2 = vws * volume
sumVol2 = volume
sumSrc2 := start2 ? sumSrc2 : sumSrc2 + sumSrc2[1]
sumVol2 := start2 ? sumVol2 : sumVol2 + sumVol2[1]
out2=sumSrc2 / sumVol2
/////////////////////////////////////////////////////////////////////////////// VWAP HIGH HAND OFF 2
start3 = high >= out2 and high < h // start == false ? ta.cross(high,out2) : na
sumSrc3 = vws * volume
sumVol3 = volume
sumSrc3 := start3 ? sumSrc3 : sumSrc3 + sumSrc3[1]
sumVol3 := start3 ? sumVol3 : sumVol3 + sumVol3[1]
out3=sumSrc3 / sumVol3
// ************** LOWER ANCHORS ******************************
/////////////////////////////////////////////////////////////////////////////// INITIAL ANCHORED VWAP FROM LOW
startlo = low <= l //ta.cross(low,l)
sumSrclo = vws2 * volume
sumVollo = volume
sumSrclo := startlo ? sumSrclo : sumSrclo + sumSrclo[1]
sumVollo := startlo ? sumVollo : sumVollo + sumVollo[1]
low1=sumSrclo / sumVollo
if startlo
labels == true ? label.new(bar_index, na, text=str.tostring(close), yloc=yloc.belowbar, style = label.style_label_up) : na
/////////////////////////////////////////////////////////////////////////////// VWAP LOW HAND OFF 1
startlo2 = low <= low1 and low > l // startlo == false ? ta.cross(low,low1) : na
sumSrclo2 = vws2 * volume
sumVollo2 = volume
sumSrclo2 := startlo2 ? sumSrclo2 : sumSrclo2 + sumSrclo2[1]
sumVollo2 := startlo2 ? sumVollo2 : sumVollo2 + sumVollo2[1]
low2=sumSrclo2 / sumVollo2
/////////////////////////////////////////////////////////////////////////////// VWAP LOW HAND OFF 2
startlo3 = low <= low2 and low > l //startlo == false ? ta.cross(low,low2) : na
sumSrclo3 = vws2 * volume
sumVollo3 = volume
sumSrclo3 := startlo3 ? sumSrclo3 : sumSrclo3 + sumSrclo3[1]
sumVollo3 := startlo3 ? sumVollo3 : sumVollo3 + sumVollo3[1]
low3=sumSrclo3 / sumVollo3
startlo4 = low <= low3 and low > l //startlo == false ? ta.cross(low,low2) : na
sumSrclo4 = vws2 * volume
sumVollo4 = volume
sumSrclo4 := startlo4 ? sumSrclo4 : sumSrclo4 + sumSrclo4[1]
sumVollo4 := startlo4 ? sumVollo4 : sumVollo4 + sumVollo4[1]
low4=sumSrclo4 / sumVollo4
startlo5 = low <= low4 and low > l //startlo == false ? ta.cross(low,low2) : na
sumSrclo5 = vws2 * volume
sumVollo5 = volume
sumSrclo5 := startlo5 ? sumSrclo5 : sumSrclo5 + sumSrclo5[1]
sumVollo5 := startlo5 ? sumVollo5 : sumVollo5 + sumVollo5[1]
low5=sumSrclo5 / sumVollo5
// // /////////////////////////////////////////////////////////////////////////////// CALCULATE VWAP AVERAGES
avg = math.avg(out1,out2,out3,low1,low2,low3) // Average of all VWAPS and Hand Offs
// /////////////////////////////////////////////////////////////////////////////// PLOT DONCHIAN HIGHS/LOWS
plot(h, "Low", linewidth=1, color= donc == true ? color.new(color.aqua, 50) : na )
plot(l, "High", linewidth=1, color= donc == true ? color.new(color.aqua, 50) : na )
// /////////////////////////////////////////////////////////////////////////////// AVWAP SENTIMENT COLOR CALCS
// AVWAPS ONLY
// UPPER VWAPS
avwapbull1 = close > out1
avwapcol1 = avwapbull1 == true ? na : bear
avwapbull2 = close > out2
avwapcol2 = avwapbull2 == true ? na : bear
avwapbull3 = close > out3
avwapcol3 = avwapbull3 == true ? na : bear
//LOWER VWAPS:
avwapbull6 = close > low1
avwapcol6 = avwapbull6 == true ? bull : na
avwapbull7 = close > low2
avwapcol7 = avwapbull7 == true ? bull : na
avwapbull8 = close > low3
avwapcol8 = avwapbull8 == true ? bull : na
allbasis = plot(avg, "VWAP Avg ALL", linewidth=1, style=plot.style_cross, color= devcol) // AVERAGE OF ALL VWAPS
// /////////////////////////////////////////////////////////////////////////////// PLOT AVWAPS
plot(out1, "AVWAP High", linewidth=2, style=plot.style_cross, color= avwaps == true ? avwapcol1 : none)
plot(out2, "AVWAP High H/O 1", linewidth=1, style=plot.style_cross, color= avwaps == true ? avwapcol2 : none)
plot(out3, "AVWAP High H/O 2", linewidth=1, style=plot.style_cross, color= avwaps == true ? avwapcol3 : none)
plot(low1, "AVWAP Low", linewidth=2, style=plot.style_cross, color= avwaps == true ? avwapcol6 : none)
plot(low2, "AVWAP Low H/O 1", linewidth=1, style=plot.style_cross, color= avwaps == true ? avwapcol7 : none)
plot(low3, "AVWAP Low H/O 2", linewidth=1, style=plot.style_cross, color= avwaps == true ? avwapcol8 : none)
|
Price Action Signals | https://www.tradingview.com/script/lLXCfNvs-Price-Action-Signals/ | sonnyparlin | https://www.tradingview.com/u/sonnyparlin/ | 117 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sonnyparlin
// 6/4/2022 Changed plot arrows
//@version=5
indicator("Price Action Signals", overlay=true)
upperTail = (high - close)
lowerTail = (open - low)
thePlot = (lowerTail-upperTail)
// cond1
// 1m chart = .1
// 5min chart =.15
// 15m char = .25
// 1 hour char = 1.00
// 1 day chart = 2.00
absStop = input.float(.25, step=0.1, title="How much price moves during one candle.")
cond1 = math.abs(open-close) < absStop
cond2Input = input.float(20, step=10, title="Length of candle wick must be x% the length of the candle body.")
// cond2
// 0.25, only show arrow if wick is at least 25% the length of the candle's body
cond2 = math.abs(lowerTail-upperTail) < (math.abs(close-open) * (cond2Input / 100))
// if (math.abs(close-open) > absStop)
// cond2 := false
days = input.int(20, step=1, title="Length for moving average")
// Only show bearish arrows if the price is above 20 day ma
cond3 = (lowerTail > upperTail and close > ta.rma(close, days))
// Only show bullish arrows if the price is below the 20 day ma
cond4 = (upperTail > lowerTail and close < ta.rma(close, days))
if (cond1 or cond2 or cond3 or cond4)
thePlot := 0
redPlot = thePlot
greenPlot = thePlot
if (lowerTail > upperTail)
redPlot:= 0
if (lowerTail < upperTail)
greenPlot:= 0
//plotarrow(thePlot, colorup = color.teal, colordown = color.orange)
plotshape(redPlot, style=shape.triangledown,
location=location.abovebar, color=color.red)
plotshape(greenPlot, style=shape.triangleup,
location=location.belowbar, color=color.green)
|
vWap Close | https://www.tradingview.com/script/SgupmYr8-vWap-Close/ | talby211 | https://www.tradingview.com/u/talby211/ | 90 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © talby211
//@version=5
indicator('vWap Close', overlay=true)
newDay = ta.change(time('D')) != 0
vwapClose = ta.valuewhen(newDay, ta.vwap[1], 0)
plot(ta.vwap, color=color.new(color.blue, 0))
plot(vwapClose, color=color.new(color.orange, 0))
|
SP Indicator | https://www.tradingview.com/script/zhe6EyHi-sp-indicator/ | Smoker024 | https://www.tradingview.com/u/Smoker024/ | 376 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Smoker024
//@version=5
indicator("SP Indicator", overlay=true)
ma(src, len) => ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))
BBMC = ma(close, 60)
rangema = ta.ema(ta.tr, 60)
upperk =BBMC + rangema * 0.2
lowerk = BBMC - rangema * 0.2
color_bar = close > upperk ? color.blue : close < lowerk ? color.fuchsia : color.gray
ExitHigh = ma(high, 15)
ExitLow = ma(low, 15)
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = ta.crossover(close, sslExit)
base_cross_Short = ta.crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na
plotarrow(codiff, colorup=color.blue, colordown=color.fuchsia,title="Exit Arrows", maxheight=20, offset=0)
plot(BBMC, color=color_bar, linewidth=4,title='MA Trendline')
alertcondition(codiff == 1, 'Long', 'Long Condition at {{close}}')
alertcondition(codiff == -1, 'Short', 'Short Condition at {{close}}')
plot(close)
|
Gann Swing Chart [One-Bar] | https://www.tradingview.com/script/R7VWnhIV-Gann-Swing-Chart-One-Bar/ | meomeo105 | https://www.tradingview.com/u/meomeo105/ | 858 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © meomeo105
//@version=5
indicator('Gann Swing V2', shorttitle='GSC2', overlay=true, max_lines_count=500)
//-----Input-------
customTF = input.timeframe(defval="",title = "Show Other TimeFrame")
GroupGann = "Gann"
showGann = input.bool(true, 'Show Gann/Style', group = GroupGann,inline = "Gann/Style")
lineGann = input.string(title="",options=['(─)', '(╌)', '(┈)'],defval='(╌)', group = GroupGann, inline = "Gann/Style")
lineStyleGann = lineGann == "(┈)" ? line.style_dotted : lineGann == "(╌)" ? line.style_dashed : line.style_solid
colorGann = input.color(color.white, 'Color/Width', group = GroupGann, inline = "Color/Width")
widthGann = input.int(defval=1,title = "",minval=1, step=1, group = GroupGann, inline = "Color/Width")
ignoreISB = input.bool(true, 'Ignore Inside Bar', group = GroupGann, inline = "ignoreISB")
GroupSGann = "Swing of Gann"
showSGann = input.bool(true, 'Show Swing/Style', group = GroupSGann, inline = "Swing/Style")
lineSGann = input.string(title="",options=["(─)", "(╌)", "(┈)"],defval="(─)", group = GroupSGann, inline = "Swing/Style")
lineStyleSGann = lineSGann == "(┈)" ? line.style_dotted : lineSGann == "(╌)" ? line.style_dashed : line.style_solid
colorSGann = input.color(color.aqua, 'Color/Width', group = GroupSGann, inline = "Color/Width")
widthSGann = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann, inline = "Color/Width")
showChoCh = input.bool(false, 'Show ChoCh', group = GroupSGann,inline = "Choch")
show2ChoCh = input.bool(true, 'Show 2Choch/Color', group = GroupSGann,inline = "2Choch")
color2Choch = input.color(color.aqua, '', group = GroupSGann,inline = "2Choch")
showLabel = input.bool(true, 'Show Label TimeFrame',group = GroupSGann)
//////////////////////////Global//////////////////////////
var arrayLineTemp = array.new_line()
// Converts a resolution expressed in minutes into a string usable by "security()"
f_resFromMinutes(_minutes) =>
_minutes < 1 ? str.tostring(math.round(_minutes*60)) + "S" :
_minutes < 60 ? str.tostring(math.round(_minutes)) + "m" :
_minutes < 1440 ? str.tostring(math.round(_minutes/60)) + "H" :
_minutes < 10080 ? str.tostring(math.round(math.min(_minutes / 1440, 7))) + "D" :
_minutes < 43800 ? str.tostring(math.round(math.min(_minutes / 10080, 4))) + "W" :
str.tostring(math.round(math.min(_minutes / 43800, 12))) + "M"
var arrayLineChoCh = array.new_line()
var label labelTF = label.new(time, close, text = "",color = color.new(showSGann ? colorSGann : colorGann,95), textcolor = showSGann ? colorSGann : colorGann,xloc = xloc.bar_time, textalign = text.align_left)
//////////////////////////Gann//////////////////////////
styleGann = showSGann ? line.style_dashed : line.style_solid
var arrayXGann = array.new_int(5,time)
var arrayYGann = array.new_float(5,close)
var arrayLineGann = array.new_line()
int drawLineGann = 0
secondCustomTF = request.security(syminfo.tickerid,customTF,timeframe.in_seconds(),lookahead=barmerge.lookahead_on)
_high = request.security(syminfo.tickerid,customTF,high,lookahead=barmerge.lookahead_on)
_low = request.security(syminfo.tickerid,customTF,low,lookahead=barmerge.lookahead_on)
_close = request.security(syminfo.tickerid,customTF,close,lookahead=barmerge.lookahead_on)
_open = request.security(syminfo.tickerid,customTF,open,lookahead=barmerge.lookahead_on)
highPrev = _high
lowPrev = _low
// drawLineGann => 2:Tiếp tục 1:Đảo chiều; // Outsidebar 2:Tiếp tục 3:Tiếp tục và Đảo chiều 4 : Đảo chiều 2 lần
drawLineGann := 0
if(_high[0] > highPrev[1] and _low[0] > lowPrev[1])
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(_high[0] > array.get(arrayYGann,0))
if(_high[0] <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high[0])
drawLineGann := 2
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
drawLineGann := 1
else if(_high[0] < highPrev[1] and _low[0] < lowPrev[1])
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
drawLineGann := 1
else
if(_low[0] < array.get(arrayYGann,0))
if(_low[0] >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low[0])
drawLineGann := 2
else if((_high[0] >= highPrev[1] and _low[0] < lowPrev[1]) or (_high[0] > highPrev[1] and _low[0] <= lowPrev[1]))
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(_high[0] >= array.get(arrayYGann,0) and array.get(arrayYGann,1) <= _low[0])
if(_high[0] <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high[0])
drawLineGann := 2
else if(_high[0] >= array.get(arrayYGann,0) and array.get(arrayYGann,1) >= _low[0])
if(_close < _open)
if(_high[0] <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
drawLineGann := 3
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
drawLineGann := 4
else if(array.get(arrayYGann,0) < array.get(arrayYGann,1))
if(_low[0] <= array.get(arrayYGann,0) and _high[0] <= array.get(arrayYGann,1))
if(_low[0] >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low[0])
drawLineGann := 2
else if(_low[0] <= array.get(arrayYGann,0) and _high[0] >= array.get(arrayYGann,1))
if(_close > _open)
if(_low[0] >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
drawLineGann := 3
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high[0])
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low[0])
drawLineGann := 4
else if((_high[0] <= highPrev[1] and _low[0] >= lowPrev[1]) and ignoreISB)
highPrev := highPrev[1]
lowPrev := lowPrev[1]
if(timeframe.in_seconds() < secondCustomTF and drawLineGann == 0)
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(array.get(arrayYGann,0) <= high)
array.set(arrayXGann, 0, time)
drawLineGann := 2
else
if(array.get(arrayYGann,0) >= low)
array.set(arrayXGann, 0, time)
drawLineGann := 2
if(showGann and timeframe.in_seconds() <= secondCustomTF)
if(drawLineGann == 2)
if(array.size(arrayLineGann) >0)
line.set_xy2(array.get(arrayLineGann,0),array.get(arrayXGann,0),array.get(arrayYGann,0))
else
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleGann))
else if(drawLineGann == 1)
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleGann))
else if(drawLineGann == 3)
if(array.size(arrayLineGann) >0)
line.set_xy2(array.get(arrayLineGann,0),array.get(arrayXGann,1),array.get(arrayYGann,1))
else
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,2),array.get(arrayYGann,2),array.get(arrayXGann,1),array.get(arrayYGann,1), color = colorGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleGann))
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleGann))
else if(drawLineGann == 4)
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,2),array.get(arrayYGann,2),array.get(arrayXGann,1),array.get(arrayYGann,1), color = colorGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleGann))
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleGann))
//////////////////////////Swing Gann//////////////////////////
var arrayXSGann = array.new_int(5,time)
var arrayYSGann = array.new_float(5,close)
var arrayLineSGann = array.new_line()
int drawLineSGann = 0
int drawLineSGann1 = 0
bool runCheckChoChSGann = false
runCheckChoChSGann := runCheckChoChSGann[1]
if(showSGann)
if(math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1)) < math.min(array.get(arrayYGann,0),array.get(arrayYGann,1)) or math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1)) > math.max(array.get(arrayYGann,0),array.get(arrayYGann,1)))
//Khởi tạo bắt đầu
drawLineSGann1 := 5
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
array.set(arrayYSGann, 0, array.get(arrayYGann,1))
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
// drawLineSGann kiểm tra điểm 1 => 13:Tiếp tục có sóng hồi // 12|19(reDraw):Tiếp tục không có sóng hồi // 14:Đảo chiều
if(array.get(arrayXGann,0) == array.get(arrayXGann,1))
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,2) and array.get(arrayYSGann,0) != array.get(arrayYGann,1) and ((array.get(arrayYGann,1) > array.get(arrayYGann,2) and array.get(arrayYSGann,0) > array.get(arrayYSGann,1)) or (array.get(arrayYGann,1) < array.get(arrayYGann,2) and array.get(arrayYSGann,0) < array.get(arrayYSGann,1))))
drawLineSGann1 := 12
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
array.set(arrayYSGann, 0, array.get(arrayYGann,1))
else if(array.get(arrayXSGann,0) <= array.get(arrayXGann,2))
if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,1) < array.get(arrayYSGann,1)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,1) > array.get(arrayYSGann,1)))
drawLineSGann1 := 14
runCheckChoChSGann := true
array.unshift(arrayXSGann,array.get(arrayXGann,1))
array.unshift(arrayYSGann,array.get(arrayYGann,1))
else if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,1) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,1) < array.get(arrayYSGann,0)))
drawLineSGann1 := 13
_max = math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_min = math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_max_idx = 0
_min_idx = 0
for i = 2 to array.size(arrayXGann)
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,i))
break
if(_min > array.get(arrayYGann,i))
_min := array.get(arrayYGann,i)
_min_idx := array.get(arrayXGann,i)
if(_max < array.get(arrayYGann,i))
_max := array.get(arrayYGann,i)
_max_idx := array.get(arrayXGann,i)
if(array.get(arrayYSGann,0) > array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_min_idx)
array.unshift(arrayYSGann,_min)
else if(array.get(arrayYSGann,0) < array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_max_idx)
array.unshift(arrayYSGann,_max)
array.unshift(arrayXSGann,array.get(arrayXGann,1))
array.unshift(arrayYSGann,array.get(arrayYGann,1))
if(timeframe.in_seconds() < secondCustomTF)
if(array.get(arrayYSGann,0) == array.get(arrayYGann,1) and array.get(arrayXSGann,0) != array.get(arrayXGann,1))
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
drawLineSGann1 := 19
if(timeframe.in_seconds() <= secondCustomTF)
if(drawLineSGann1 == 12 or drawLineSGann1 == 19)
if(array.size(arrayLineSGann) >0)
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,0),array.get(arrayYSGann,0))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann1 == 14)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann1 == 13)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGann,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
if(runCheckChoChSGann)
runCheckChoChSGann := false
// ChoCh Trường hợp chữ N ngược, chữ N
if((array.get(arrayYSGann,3) > array.get(arrayYSGann,2) and array.get(arrayYSGann,3) < array.get(arrayYSGann,1) and array.get(arrayYSGann,0) < array.get(arrayYSGann,2)) or (array.get(arrayYSGann,3) < array.get(arrayYSGann,2) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,2)))
alert(syminfo.ticker + " : " + timeframe.period + " => Swing of Gann ChoCh" + (array.get(arrayYSGann,0) > array.get(arrayYSGann,1) ? "+ ⇑" : "- ⇓"))
if(showChoCh)
array.unshift(arrayLineChoCh,line.new(x1= array.get(arrayXSGann,2) , y1=array.get(arrayYSGann,2),x2=array.get(arrayXSGann,0), y2=array.get(arrayYSGann,2),color = colorSGann,xloc = xloc.bar_time,style = line.style_dotted))
// ChoCh 2 Đầu Trường hợp chữ N ngược, chữ N
if(show2ChoCh and ((array.get(arrayYSGann,1) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1))))
line.set_width(array.get(arrayLineSGann,1),widthGann + 1)
line.set_style(array.get(arrayLineSGann,1),line.style_dashed)
line.set_color(array.get(arrayLineSGann,1),color2Choch)
// drawLineSGann kiểm tra điểm 0 => 3:Tiếp tục có sóng hồi // 2|9(reDraw):Tiếp tục không có sóng hồi // 4:Đảo chiều
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,1) and array.get(arrayYSGann,0) != array.get(arrayYGann,0) and ((array.get(arrayYGann,0) > array.get(arrayYGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,1)) or (array.get(arrayYGann,0) < array.get(arrayYGann,1) and array.get(arrayYSGann,0) < array.get(arrayYSGann,1))))
drawLineSGann := 2
array.set(arrayXSGann, 0, array.get(arrayXGann,0))
array.set(arrayYSGann, 0, array.get(arrayYGann,0))
else if(array.get(arrayXSGann,0) <= array.get(arrayXGann,1))
if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,0) < array.get(arrayYSGann,1)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,0) > array.get(arrayYSGann,1)))
drawLineSGann := 4
runCheckChoChSGann := true
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
else if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,0) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,0) < array.get(arrayYSGann,0)))
drawLineSGann := 3
_max = math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_min = math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_max_idx = 0
_min_idx = 0
for i = 1 to array.size(arrayXGann)
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,i))
break
if(_min > array.get(arrayYGann,i))
_min := array.get(arrayYGann,i)
_min_idx := array.get(arrayXGann,i)
if(_max < array.get(arrayYGann,i))
_max := array.get(arrayYGann,i)
_max_idx := array.get(arrayXGann,i)
if(array.get(arrayYSGann,0) > array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_min_idx)
array.unshift(arrayYSGann,_min)
else if(array.get(arrayYSGann,0) < array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_max_idx)
array.unshift(arrayYSGann,_max)
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
if(timeframe.in_seconds() < secondCustomTF)
if(array.get(arrayYSGann,0) == array.get(arrayYGann,0) and array.get(arrayXSGann,0) != array.get(arrayXGann,0))
array.set(arrayXSGann, 0, array.get(arrayXGann,0))
drawLineSGann := 9
if(timeframe.in_seconds() <= secondCustomTF)
if(drawLineSGann == 2 or drawLineSGann == 9)
if(array.size(arrayLineSGann) >0)
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,0),array.get(arrayYSGann,0))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann == 4)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
else if(drawLineSGann == 3)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGann,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthGann,style=lineStyleSGann))
if(runCheckChoChSGann)
runCheckChoChSGann := false
// ChoCh Trường hợp chữ N ngược, chữ N
if((array.get(arrayYSGann,3) > array.get(arrayYSGann,2) and array.get(arrayYSGann,3) < array.get(arrayYSGann,1) and array.get(arrayYSGann,0) < array.get(arrayYSGann,2)) or (array.get(arrayYSGann,3) < array.get(arrayYSGann,2) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,2)))
alert(syminfo.ticker + " : " + timeframe.period + " => Swing of Gann ChoCh" + (array.get(arrayYSGann,0) > array.get(arrayYSGann,1) ? "+ ⇑" : "- ⇓"))
if(showChoCh)
array.unshift(arrayLineChoCh,line.new(x1= array.get(arrayXSGann,2) , y1=array.get(arrayYSGann,2),x2=array.get(arrayXSGann,0), y2=array.get(arrayYSGann,2),color = colorSGann,xloc = xloc.bar_time,style = line.style_dotted))
// ChoCh 2 Đầu Trường hợp chữ N ngược, chữ N
if(show2ChoCh and ((array.get(arrayYSGann,1) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1))))
line.set_width(array.get(arrayLineSGann,1),widthGann+1)
line.set_style(array.get(arrayLineSGann,1),line.style_dashed)
line.set_color(array.get(arrayLineSGann,1),color2Choch)
///////////////////////Other//////////////////////////////////
if(timeframe.in_seconds() <= secondCustomTF)
if(showSGann)
if(showLabel and (barstate.islast or barstate.islastconfirmedhistory))
texLabel = timeframe.in_seconds() == secondCustomTF ? f_resFromMinutes(timeframe.in_seconds()/60) : f_resFromMinutes(secondCustomTF/60)
label.set_xy(labelTF,array.get(arrayXSGann,0),array.get(arrayYSGann,0))
label.set_text(labelTF,texLabel)
label.set_style(labelTF,array.get(arrayYSGann,0) < array.get(arrayYSGann,1) ? label.style_label_upper_right : label.style_label_lower_right)
else if(showGann)
if(showLabel and (barstate.islast or barstate.islastconfirmedhistory))
texLabel = timeframe.in_seconds() == secondCustomTF ? f_resFromMinutes(timeframe.in_seconds()/60) : f_resFromMinutes(secondCustomTF/60)
label.set_xy(labelTF,array.get(arrayXGann,0),array.get(arrayYGann,0))
label.set_text(labelTF,texLabel)
label.set_style(labelTF,array.get(arrayYGann,0) < array.get(arrayYGann,1) ? label.style_label_upper_right : label.style_label_lower_right)
if(showSGann and showGann and array.size(arrayLineGann) > 9 and array.size(arrayLineSGann) > 9 and drawLineGann != 2 and drawLineSGann != 2 and drawLineSGann != 9 and drawLineSGann != 12 and drawLineSGann != 19)
for i = 1 to 9
if(line.get_x1(array.get(arrayLineGann,i)) == line.get_x1(array.get(arrayLineSGann,0)) and line.get_y1(array.get(arrayLineGann,i)) == line.get_y1(array.get(arrayLineSGann,0)) and line.get_x2(array.get(arrayLineGann,i)) == line.get_x2(array.get(arrayLineSGann,0)) and line.get_y2(array.get(arrayLineGann,i)) == line.get_y2(array.get(arrayLineSGann,0)))
line.delete(array.get(arrayLineGann,i))
array.remove(arrayLineGann,i)
break
else if(line.get_x1(array.get(arrayLineGann,i)) == line.get_x1(array.get(arrayLineSGann,1)) and line.get_y1(array.get(arrayLineGann,i)) == line.get_y1(array.get(arrayLineSGann,1)) and line.get_x2(array.get(arrayLineGann,i)) == line.get_x2(array.get(arrayLineSGann,1)) and line.get_y2(array.get(arrayLineGann,i)) == line.get_y2(array.get(arrayLineSGann,1)))
line.delete(array.get(arrayLineGann,i))
array.remove(arrayLineGann,i)
break
else if(line.get_x1(array.get(arrayLineGann,i)) == line.get_x1(array.get(arrayLineSGann,2)) and line.get_y1(array.get(arrayLineGann,i)) == line.get_y1(array.get(arrayLineSGann,2)) and line.get_x2(array.get(arrayLineGann,i)) == line.get_x2(array.get(arrayLineSGann,2)) and line.get_y2(array.get(arrayLineGann,i)) == line.get_y2(array.get(arrayLineSGann,2)))
line.delete(array.get(arrayLineGann,i))
array.remove(arrayLineGann,i)
break |
Chaikin Volume Accumulator | https://www.tradingview.com/script/vk2zVcMS-Chaikin-Volume-Accumulator/ | TechnicusCapital | https://www.tradingview.com/u/TechnicusCapital/ | 17 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TechnicusCapital
//@version=5
indicator("Volume Accumulator")
VA = ta.cum((((close-low)/(high-low)) - 0.5) * 2 * volume)
plot(VA, color=color.white)
|
trailing_drawdown | https://www.tradingview.com/script/8Xjkf9XN-trailing-drawdown/ | palitoj_endthen | https://www.tradingview.com/u/palitoj_endthen/ | 46 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © palitoj_endthen
//@version=5
indicator(title = 'Trailing Drawdown', shorttitle = 'drawdown', overlay = false, scale = scale.right)
// input
src = input(defval = close, title = 'Source', group = 'Options', tooltip = 'Determines the source of input data, default to close')
viz_style = input.string(defval = 'Static', title = ' Type', group = 'Options', options = ['Static', 'Dynamic'], tooltip = 'Choose drawdown display type between static or dynamic')
show_level = input.bool(defval = true, title = 'Level', group = 'Lookback Period', tooltip = 'Determines whether to display current level, default to true', inline = 'f')
length = input.int(defval = 252, title = 'Length', minval = 100, maxval = 1000, group = 'Lookback Period', tooltip = 'Determines lookback period for compute trailing drawdown, default in a year', inline = 'f')
// drawdown
drawdown(src_, length_)=>
var peaks = array.new_float(length_)
var max_peaks = 0.0
for i = 1 to length_-1
if src_ > src_[i]
array.set(peaks, i, src_)
max_peaks := array.max(peaks)
dd = (src/max_peaks)-1
[max_peaks, dd]
[max_peaks, dd] = drawdown(src, length)
// visualize
p1 = plot(dd, color = viz_style == 'Static' ? color.new(color.red, 80) : na, style = plot.style_area)
p2 = plot(dd, color = viz_style == 'Static' ? color.new(color.orange, 50) : na, style = plot.style_line, linewidth = 2)
p3 = plot(viz_style == 'Dynamic' ? max_peaks : 0, color = viz_style == 'Dynamic' ? color.navy : na)
p4 = plot(viz_style == 'Dynamic' ? src : 0, color = viz_style == 'Dynamic' ? color.new(color.orange, 50) : na)
fill(p3, p4, color = viz_style == 'Dynamic' ? color.new(color.red, 80) : na)
// additional shorter timeframe
[pp_month, dd_month] = drawdown(src, (length/12))
p5 = plot(viz_style == 'Dynamic' ? pp_month : 0, color = viz_style == 'Dynamic' ? color.navy : na)
fill(p5, p4, color = viz_style == 'Dynamic' ? color.new(color.orange, 95) : na)
// add current level line
float level_ = viz_style == 'Static' ? dd : src
var line line_ = line.new(na, na, na, na, xloc = xloc.bar_time, extend = extend.both, color = show_level ? color.olive : na, style = line.style_dotted)
line.set_xy1(line_, time, level_)
line.set_xy2(line_, time+1, level_) |
Connors-Hayward Advance-Decline Trading Patterns | https://www.tradingview.com/script/thoSzsfI-Connors-Hayward-Advance-Decline-Trading-Patterns/ | TechnicusCapital | https://www.tradingview.com/u/TechnicusCapital/ | 22 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TechnicusCapital
//@version=5
indicator("CHADTP", overlay= false)
adv = request.security("USI:ADV", "D", close)
decl = request.security("USI:DECL", "D", close)
advsum = math.sum(adv, 5)
declsum = math.sum(decl, 5)
AD = (advsum - declsum)/ 5
plot(AD, color=color.white)
|
Bitcoin Price Temperature: Weekly Timeframe | https://www.tradingview.com/script/qUgNvEMH-Bitcoin-Price-Temperature-Weekly-Timeframe/ | cryptoonchain | https://www.tradingview.com/u/cryptoonchain/ | 191 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MJShahsavar
//@version=5
indicator("Bitcoin Price Temperature: Weekly Timeframe", timeframe = "W")
a=ta.sma(close, 208)
b=close-a
c=ta.stdev(close, 208)
d=b/c
h1=hline (0.2, color=color.green, linewidth = 2)
h2= hline (6, color=color.red, linewidth = 2)
h3= hline (3, color=color.black, linewidth = 2)
BPT = d >= 6 ? color.blue : d <= 0.2 ? color.red : color.maroon
plot (d, "BPT" , d >= 6 ? color.red : d <= 0.2 ? color.green : color.blue, linewidth=1)
|
Dogaressa Helper (Emas) | https://www.tradingview.com/script/EartKotm-Dogaressa-Helper-Emas/ | ToddyS2K | https://www.tradingview.com/u/ToddyS2K/ | 11 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ToddyS2K
//@version=5
indicator("Dogaressa Helper (Emas)", "Dogaressa Helper (Emas)", overlay=true)
print(txt) => var _label = label.new(bar_index, na, txt, xloc.bar_index, yloc.price, color(na), label.style_none, color.gray, size.large, text.align_left), label.set_xy(_label, bar_index, ta.highest(10)[1]), label.set_text(_label, txt)
get_ema50 (isCrypto) => (isCrypto) ? ta.ema(close,60) : ta.ema(close,50)
get_ema200 (isCrypto) => (isCrypto) ? ta.ema(close,223) : ta.ema(close,200)
ema10Color = input(color.yellow,"Ema 10")
ema50Color = input(color.blue,"Ema 50/60")
ema200Color = input(color.green,"Ema 200/223")
isCrypto = input(true,"Trading crypto")
ema10 = ta.ema(close,10)
var float ema50 = na
var float ema200 = na
if isCrypto
ema50 := ta.ema(close,60)
ema200 := ta.ema(close,223)
label50 = "60"
label200 = "223"
else
ema50 := ta.ema(close,50)
ema200 := ta.ema(close,200)
label50 = "50"
label200 = "200"
ema10_M30 = request.security(syminfo.tickerid,"30",ema10)
ema10_H1 = request.security(syminfo.tickerid,"60",ema10)
ema10_H4 = request.security(syminfo.tickerid,"240",ema10)
ema10_D = request.security(syminfo.tickerid,"D",ema10)
ema50_M30 = request.security(syminfo.tickerid,"30",get_ema50(isCrypto))
ema50_H1 = request.security(syminfo.tickerid,"60",get_ema50(isCrypto))
ema50_H4 = request.security(syminfo.tickerid,"240",get_ema50(isCrypto))
ema50_D = request.security(syminfo.tickerid,"D",get_ema50(isCrypto))
ema200_M30 = request.security(syminfo.tickerid,"30",get_ema200(isCrypto))
ema200_H1 = request.security(syminfo.tickerid,"60",get_ema200(isCrypto))
ema200_H4 = request.security(syminfo.tickerid,"240",get_ema200(isCrypto))
ema200_D = request.security(syminfo.tickerid,"D",get_ema200(isCrypto))
var line ln10_M30 = na
var line ln10_H1 = na
var line ln10_H4 = na
var line ln10_D = na
var label lb10_M30 = na
var label lb10_H1 = na
var label lb10_H4 = na
var label lb10_D = na
var line ln50_M30 = na
var line ln50_H1 = na
var line ln50_H4 = na
var line ln50_D = na
var label lb50_M30 = na
var label lb50_H1 = na
var label lb50_H4 = na
var label lb50_D = na
var line ln200_M30 = na
var line ln200_H1 = na
var line ln200_H4 = na
var line ln200_D = na
var label lb200_M30 = na
var label lb200_H1 = na
var label lb200_H4 = na
var label lb200_D = na
line.delete(ln10_M30)
line.delete(ln10_H1)
line.delete(ln10_H4)
line.delete(ln10_D)
label.delete(lb10_M30)
label.delete(lb10_H1)
label.delete(lb10_H4)
label.delete(lb10_D)
line.delete(ln50_M30)
line.delete(ln50_H1)
line.delete(ln50_H4)
line.delete(ln50_D)
label.delete(lb50_M30)
label.delete(lb50_H1)
label.delete(lb50_H4)
label.delete(lb50_D)
line.delete(ln200_M30)
line.delete(ln200_H1)
line.delete(ln200_H4)
line.delete(ln200_D)
label.delete(lb200_M30)
label.delete(lb200_H1)
label.delete(lb200_H4)
label.delete(lb200_D)
//For intraday timeframes, three bars back and three bars forward
x1 = time - timeframe.multiplier * 3 * 60 * 1000
x2 = time + timeframe.multiplier * 4 * 60 * 1000
x1 := time
x2lab = time + timeframe.multiplier * 2 * 60 * 1000
if timeframe.multiplier < 30 and timeframe.isminutes
ln10_M30 := line.new(x1, ema10_M30, x2, ema10_M30, xloc=xloc.bar_time, width=2, color=ema10Color)
lb10_M30 := label.new(x2lab, ema10_M30, "M30", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
ln50_M30 := line.new(x1, ema50_M30, x2, ema50_M30, xloc=xloc.bar_time, width=2, color=ema50Color)
lb50_M30 := label.new(x2lab, ema50_M30, "M30", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
ln200_M30 := line.new(x1, ema200_M30, x2, ema200_M30, xloc=xloc.bar_time, width=2, color=ema200Color)
lb200_M30 := label.new(x2lab, ema200_M30, "M30", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)
if timeframe.multiplier < 60 and timeframe.isminutes
ln10_H1 := line.new(x1, ema10_H1, x2, ema10_H1, xloc=xloc.bar_time, width=2, color=ema10Color)
lb10_H1 := label.new(x2lab, ema10_H1, "H1", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
ln50_H1 := line.new(x1, ema50_H1, x2, ema50_H1, xloc=xloc.bar_time, width=2, color=ema50Color)
lb50_H1 := label.new(x2lab, ema50_H1, "H1", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
ln200_H1 := line.new(x1, ema200_H1, x2, ema200_H1, xloc=xloc.bar_time, width=2, color=ema200Color)
lb200_H1 := label.new(x2lab, ema200_H1, "H1", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)
if timeframe.multiplier < 240 and timeframe.isminutes
ln10_H4 := line.new(x1, ema10_H4, x2, ema10_H4, xloc=xloc.bar_time, width=2, color=ema10Color)
lb10_H4 := label.new(x2lab, ema10_H4, "H4", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
ln50_H4 := line.new(x1, ema50_H4, x2, ema50_H4, xloc=xloc.bar_time, width=2, color=ema50Color)
lb50_H4 := label.new(x2lab, ema50_H4, "H4", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
ln200_H4 := line.new(x1, ema200_H4, x2, ema200_H4, xloc=xloc.bar_time, width=2, color=ema200Color)
lb200_H4 := label.new(x2lab, ema200_H4, "H4", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)
if timeframe.multiplier <= 240 and timeframe.isminutes
ln10_D := line.new(x1, ema10_D, x2, ema10_D, xloc=xloc.bar_time, width=2, color=ema10Color)
lb10_D := label.new(x2lab, ema10_D, "D", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema10Color, textalign=text.align_left)
ln50_D := line.new(x1, ema50_D, x2, ema50_D, xloc=xloc.bar_time, width=2, color=ema50Color)
lb50_D := label.new(x2lab, ema50_D, "D", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema50Color, textalign=text.align_left)
ln200_D := line.new(x1, ema200_D, x2, ema200_D, xloc=xloc.bar_time, width=2, color=ema200Color)
lb200_D := label.new(x2lab, ema200_D, "D", xloc=xloc.bar_time, size=size.normal, style=label.style_none, textcolor=ema200Color, textalign=text.align_left)
|
TL Waves | https://www.tradingview.com/script/cMo3fVIC-TL-Waves/ | TL_ID | https://www.tradingview.com/u/TL_ID/ | 117 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TL_ID
//@version=5
indicator(title='TL Waves v.1', shorttitle='TL Waves', overlay=true)
////////////////////////////////////////////////////////////////////////
// //
// Moving Average Types //
// //
////////////////////////////////////////////////////////////////////////
// SMA ---> Simple
// WMA ---> Weighted
// VWMA ---> Volume Weighted
// EMA ---> Exponential
// DEMA ---> Double EMA
// ALMA ---> Arnaud Legoux
// HMA ---> Hull MA
// SMMA ---> Smoothed
// LSMA ---> Least Squares
// KAMA ---> Kaufman Adaptive
// TEMA ---> Triple EMA
// ZLEMA ---> Zero Lag
// FRAMA ---> Fractal Adaptive
// VIDYA ---> Variable Index Dynamic Average
// JMA ---> Jurik Moving Average
// T3 ---> Tillson
// TRIMA ---> Triangular
////////////////////////////////////////////////////////////////////////
// //
// Guppy and Wave Basis //
// //
////////////////////////////////////////////////////////////////////////
//Wave Basis
line0 = input.int(defval=107, title='Wave Basis', minval=1)
line0_type = input.string(defval='HMA', title='Wave Basis Type', options=['SMA', 'WMA', 'VWMA', 'EMA', 'DEMA', 'ALMA', 'HMA', 'SMMA', 'LSMA', 'KAMA', 'TEMA', 'ZLEMA', 'ViDYA', 'FRAMA', 'JMA', 'T3', 'TRIMA'])
line0_src = close
//Guppyline 1
line1 = input.int(defval=150, title='GuppyLine 1', minval=1)
line1_type = input.string(defval='JMA', title='GuppyLine 1 Type', options=['SMA', 'WMA', 'VWMA', 'EMA', 'DEMA', 'ALMA', 'HMA', 'SMMA', 'LSMA', 'KAMA', 'TEMA', 'ZLEMA', 'ViDYA', 'FRAMA', 'JMA', 'T3', 'TRIMA'])
line1_src = input(close)
//GuppyLine 2
line2 = input.int(defval=200, title='GuppyLine 2', minval=1)
line2_type = input.string(defval='JMA', title='GuppyLine 2 Type', options=['SMA', 'WMA', 'VWMA', 'EMA', 'DEMA', 'ALMA', 'HMA', 'SMMA', 'LSMA', 'KAMA', 'TEMA', 'ZLEMA', 'ViDYA', 'FRAMA', 'JMA', 'T3', 'TRIMA'])
line2_src = input(close)
//GuppyLine 3
line3 = input.int(defval=250, title='GuppyLine 3', minval=1)
line3_type = input.string(defval='JMA', title='GuppyLine 3 Type', options=['SMA', 'WMA', 'VWMA', 'EMA', 'DEMA', 'ALMA', 'HMA', 'SMMA', 'LSMA', 'KAMA', 'TEMA', 'ZLEMA', 'ViDYA', 'FRAMA', 'JMA', 'T3', 'TRIMA'])
line3_src = input(close)
////////////////////////////////////////////////////////////////////////
// //
// Moving Average Definitions //
// //
////////////////////////////////////////////////////////////////////////
//DEMA
getDEMA(src, len) =>
dema = 2 * ta.ema(src, len) - ta.ema(ta.ema(src, len), len)
dema
//HMA
getHULLMA(src, len) =>
hullma = ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len)))
hullma
//KAMA
getKAMA(src, len, k1, k2) =>
change = math.abs(ta.change(src, len))
volatility = math.sum(math.abs(ta.change(src)), len)
efficiency_ratio = volatility != 0 ? change / volatility : 0
kama = 0.0
fast = 2 / (k1 + 1)
slow = 2 / (k2 + 1)
smooth_const = math.pow(efficiency_ratio * (fast - slow) + slow, 2)
kama := nz(kama[1]) + smooth_const * (src - nz(kama[1]))
kama
//TEMA
getTEMA(src, len) =>
e = ta.ema(src, len)
tema = 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len)
tema
//ZLEMA
getZLEMA(src, len) =>
zlemalag_1 = (len - 1) / 2
zlemadata_1 = src + src - src[zlemalag_1]
zlema = ta.ema(zlemadata_1, len)
zlema
//FRAMA
getFRAMA(src, len) =>
Price = src
N = len
if N % 2 != 0
N += 1
N
N1 = 0.0
N2 = 0.0
N3 = 0.0
HH = 0.0
LL = 0.0
Dimen = 0.0
alpha = 0.0
Filt = 0.0
N3 := (ta.highest(N) - ta.lowest(N)) / N
HH := ta.highest(N / 2 - 1)
LL := ta.lowest(N / 2 - 1)
N1 := (HH - LL) / (N / 2)
HH := high[N / 2]
LL := low[N / 2]
for i = N / 2 to N - 1 by 1
if high[i] > HH
HH := high[i]
HH
if low[i] < LL
LL := low[i]
LL
N2 := (HH - LL) / (N / 2)
if N1 > 0 and N2 > 0 and N3 > 0
Dimen := (math.log(N1 + N2) - math.log(N3)) / math.log(2)
Dimen
alpha := math.exp(-4.6 * (Dimen - 1))
if alpha < .01
alpha := .01
alpha
if alpha > 1
alpha := 1
alpha
Filt := alpha * Price + (1 - alpha) * nz(Filt[1], 1)
if bar_index < N + 1
Filt := Price
Filt
Filt
//VIDYA
getVIDYA(src, len) =>
mom = ta.change(src)
upSum = math.sum(math.max(mom, 0), len)
downSum = math.sum(-math.min(mom, 0), len)
out = (upSum - downSum) / (upSum + downSum)
cmo = math.abs(out)
alpha = 2 / (len + 1)
vidya = 0.0
vidya := src * alpha * cmo + nz(vidya[1]) * (1 - alpha * cmo)
vidya
//JMA
getJMA(src, len, power, phase) =>
phase_ratio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = math.pow(beta, power)
MA1 = 0.0
Det0 = 0.0
MA2 = 0.0
Det1 = 0.0
JMA = 0.0
MA1 := (1 - alpha) * src + alpha * nz(MA1[1])
Det0 := (src - MA1) * (1 - beta) + beta * nz(Det0[1])
MA2 := MA1 + phase_ratio * Det0
Det1 := (MA2 - nz(JMA[1])) * math.pow(1 - alpha, 2) + math.pow(alpha, 2) * nz(Det1[1])
JMA := nz(JMA[1]) + Det1
JMA
//T3
getT3(src, len, vFactor) =>
ema1 = ta.ema(src, len)
ema2 = ta.ema(ema1, len)
ema3 = ta.ema(ema2, len)
ema4 = ta.ema(ema3, len)
ema5 = ta.ema(ema4, len)
ema6 = ta.ema(ema5, len)
c1 = -1 * math.pow(vFactor, 3)
c2 = 3 * math.pow(vFactor, 2) + 3 * math.pow(vFactor, 3)
c3 = -6 * math.pow(vFactor, 2) - 3 * vFactor - 3 * math.pow(vFactor, 3)
c4 = 1 + 3 * vFactor + math.pow(vFactor, 3) + 3 * math.pow(vFactor, 2)
T3 = c1 * ema6 + c2 * ema5 + c3 * ema4 + c4 * ema3
T3
//TRIMA
getTRIMA(src, len) =>
N = len + 1
Nm = math.round(N / 2)
TRIMA = ta.sma(ta.sma(src, Nm), Nm)
TRIMA
getMA(type, src, len) =>
float result = 0
if type == 'SMA'
result := ta.sma(src, len)
result
if type == 'EMA'
result := ta.ema(src, len)
result
if type == 'WMA'
result := ta.wma(src, len)
result
if type == 'VWMA'
result := ta.vwma(src, len)
result
if type == 'ALMA'
result := ta.alma(src, len, 0.85, 6)
result
if type == 'SMMA'
result := ta.rma(src, len)
result
if type == 'LSMA'
result := ta.linreg(src, len, 0)
result
if type == 'DEMA'
result := getDEMA(src, len)
result
if type == 'TEMA'
result := getTEMA(src, len)
result
if type == 'HMA'
result := getHULLMA(src, len)
result
if type == 'ZLEMA'
result := getZLEMA(src, len)
result
if type == 'TRIMA'
result := getTRIMA(src, len)
result
if type == 'T3'
result := getT3(src, len, 0.7)
result
if type == 'KAMA'
result := getKAMA(src, len, 2, 30)
result
if type == 'FRAMA'
result := getFRAMA(src, len)
result
if type == 'JMA'
result := getJMA(src, len, 2, 50)
result
if type == 'ViDYA'
result := getVIDYA(src, len)
result
result
//Select MA Type
hullma = getMA(line0_type, line0_src, line0)
line_1 = getMA(line1_type, line1_src, line1)
line_2 = getMA(line2_type, line2_src, line2)
line_3 = getMA(line3_type, line3_src, line3)
////////////////////////////////////////////////////////////////////////
// //
// Waves //
// //
////////////////////////////////////////////////////////////////////////
//Source
src = close
//Poles
N = input.int(defval=4, minval=1, maxval=9, title='Poles')
//Sampling Period
per = input.int(defval=350, minval=2, title='Sampling Period')
//Filtered True Range Multiplier
mult = input.float(defval=1.9, minval=0, title='Band Multiplier 1')
//Filtered True Range Multiplier
mult1 = input.float(defval=3.8, minval=0, title='Band Multiplier 2')
//Filtered True Range Multiplier
mult2 = input.float(defval=5.8, minval=0, title='Band Multiplier 3')
//Filtered True Range Multiplier
mult3 = input.float(defval=6.4, minval=0, title='Band Multiplier 4')
//Reduced Lag Mode
lagreduce = input(defval=true, title='Reduced Lag Mode')
//Fast Response Mode
fastresponse = input(defval=false, title='Fast Response Mode')
//Pi
pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821483
//Beta and Alpha Components
beta = (1 - math.cos(2 * pi / per)) / (math.pow(1.414, 2 / N) - 1)
alpha = -beta + math.sqrt(math.pow(beta, 2) + 2 * beta)
x = 1 - alpha
//Lag Reduction
lag = (per - 1) / (2 * N)
srcdata = lagreduce ? src + src - src[lag] : src
trdata = lagreduce ? ta.tr + ta.tr - ta.tr[lag] : ta.tr
//Filters (1 - 9 poles)
filt1 = 0.0
filt1 := alpha * srcdata + x * nz(filt1[1])
filt2 = 0.0
filt2 := math.pow(alpha, 2) * srcdata + 2 * x * nz(filt2[1]) - math.pow(x, 2) * nz(filt2[2])
filt3 = 0.0
filt3 := math.pow(alpha, 3) * srcdata + 3 * x * nz(filt3[1]) - 3 * math.pow(x, 2) * nz(filt3[2]) + math.pow(x, 3) * nz(filt3[3])
filt4 = 0.0
filt4 := math.pow(alpha, 4) * srcdata + 4 * x * nz(filt4[1]) - 6 * math.pow(x, 2) * nz(filt4[2]) + 4 * math.pow(x, 3) * nz(filt4[3]) - math.pow(x, 4) * nz(filt4[4])
filt5 = 0.0
filt5 := math.pow(alpha, 5) * srcdata + 5 * x * nz(filt5[1]) - 10 * math.pow(x, 2) * nz(filt5[2]) + 10 * math.pow(x, 3) * nz(filt5[3]) - 5 * math.pow(x, 4) * nz(filt5[4]) + math.pow(x, 5) * nz(filt5[5])
filt6 = 0.0
filt6 := math.pow(alpha, 6) * srcdata + 6 * x * nz(filt6[1]) - 15 * math.pow(x, 2) * nz(filt6[2]) + 20 * math.pow(x, 3) * nz(filt6[3]) - 15 * math.pow(x, 4) * nz(filt6[4]) + 6 * math.pow(x, 5) * nz(filt6[5]) - math.pow(x, 6) * nz(filt6[6])
filt7 = 0.0
filt7 := math.pow(alpha, 7) * srcdata + 7 * x * nz(filt7[1]) - 21 * math.pow(x, 2) * nz(filt7[2]) + 35 * math.pow(x, 3) * nz(filt7[3]) - 35 * math.pow(x, 4) * nz(filt7[4]) + 21 * math.pow(x, 5) * nz(filt7[5]) - 7 * math.pow(x, 6) * nz(filt7[6]) + math.pow(x, 7) * nz(filt7[7])
filt8 = 0.0
filt8 := math.pow(alpha, 8) * srcdata + 8 * x * nz(filt8[1]) - 28 * math.pow(x, 2) * nz(filt8[2]) + 56 * math.pow(x, 3) * nz(filt8[3]) - 70 * math.pow(x, 4) * nz(filt8[4]) + 56 * math.pow(x, 5) * nz(filt8[5]) - 28 * math.pow(x, 6) * nz(filt8[6]) + 8 * math.pow(x, 7) * nz(filt8[7]) - math.pow(x, 8) * nz(filt8[8])
filt9 = 0.0
filt9 := math.pow(alpha, 9) * srcdata + 9 * x * nz(filt9[1]) - 36 * math.pow(x, 2) * nz(filt9[2]) + 84 * math.pow(x, 3) * nz(filt9[3]) - 126 * math.pow(x, 4) * nz(filt9[4]) + 126 * math.pow(x, 5) * nz(filt9[5]) - 84 * math.pow(x, 6) * nz(filt9[6]) + 36 * math.pow(x, 7) * nz(filt9[7]) - 9 * math.pow(x, 8) * nz(filt9[8]) + math.pow(x, 9) * nz(filt9[9])
//Filter Selection
filtn = N == 1 ? filt1 : N == 2 ? filt2 : N == 3 ? filt3 : N == 4 ? filt4 : N == 5 ? filt5 : N == 6 ? filt6 : N == 7 ? filt7 : N == 8 ? filt8 : N == 9 ? filt9 : na
rlfilt = (filtn + filt1) / 2
filt = fastresponse ? rlfilt : filtn
//Filtered True Range (1 - 9 poles)
filt1tr = 0.0
filt1tr := alpha * trdata + x * nz(filt1tr[1])
filt2tr = 0.0
filt2tr := math.pow(alpha, 2) * trdata + 2 * x * nz(filt2tr[1]) - math.pow(x, 2) * nz(filt2tr[2])
filt3tr = 0.0
filt3tr := math.pow(alpha, 3) * trdata + 3 * x * nz(filt3tr[1]) - 3 * math.pow(x, 2) * nz(filt3tr[2]) + math.pow(x, 3) * nz(filt3tr[3])
filt4tr = 0.0
filt4tr := math.pow(alpha, 4) * trdata + 4 * x * nz(filt4tr[1]) - 6 * math.pow(x, 2) * nz(filt4tr[2]) + 4 * math.pow(x, 3) * nz(filt4tr[3]) - math.pow(x, 4) * nz(filt4tr[4])
filt5tr = 0.0
filt5tr := math.pow(alpha, 5) * trdata + 5 * x * nz(filt5tr[1]) - 10 * math.pow(x, 2) * nz(filt5tr[2]) + 10 * math.pow(x, 3) * nz(filt5tr[3]) - 5 * math.pow(x, 4) * nz(filt5tr[4]) + math.pow(x, 5) * nz(filt5tr[5])
filt6tr = 0.0
filt6tr := math.pow(alpha, 6) * trdata + 6 * x * nz(filt6tr[1]) - 15 * math.pow(x, 2) * nz(filt6tr[2]) + 20 * math.pow(x, 3) * nz(filt6tr[3]) - 15 * math.pow(x, 4) * nz(filt6tr[4]) + 6 * math.pow(x, 5) * nz(filt6tr[5]) - math.pow(x, 6) * nz(filt6tr[6])
filt7tr = 0.0
filt7tr := math.pow(alpha, 7) * trdata + 7 * x * nz(filt7tr[1]) - 21 * math.pow(x, 2) * nz(filt7tr[2]) + 35 * math.pow(x, 3) * nz(filt7tr[3]) - 35 * math.pow(x, 4) * nz(filt7tr[4]) + 21 * math.pow(x, 5) * nz(filt7tr[5]) - 7 * math.pow(x, 6) * nz(filt7tr[6]) + math.pow(x, 7) * nz(filt7tr[7])
filt8tr = 0.0
filt8tr := math.pow(alpha, 8) * trdata + 8 * x * nz(filt8tr[1]) - 28 * math.pow(x, 2) * nz(filt8tr[2]) + 56 * math.pow(x, 3) * nz(filt8tr[3]) - 70 * math.pow(x, 4) * nz(filt8tr[4]) + 56 * math.pow(x, 5) * nz(filt8tr[5]) - 28 * math.pow(x, 6) * nz(filt8tr[6]) + 8 * math.pow(x, 7) * nz(filt8tr[7]) - math.pow(x, 8) * nz(filt8tr[8])
filt9tr = 0.0
filt9tr := math.pow(alpha, 9) * trdata + 9 * x * nz(filt9tr[1]) - 36 * math.pow(x, 2) * nz(filt9tr[2]) + 84 * math.pow(x, 3) * nz(filt9tr[3]) - 126 * math.pow(x, 4) * nz(filt9tr[4]) + 126 * math.pow(x, 5) * nz(filt9tr[5]) - 84 * math.pow(x, 6) * nz(filt9tr[6]) + 36 * math.pow(x, 7) * nz(filt9tr[7]) - 9 * math.pow(x, 8) * nz(filt9tr[8]) + math.pow(x, 9) * nz(filt9tr[9])
//Filtered True Range Selection
filtntr = N == 1 ? filt1tr : N == 2 ? filt2tr : N == 3 ? filt3tr : N == 4 ? filt4tr : N == 5 ? filt5tr : N == 6 ? filt6tr : N == 7 ? filt7tr : N == 8 ? filt8tr : N == 9 ? filt9tr : na
rlfilttr = (filtntr + filt1tr) / 2
filttr = fastresponse ? rlfilttr : filtntr
//Bands
hband = hullma + filttr * mult
lband = hullma - filttr * mult
hband1 = hullma + filttr * mult1
lband1 = hullma - filttr * mult1
hband2 = hullma + filttr * mult2
lband2 = hullma - filttr * mult2
hband3 = hullma + filttr * mult3
lband3 = hullma - filttr * mult3
////////////////////////////////////////////////////////////////////////
// //
// Colors //
// //
////////////////////////////////////////////////////////////////////////
fcolor = hullma > hullma[1] ? color.lime : hullma < hullma[1] ? color.red : color.orange
col1 = low < lband3 ? color.green : na
col2 = high > hband3 ? color.red : na
rcol = line_3 > hullma ? color.red : color.green
rcol1 = line_2 > hullma ? color.red : color.green
rcol2 = line_1 > hullma ? color.red : color.green
////////////////////////////////////////////////////////////////////////
// //
// Plots //
// //
////////////////////////////////////////////////////////////////////////
hullplot = plot(hullma, style=plot.style_line, color = fcolor, linewidth=2, title="Basis")
hbandplot = plot(hband, color=color.new(color.gray, 60), linewidth=1, style=plot.style_line, title='Filtered True Range High Band')
lbandplot = plot(lband, color=color.new(color.gray, 60), linewidth=1, style=plot.style_line, title='Filtered True Range Low Band')
hbandplot1 = plot(hband1, color=color.new(color.gray, 40), linewidth=1, style=plot.style_line, title='Filtered True Range High Band 2')
lbandplot1 = plot(lband1, color=color.new(color.gray, 40), linewidth=1, style=plot.style_line, title='Filtered True Range Low Band 2')
hbandplot2 = plot(hband2, color=fcolor, linewidth=2, style=plot.style_line, title='Filtered True Range High Band 3', transp=100)
lbandplot2 = plot(lband2, color=fcolor, linewidth=2, style=plot.style_line, title='Filtered True Range Low Band 3', transp=100)
hbandplot3 = plot(hband3, color=color.new(color.gray, 20), linewidth=1, style=plot.style_circles, title='Filtered True Range High Band 4')
lbandplot3 = plot(lband3, color=color.new(color.gray, 20), linewidth=1, style=plot.style_circles, title='Filtered True Range Low Band 4')
ribboplot1 = plot(line_1, color=color.new(color.gray, 100), linewidth=1, style=plot.style_line, title="MA №1")
ribboplot2 = plot(line_2, color=color.new(color.gray, 100), linewidth=1, style=plot.style_line, title="MA №2")
ribboplot3 = plot(line_3, color=color.new(color.gray, 100), linewidth=1, style=plot.style_line, title="MA №3")
////////////////////////////////////////////////////////////////////////
// //
// Fills //
// //
////////////////////////////////////////////////////////////////////////
fill(lbandplot2, lbandplot3, color=col1, title='Channel Fill', transp=30)
fill(hbandplot2, hbandplot3, color=col2, title='Channel Fill', transp=30)
fill(hullplot, ribboplot3, color=rcol, title='Channel Fill', transp=90)
fill(hullplot, ribboplot2, color=rcol1, title='Channel Fill', transp=85)
fill(hullplot, ribboplot1, color=rcol2, title='Channel Fill', transp=80) |
TUE ADX Crossover Signals V1.0 | https://www.tradingview.com/script/K8sSBess-TUE-ADX-Crossover-Signals-V1-0/ | TradersUltimateEdge | https://www.tradingview.com/u/TradersUltimateEdge/ | 591 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Written by TradersUltimateEdge
// Code provided open source, feel free to use it for any purpose except resale
//@version=5
indicator("TUE ADX Crossover Signals V1.0", overlay=true)
showsignals = input(true, title="Show BUY/SELL Signals")
length = input(14, title="ADX Length")
smoothing = input(10, title="ADX Smoothing")
colorup = input(color.green, title="Up Candle Color")
colordown = input(color.red, title="Down Candle Color")
/////////////////////////////////////////////////////////////////////////////////////////////// ADX CALC
[diplus, diminus, adx] = ta.dmi(length, smoothing)
//////////////////////////////////////////////////////////////////////////////////////////////TRADE CALC
int trade = 0
//Open from nothing
if trade == 0 and diplus > diminus
trade := 1
else if trade == 0 and diminus > diplus
trade := -1
//Reversal
else if trade == 1 and diminus > diplus
trade := -1
else if trade == -1 and diplus > diminus
trade := 1
//Keep status quo until crossover
else
trade := trade[1]
//////////////////////////////////////////////////////////////////////////////////////////////PLOT
colors = diplus > diminus ? colorup : colordown
plotcandle(open, high, low, close, color=colors)
plotshape(trade[1] != 1 and trade == 1 and showsignals, style=shape.labelup, text='BUY', textcolor=color.white, color=color.green, size=size.small, location=location.belowbar)
plotshape(trade[1] != -1 and trade == -1 and showsignals, style=shape.labeldown, text='SELL', textcolor=color.white, color=color.red, size=size.small, location=location.abovebar)
///////////////////////////////////////////////////////////////////////////////////////////// ALERTS
alertcondition(trade[1] != 1 and trade == 1, "ADX CROSSOVER LONG")
alertcondition(trade[1] != -1 and trade == -1, "ADX CROSSOVER SHORT") |
ICT Everything | https://www.tradingview.com/script/T6KkMfK6-ICT-Everything/ | coldbrewrosh | https://www.tradingview.com/u/coldbrewrosh/ | 2,536 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©coldbrewrosh
//@version=5
indicator("ICT Everything @coldbrewrosh", overlay=true, max_lines_count=500, max_labels_count=5, max_boxes_count=500)
// General Settings Inputs
TZI = input.string (defval="UTC -5", title="Timezone Selection", options=["UTC -10", "UTC -7", "UTC -6", "UTC -5", "UTC -4", "UTC -3", "UTC +0", "UTC +1", "UTC +2", "UTC +3", "UTC +3:30", "UTC +4", "UTC +5", "UTC +5:30", "UTC +6", "UTC +7", "UTC +8", "UTC +9", "UTC +9:30", "UTC +10", "UTC +10:30", "UTC +11", "UTC +13", "UTC +13:45"], tooltip="Select the Timezone. ( Shifts Chart Elements )", group="Global Settings")
Timezone = TZI == "UTC -10" ? "GMT-10:00" : TZI == "UTC -7" ? "GMT-07:00" : TZI == "UTC -6" ? "GMT-06:00" : TZI == "UTC -5" ? "GMT-05:00" : TZI == "UTC -4" ? "GMT-04:00" : TZI == "UTC -3" ? "GMT-03:00" : TZI == "UTC +0" ? "GMT+00:00" : TZI == "UTC +1" ? "GMT+01:00" : TZI == "UTC +2" ? "GMT+02:00" : TZI == "UTC +3" ? "GMT+03:00" : TZI == "UTC +3:30" ? "GMT+03:30" : TZI == "UTC +4" ? "GMT+04:00" : TZI == "UTC +5" ? "GMT+05:00" : TZI == "UTC +5:30" ? "GMT+05:30" : TZI == "UTC +6" ? "GMT+06:00" : TZI == "UTC +7" ? "GMT+07:00" : TZI == "UTC +8" ? "GMT+08:00" : TZI == "UTC +9" ? "GMT+09:00" : TZI == "UTC +9:30" ? "GMT+09:30" : TZI == "UTC +10" ? "GMT+10:00" : TZI == "UTC +10:30" ? "GMT+10:30" : TZI == "UTC +11" ? "GMT+11:00" : TZI == "UTC +13" ? "GMT+13:00" : "GMT+13:45"
inputMaxInterval = input.int (31, title="Hide Indicator Above Specified Minutes", tooltip="Above 30Min, Chart Will Become Messy & Unreadable", group="Global Settings")
// Session options
ShowTSO = input.bool (true, title="Show Today's Session Only", group="Session Options", tooltip="Hide Historical Sessions")
ShowTWO = input.bool (true, title="Show Current Week's Sessions Only", group="Session Options", tooltip="Show All Sessions from the current week")
SL4W = input.bool (true, title="Show Last 4 Week Sessions", group="Session Options", tooltip="Show All Sessions from Last Four Weeks \nShould Disable Current Week Session to Work")
ShowSFill = input.bool (false, title="Show Session Highlighting", group="Session Options", tooltip="Highlights Session from Top of the Chart to Bottom")
//----------------------------------------------
// Historical Lines
ShowMOPL = input.bool (title="Midnight Historical Price Lines", defval=false, group="Historical Lines", tooltip="Shows Historical Midnight Price Lines")
MOLHist = input.bool (title="Midnight Historical Vertical Lines", defval=true, group="Historical Lines", tooltip="Shows Historical Midnight Vertical Lines")
ShowPrev = input.bool (false, title="Misc. Historical Price Lines", group="Historical Lines", tooltip="Makes Chart Cluttered, Use For Backtesting Only")
//----------------------------------------------
// Session Bool
ShowLondon = input.bool (true, "", inline="LONDON", group="Sessions", tooltip="01:00 to 05:00")
ShowNY = input.bool (true, "", inline="NY", group="Sessions", tooltip="07:00 to 10:00")
ShowLC = input.bool (true, "", inline="LC", group="Sessions", tooltip="10:00 to 12:00")
ShowPM = input.bool (true, "",inline="PM", group="Sessions", tooltip="13:00 to 16:00")
ShowAsian = input.bool (false, "",inline="ASIA2", group="Sessions", tooltip="20:00 to 00:00")
ShowFreeSesh = input.bool (false, "",inline="FREE", group="Sessions", tooltip="Custom Session")
// Session Strings
txt2 = input.string ("LONDON", title="", inline="LONDON", group="Sessions")
txt3 = input.string ("NEW YORK", title="", inline="NY", group="Sessions")
txt4 = input.string ("LDN CLOSE", title="", inline="LC", group="Sessions")
txt5 = input.string ("AFTERNOON", title="", inline="PM", group="Sessions")
txt6 = input.string ("ASIA", title="", inline="ASIA2", group="Sessions")
txt9 = input.string ("FREE SESH", title="", inline="FREE", group="Sessions")
// CBDR = input.session ('1600-2000:1234567', "", inline="CBDR", group="Sessions")
// ASIA = input.session ('2000-0000:1234567', "", inline="ASIA", group="Sessions")
// Session Times
LDNsesh = input.session ('0200-0500:1234567', "", inline="LONDON", group="Sessions")
NYsesh = input.session ('0700-1000:1234567', "", inline="NY", group="Sessions")
LCsesh = input.session ('1000-1200:1234567', "", inline="LC", group="Sessions")
PMsesh = input.session ('1300-1600:1234567', "", inline="PM", group="Sessions")
ASIA2sesh = input.session ('2000-2359:1234567', "", inline="ASIA2", group="Sessions")
FreeSesh = input.session ('0000-0000:1234567', "", inline="FREE", group="Sessions")
// Session Color
LSFC = input.color (color.new(#787b86, 90), "", inline="LONDON", group="Sessions")
NYSFC = input.color (color.new(#787b86, 90), "",inline="NY", group="Sessions")
LCSFC = input.color (color.new(#787b86, 90), "",inline="LC", group="Sessions")
PMSFC = input.color (color.new(#787b86, 90), "",inline="PM", group="Sessions")
ASFC = input.color (color.new(#787b86, 90), "",inline="ASIA2", group="Sessions")
FSFC = input.color (color.new(#787b86, 90), "",inline="FREE", group="Sessions")
//----------------------------------------------
// Vertical Line Bool
ShowMOP = input.bool (title="", defval=true, inline="MOP", group="Vertical Lines", tooltip="00:00 AM")
txt12 = input.string ("MIDNIGHT", title="", inline="MOP", group="Vertical Lines")
ShowLOP = input.bool (title="", defval=false, inline="LOP", group="Vertical Lines", tooltip="03:00 AM")
txt14 = input.string ("LONDON", title="", inline="LOP", group="Vertical Lines")
ShowNYOP = input.bool (title="", defval=true, inline="NYOP", group="Vertical Lines", tooltip="08:30 AM")
txt15 = input.string ("NEW YORK", title="", inline="NYOP", group="Vertical Lines")
ShowEOP = input.bool (title="", defval=false, inline="EOP", group="Vertical Lines", tooltip="09:30 AM")
txt16 = input.string ("EQUITIES", title="", inline="EOP", group="Vertical Lines")
// Vertical Line Color
MOPColor = input.color (color.new(#787b86, 0), "", inline="MOP", group="Vertical Lines")
LOPColor = input.color (color.rgb(0,128,128,60), "", inline="LOP", group="Vertical Lines")
NYOPColor = input.color (color.rgb(0,128,128,60), "", inline="NYOP", group="Vertical Lines")
EOPColor = input.color (color.rgb(0,128,128,60), "", inline="EOP", group="Vertical Lines")
// Vertical LineStyle
Midnight_Open_LS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="MOP", group="Vertical Lines")
london_Open_LS = input.string ("Solid", "", options=["Solid", "Dashed", "Dotted"], inline="LOP", group="Vertical Lines")
NY_Open_LS = input.string ("Solid", "", options=["Solid", "Dashed", "Dotted"], inline="NYOP", group="Vertical Lines")
Equities_Open_LS = input.string ("Solid", "", options=["Solid", "Dashed", "Dotted"], inline="EOP", group="Vertical Lines")
// Vertical LineWidth
Midnight_Open_LW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="MOP", group="Vertical Lines")
London_Open_LW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="LOP", group="Vertical Lines")
NY_Open_LW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="NYOP", group="Vertical Lines")
Equities_Open_LW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="EOP", group="Vertical Lines")
//----------------------------------------------
// Opening Price Bool
ShowMOPP = input.bool (title="", defval=true, inline="MOPP", group="Opening Price Lines", tooltip="00:00 AM")
txt13 = input.string ("MIDNIGHT", title="", inline="MOPP", group="Opening Price Lines")
ShowNYOPP = input.bool (title="", defval=false, inline="NYOPP", group="Opening Price Lines", tooltip="08:30 AM")
txt17 = input.string ("NEW YORK", title="", inline="NYOPP", group="Opening Price Lines")
ShowEOPP = input.bool (title="", defval=false, inline="EOPP", group="Opening Price Lines", tooltip="09:30 AM")
txt18 = input.string ("EQUITIES", title="", inline="EOPP", group="Opening Price Lines")
ShowAFTPP = input.bool (title="", defval=false, inline="AFTOPP", group="Opening Price Lines", tooltip="01:30 PM")
txt1330 = input.string ("AFTERNOON", title="", inline="AFTOPP", group="Opening Price Lines")
// Opening Price Color
MOPColP = input.color (color.new(#787b86, 0), "", inline="MOPP", group="Opening Price Lines")
NYOPColP = input.color (color.new(#787b86, 0), "", inline="NYOPP", group="Opening Price Lines")
EOPColP = input.color (color.new(#787b86, 0), "", inline="EOPP", group="Opening Price Lines")
AFTOPColP = input.color (color.new(#787b86, 0), "", inline="AFTOPP", group="Opening Price Lines")
// Opening Price LineStyle
MOPLS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="MOPP", group="Opening Price Lines")
NYOPLS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="NYOPP", group="Opening Price Lines")
EOPLS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="EOPP", group="Opening Price Lines")
AFTOPLS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="AFTOPP", group="Opening Price Lines")
// Opening Price LineWidth
i_MOPLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="MOPP", group="Opening Price Lines")
i_NYOPLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="NYOPP", group="Opening Price Lines")
i_EOPLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="EOPP", group="Opening Price Lines")
i_AFTOPLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="AFTOPP", group="Opening Price Lines")
//----------------------------------------------
// W&M Bool
ShowWeekOpen = input.bool (defval=false, title="", tooltip="Draw Weekly Open Price Line", group="HTF Opening Price Lines", inline="WO")
showMonthOpen = input.bool (defval=false, title="", tooltip="Draw Monthly Open Price Line", group="HTF Opening Price Lines", inline="MO")
// W&M String
txt19 = input.string ("WEEKLY", title="", inline="WO", group="HTF Opening Price Lines")
txt20 = input.string ("MONTHLY", title="", inline="MO", group="HTF Opening Price Lines")
// W&M Color
i_WeekOpenCol = input.color (title="", defval=color.new(#787b86, 0), group="HTF Opening Price Lines", inline="WO")
i_MonthOpenCol = input.color (title="", tooltip="", defval=color.new(#787b86, 0), group="HTF Opening Price Lines", inline="MO")
// W&M LineStyle
WOLS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="WO", group="HTF Opening Price Lines")
MOLS = input.string ("Dotted", "", options=["Solid", "Dashed", "Dotted"], inline="MO", group="HTF Opening Price Lines")
// W&M LineWidth
i_WOPLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="WO", group="HTF Opening Price Lines")
i_MONPLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="MO", group="HTF Opening Price Lines")
//----------------------------------------------
// CBDR, ASIA & FLOUT
ShowCBDR = input.bool (true, "", inline='CBDR', group="CBDR, ASIA & FLOUT")
ShowASIA = input.bool (true, "", inline='ASIA', group="CBDR, ASIA & FLOUT")
ShowFLOUT = input.bool (false, "", inline='FLOUT', group="CBDR, ASIA & FLOUT")
// Strings
txt0 = input.string ("CBDR", title="", inline="CBDR", group="CBDR, ASIA & FLOUT", tooltip="16:00 to 20:00 \nSD Increments of 1")
txt1 = input.string ("ASIA", title="", inline="ASIA", group="CBDR, ASIA & FLOUT", tooltip="20:00 to 00:00 \nSD Increments of 1")
txt7 = input.string ("FLOUT", title="", inline="FLOUT", group="CBDR, ASIA & FLOUT", tooltip="16:00 to 00:00 \nSD Increments of 0.5")
// Color
CBDRBoxCol = input.color (color.new(#787b86, 0),"", inline='CBDR', group="CBDR, ASIA & FLOUT")
ASIABoxCol = input.color (color.new(#787b86, 0), "", inline='ASIA', group="CBDR, ASIA & FLOUT")
FLOUTBoxCol = input.color (color.new(#787b86, 0),"", inline='FLOUT', group="CBDR, ASIA & FLOUT")
// Extras
box_text_cbdr = input.bool (true, "Show Text", inline="CBDR", group="CBDR, ASIA & FLOUT")
box_text_cbdr_col = input.color (color.new(color.gray, 80), "", inline="CBDR", group="CBDR, ASIA & FLOUT")
bool_cbdr_dev = input.bool (true, "SD", inline="CBDR", group="CBDR, ASIA & FLOUT")
box_text_asia = input.bool (true, "Show Text", inline="ASIA", group="CBDR, ASIA & FLOUT")
box_text_asia_col = input.color (color.new(color.gray, 80), "", inline="ASIA", group="CBDR, ASIA & FLOUT")
bool_asia_dev = input.bool (true, "SD", inline="ASIA", group="CBDR, ASIA & FLOUT")
box_text_flout = input.bool (true, "Show Text", inline="FLOUT", group="CBDR, ASIA & FLOUT")
box_text_flout_col = input.color (color.new(color.gray, 80), "", inline="FLOUT", group="CBDR, ASIA & FLOUT")
bool_flout_dev = input.bool (true, "SD", inline="FLOUT", group="CBDR, ASIA & FLOUT")
// Table
// SD Lines
ShowDevLN = input.bool (title="", defval=true, inline="DEVLN", group="Standard Deviation", tooltip="Deviation Lines")
DEVLNTXT = input.string ("SD LINES", title="", inline="DEVLN", group="Standard Deviation")
DevLNCol = input.color (color.new(#787b86, 0), "", inline="DEVLN", group="Standard Deviation")
DEVLS = input.string ("Solid", "", options=["Solid", "Dashed", "Dotted"], inline="DEVLN", group="Standard Deviation")
i_DEVLW = input.string ("1px", "", options=["1px","2px", "3px", "4px", "5px"], inline="DEVLN", group="Standard Deviation")
DEVLSS = DEVLS=="Solid" ? line.style_solid : DEVLS == "Dotted" ? line.style_dotted : line.style_dashed
DEVLW = i_DEVLW=="1px" ? 1 : i_DEVLW == "2px" ? 2 : i_DEVLW == "3px" ? 3 : i_DEVLW == "4px" ? 4 : 5
ShowDev = input.bool (false, '', inline="DEV", group="Standard Deviation")
txt8 = input.string ("SD COUNT", title="", inline="DEV", group="Standard Deviation")
SDCountCol = input.color (color.new(#787b86, 0), "", inline="DEV", group="Standard Deviation")
DevInput = input.string ("2 SD", "", options=["1 SD","2 SD", "3 SD", "4 SD"], inline="DEV", group="Standard Deviation")
DevDirection = input.string ("Both", "", options=["Upside Only","Both", "Downside Only"], inline="DEV", group="Standard Deviation", tooltip="SD Count, NULL, SD Count, SD Direction")
DevCount = DevInput == "1 SD" ? 1 : DevInput == "2 SD" ? 2 : DevInput == "3 SD" ? 3 : 4
Auto_Select = input.bool (false, "", group="Standard Deviation", inline="AUTOSD", tooltip="Auto SD Selection | Charter Content, Range Table \nMight Bug Out On Mondays" )
txtSD = input.string ("AUTO SD", "", group="Standard Deviation", inline="AUTOSD")
Tab1txtCol = input.color (color.new(#808080, 0), "", inline='AUTOSD', group="Standard Deviation")
TabOptionShow = input.string ("Show Table", "", options=["Show Table", "Hide Table"], inline="AUTOSD", group="Standard Deviation")
Stats = TabOptionShow == "Show Table" ? true : false
TabOption1 = input.string ("Top Right", "", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], inline="AUTOSD", group="Standard Deviation")
tabinp1 = TabOption1 == "Top Left" ? position.top_left : TabOption1 == "Top Center" ? position.top_center : TabOption1 == "Top Right" ? position.top_right : TabOption1 == "Middle Left" ? position.middle_left : TabOption1 == "Middle Right" ? position.middle_right : TabOption1 == "Bottom Left" ? position.bottom_left : TabOption1 == "Bottom Center" ? position.bottom_center : position.bottom_right
L_Prof = true
CellBG = color.new(#131722, 100)
//----------------------------------------------
// Day Of Week & Labels
// Label Settings Inputs
ShowLabel = input.bool (true, title="", inline="Glabel", group="Day Of Week & Labels")
txt21 = input.string ("LABEL", title="", inline="Glabel", group="Day Of Week & Labels")
LabelColor = input.color (color.rgb(0,0,0,100), "", inline="Glabel", group="Day Of Week & Labels")
LabelSizeInput = input.string ("Normal", "", options=["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], inline="Glabel", group="Day Of Week & Labels")
Terminusinp = input.string ("Terminus @ Current Time +1hr", "", options = ["Terminus @ Next Midnight","Terminus @ Current Time", "Terminus @ Current Time +15min", "Terminus @ Current Time +30min", "Terminus @ Current Time +45min", "Terminus @ Current Time +1hr", "Terminus @ Current Time +2hr", "Terminus @ Current Time +3hr"], inline="Glabel", group="Day Of Week & Labels", tooltip="Select Label Size & Color & Terminus \nHistorical Price Lines needs to be toggled off for using Terminus")
ShowLabelText = input.bool (true, title="", inline="label", group="Day Of Week & Labels")
txt22 = input.string ("LABEL TEXT", title="", inline="label", group="Day Of Week & Labels")
LabelTextColor = input.color (color.new(#787b86, 0), title="", inline="label", group="Day Of Week & Labels")
LabelTextOptioninput = input.string ("Time", "", options=["Time", "Text"], inline="label", group="Day Of Week & Labels", tooltip="Choose Between Descriptive Text as Label or Time \nShow/Hide Prices on Labels")
ShowPricesBool = input.string ("Hide Prices", title="", options=["Show Prices", "Hide Prices"], group="Day Of Week & Labels", inline="label")
ShowPrices = ShowPricesBool == "Show Prices" ? true : false
showDOW = input.bool (true, title="", inline="DOW", group="Day Of Week & Labels")
txt24 = input.string ("DAY OF WEEK", title="", inline="DOW", group="Day Of Week & Labels")
i_DOWCol = input.color (color.new(#787b86, 0), title="", inline="DOW", group="Day Of Week & Labels")
DOWTime = input.int (defval = 12, title="", inline="DOW", group="Day Of Week & Labels")
DOWLoc_inpt = input.string ("Bottom", "", options = ["Top", "Bottom"], inline="DOW", group="Day Of Week & Labels", tooltip="DOW Color, Time Alignment, Vertical Location")
DOWLoc = DOWLoc_inpt == "Bottom" ? location.bottom : location.top
//----------------------------------------------
BIAS_M_Bool = input.bool (false, "", group="BIAS & NOTES PRECONFIG", inline="stats")
txt100 = input.string ("BIAS", title="", inline="stats", group="BIAS & NOTES PRECONFIG")
TableBG2 = color.new(#131722, 100)
Tab2txtCol = input.color (color.new(#787b86, 0), "", inline='stats', group="BIAS & NOTES PRECONFIG")
TabOption2 = input.string ("Bottom Right", "", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], inline="stats", group="BIAS & NOTES PRECONFIG")
tabinp2 = TabOption2 == "Top Left" ? position.top_left : TabOption2 == "Top Center" ? position.top_center : TabOption2 == "Top Right" ? position.top_right : TabOption2 == "Middle Left" ? position.middle_left : TabOption2 == "Middle Right" ? position.middle_right : TabOption2 == "Bottom Left" ? position.bottom_left : TabOption2 == "Bottom Center" ? position.bottom_center : position.bottom_right
notesbool = false
NOTES_M_Bool = input.bool (true, "", group="BIAS & NOTES PRECONFIG", inline="stats2")
txt101 = input.string ("NOTES", title="", inline="stats2", group="BIAS & NOTES PRECONFIG")
Tab3txtCol = input.color (color.new(#787b86, 0), "", inline='stats2', group="BIAS & NOTES PRECONFIG")
TabOption3 = input.string ("Top Center", "", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], inline="stats2", group="BIAS & NOTES PRECONFIG")
tabinp3 = TabOption3 == "Top Left" ? position.top_left : TabOption3 == "Top Center" ? position.top_center : TabOption3 == "Top Right" ? position.top_right : TabOption3 == "Middle Left" ? position.middle_left : TabOption3 == "Middle Right" ? position.middle_right : TabOption3 == "Bottom Left" ? position.bottom_left : TabOption3 == "Bottom Center" ? position.bottom_center : position.bottom_right
BIASbool1 = input.bool (true, '', inline="BIAS1", group="BIAS & NOTES")
txt52 = input.string ("DXY ", title="", inline="BIAS1", group="BIAS & NOTES")
BIASOption1 = input.string ("Bullish", options=["Bullish", "Bearish", "Consolidating", "Unclear"], title="", inline="BIAS1", group="BIAS & NOTES")
BIASbool2 = input.bool (true, '', inline="BIAS2", group="BIAS & NOTES")
txt53 = input.string ("EURGBP ", title="", inline="BIAS2", group="BIAS & NOTES")
BIASOption2 = input.string ("Bearish", options=["Bullish", "Bearish", "Consolidating", "Unclear"], title="", inline="BIAS2", group="BIAS & NOTES")
BIASbool3 = input.bool (true, '', inline="BIAS3", group="BIAS & NOTES")
txt54 = input.string ("AUDNZD ", title="", inline="BIAS3", group="BIAS & NOTES")
BIASOption3 = input.string ("Bullish", options=["Bullish", "Bearish", "Consolidating", "Unclear"], title="", inline="BIAS3", group="BIAS & NOTES")
BIASbool4 = input.bool (true, '', inline="BIAS4", group="BIAS & NOTES")
txt55 = input.string ("NASDAQ ", title="", inline="BIAS4", group="BIAS & NOTES")
BIASOption4 = input.string ("Bearish", options=["Bullish", "Bearish", "Consolidating", "Unclear"], title="", inline="BIAS4", group="BIAS & NOTES")
notes = input.text_area ("@coldbrewrosh", "Notes", group = "BIAS & NOTES")
//--------------------END OF INPUTS--------------------//
// Pre-Def
DOM = (timeframe.multiplier <= inputMaxInterval) and (timeframe.isintraday)
newDay = ta.change(dayofweek)
newWeek = ta.change(weekofyear)
newMonth = ta.change(time("M"))
transparentcol = color.rgb(255,255,255,100)
LSVLC = color.rgb(255,255,255,100)
NYSVLC = color.rgb(255,255,255,100)
PMSVLC = color.rgb(255,255,255,100)
ASVLC = color.rgb(255,255,255,100)
LSVLS = "dotted"
NYSVLS = "dotted"
PMSVLS = "dotted"
ASVLS = "dotted"
// Functions
isToday = false
if year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time)
isToday := true
// Current Week
thisweek = year(timenow) == year(time) and weekofyear(timenow) == weekofyear(time)
LastOneWeek = year(timenow) == year(time) and weekofyear(timenow-604800000) == weekofyear(time)
LastTwoWeek = year(timenow) == year(time) and weekofyear(timenow-1209600000) == weekofyear(time)
LastThreeWeek = year(timenow) == year(time) and weekofyear(timenow-1814400000) == weekofyear(time)
LastFourWeek = year(timenow) == year(time) and weekofyear(timenow-2419200000) == weekofyear(time)
Last4Weeks = false
if thisweek == true or LastOneWeek == true or LastTwoWeek == true or LastThreeWeek == true or LastFourWeek == true
Last4Weeks := true
// Function to draw Vertical Lines
vline(Start, Color, linestyle, LineWidth) =>
line.new(x1=Start, y1=low - ta.tr, x2=Start, y2=high + ta.tr, xloc=xloc.bar_time, extend=extend.both, color=Color, style=linestyle, width=LineWidth)
// Function to convert forex pips into whole numbers
atr = ta.atr(14)
toWhole(number) =>
if syminfo.type == "forex" // This method only works on forex pairs
_return = atr < 1.0 ? (number / syminfo.mintick) / 10 : number
_return := atr >= 1.0 and atr < 100.0 and syminfo.currency == "JPY" ? _return * 100 : _return
else
number
// Function for determining the Start of a Session (taken from the Pinescript manual: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Sessions.html )
SessionBegins(sess) =>
t = time("", sess , Timezone)
DOM and (not barstate.isfirst) and na(t[1]) and not na(t)
// BarIn Session
BarInSession(sess) =>
time(timeframe.period, sess, Timezone) != 0
// Label Type Logic
var SFistrue = true
if LabelTextOptioninput == "Time"
SFistrue := true
else
SFistrue := false
// Session String to int
SeshStartHour(Session) =>
math.round(str.tonumber(str.substring(Session,0,2)))
SeshStartMins(Session) =>
math.round(str.tonumber(str.substring(Session,2,4)))
SeshEndHour(Session) =>
math.round(str.tonumber(str.substring(Session,5,7)))
SeshEndMins(Session) =>
math.round(str.tonumber(str.substring(Session,7,9)))
// Time periods
CBDR = "1600-2000:1234567"
ASIA = "2000-0000:1234567"
FLOUT = "1600-0000:1234567"
midsesh = "0000-1600:1234567"
cbdrOpenTime = timestamp (Timezone, year, month, dayofmonth, SeshStartHour(CBDR), SeshStartMins(CBDR), 00)
cbdrEndTime = timestamp (Timezone, year, month, dayofmonth, SeshEndHour(CBDR), SeshEndMins(CBDR), 00)
asiaOpenTime = timestamp (Timezone, year, month, dayofmonth, SeshStartHour(ASIA), SeshStartMins(ASIA), 00)
asiaEndTime = timestamp (Timezone, year, month, dayofmonth, SeshEndHour(ASIA), SeshEndMins(ASIA), 00)+86400000
floutOpenTime = timestamp (Timezone, year, month, dayofmonth, SeshStartHour(FLOUT), SeshStartMins(FLOUT), 00)
floutEndTime = timestamp (Timezone, year, month, dayofmonth, SeshEndHour(FLOUT), SeshEndMins(FLOUT), 00)+86400000
CBDRTime = time (timeframe.period, CBDR, Timezone)
ASIATime = time (timeframe.period, ASIA, Timezone)
FLOUTTime = time (timeframe.period, FLOUT, Timezone)
LabelOnlyToday = true
// Time Periods
LondonStartTime = timestamp(Timezone, year, month, dayofmonth, SeshStartHour(LDNsesh), SeshStartMins(LDNsesh), 00)
LondonEndTime = timestamp(Timezone, year, month, dayofmonth, SeshEndHour(LDNsesh), SeshEndMins(LDNsesh), 00)
NYStartTime = timestamp(Timezone, year, month, dayofmonth, SeshStartHour(NYsesh), SeshStartMins(NYsesh), 00)
NYEndTime = timestamp(Timezone, year, month, dayofmonth, SeshEndHour(NYsesh), SeshEndMins(NYsesh), 00)
LCStartTime = timestamp(Timezone, year, month, dayofmonth, SeshStartHour(LCsesh), SeshStartMins(LCsesh), 00)
LCEndTime = timestamp(Timezone, year, month, dayofmonth, SeshEndHour(LCsesh), SeshEndMins(LCsesh), 00)
PMStartTime = timestamp(Timezone, year, month, dayofmonth, SeshStartHour(PMsesh), SeshStartMins(PMsesh), 00)
PMEndTime = timestamp(Timezone, year, month, dayofmonth, SeshEndHour(PMsesh), SeshEndMins(PMsesh), 00)
AsianStartTime = timestamp(Timezone, year, month, dayofmonth, SeshStartHour(ASIA2sesh), SeshStartMins(ASIA2sesh), 00)
AsianEndTime = timestamp(Timezone, year, month, dayofmonth, SeshEndHour(ASIA2sesh), SeshEndMins(ASIA2sesh), 00)
FreeStartTime = timestamp(Timezone, year, month, dayofmonth, SeshStartHour(FreeSesh), SeshStartMins(FreeSesh), 00)
FreeEndTime = timestamp(Timezone, year, month, dayofmonth, SeshEndHour(FreeSesh), SeshEndMins(FreeSesh), 00)
MidnightOpenTime = timestamp(Timezone, year, month, dayofmonth, 0, 0, 00)
CLEANUPTIME = timestamp(Timezone, year, month, dayofmonth, 0, 0, 00) - 16200000
LondonOpenTime = timestamp(Timezone, year, month, dayofmonth, 3, 0, 00)
NYOpenTime = timestamp(Timezone, year, month, dayofmonth, 8, 30, 00)
EquitiesOpenTime = timestamp(Timezone, year, month, dayofmonth, 9, 30, 00)
AfternoonOpenTime = timestamp(Timezone, year, month, dayofmonth, 13, 30, 00)
tMidnight = time("1", "0000-0001:1234567", Timezone)
// Cleanup - Remove old drawing objects
Cleanup(days) =>
// Delete old drawing objects
// One day is 86400000 milliseconds
removal_timestamp = (CLEANUPTIME) - (days * 86400000) // Remove every drawing object older than the start of the Today's Midnight
a_allLines = line.all
a_allLabels = label.all
a_allboxes = box.all
// Remove old lines
if array.size(a_allLines) > 0
for i = 0 to array.size(a_allLines) - 1
line_x2 = line.get_x2(array.get(a_allLines, i))
if line_x2 < (removal_timestamp)
line.delete(array.get(a_allLines, i))
// Remove old labels
if array.size(a_allLabels) > 0
for i = 0 to array.size(a_allLabels) - 1
label_x = label.get_x(array.get(a_allLabels, i))
if label_x < removal_timestamp
label.delete(array.get(a_allLabels, i))
// Remove old boxes
if array.size(a_allboxes) > 0
for i = 0 to array.size(a_allboxes) - 1
box_x = box.get_right(array.get(a_allboxes, i))
if box_x < (removal_timestamp - 86400000)
box.delete(array.get(a_allboxes, i))
// End of Cleanup function
// Terminus Function
Terminus(Terminus_Inp)=>
if Terminus_Inp == "Terminus @ Current Time"
_return = timenow
else if Terminus_Inp == "Terminus @ Current Time +15min"
_return = timenow + 900000
else if Terminus_Inp == "Terminus @ Current Time +30min"
_return = timenow + 1800000
else if Terminus_Inp == "Terminus @ Current Time +45min"
_return = timenow + 2700000
else if Terminus_Inp == "Terminus @ Current Time +1hr"
_return = timenow + 3600000
else if Terminus_Inp == "Terminus @ Current Time +2hr"
_return = timenow + 7200000
else
_return = timenow + 10800000
// Linestyle Function
MNOPLS = Midnight_Open_LS=="Solid" ? line.style_solid : Midnight_Open_LS == "Dotted" ? line.style_dotted : line.style_dashed
LNOPLS = london_Open_LS=="Solid" ? line.style_solid : london_Open_LS == "Dotted" ? line.style_dotted : line.style_dashed
NWYOPLS = NY_Open_LS=="Solid" ? line.style_solid : NY_Open_LS == "Dotted" ? line.style_dotted : line.style_dashed
EQOPLS = Equities_Open_LS=="Solid" ? line.style_solid : Equities_Open_LS == "Dotted" ? line.style_dotted : line.style_dashed
MOPLSS = MOPLS=="Solid" ? line.style_solid : MOPLS == "Dotted" ? line.style_dotted : line.style_dashed
NYOPLSS = NYOPLS=="Solid" ? line.style_solid : NYOPLS == "Dotted" ? line.style_dotted : line.style_dashed
EOPLSS = EOPLS=="Solid" ? line.style_solid : EOPLS == "Dotted" ? line.style_dotted : line.style_dashed
AFTOPLSS = AFTOPLS=="Solid" ? line.style_solid : AFTOPLS == "Dotted" ? line.style_dotted : line.style_dashed
WeekOpenLS = WOLS=="Solid" ? line.style_solid : WOLS == "Dotted" ? line.style_dotted : line.style_dashed
MonthOpenLS = MOLS=="Solid" ? line.style_solid : MOLS == "Dotted" ? line.style_dotted : line.style_dashed
// Linewidth Function
MOPLW = Midnight_Open_LW=="1px" ? 1 : Midnight_Open_LW == "2px" ? 2 : Midnight_Open_LW == "3px" ? 3 : Midnight_Open_LW == "4px" ? 4 : 5
LOPLW = London_Open_LW=="1px" ? 1 : London_Open_LW == "2px" ? 2 : London_Open_LW == "3px" ? 3 : London_Open_LW == "4px" ? 4 : 5
NYOPLW = NY_Open_LW=="1px" ? 1 : NY_Open_LW == "2px" ? 2 : NY_Open_LW == "3px" ? 3 : NY_Open_LW == "4px" ? 4 : 5
EOPLW = Equities_Open_LW=="1px" ? 1 : Equities_Open_LW == "2px" ? 2 : Equities_Open_LW == "3px" ? 3 : Equities_Open_LW == "4px" ? 4 : 5
MOPPLW = i_MOPLW=="1px" ? 1 : i_MOPLW == "2px" ? 2 : i_MOPLW == "3px" ? 3 : i_MOPLW == "4px" ? 4 : 5
NYOPPLW = i_NYOPLW=="1px" ? 1 : i_NYOPLW == "2px" ? 2 : i_NYOPLW == "3px" ? 3 : i_NYOPLW == "4px" ? 4 : 5
EOPPLW = i_EOPLW=="1px" ? 1 : i_EOPLW == "2px" ? 2 : i_EOPLW == "3px" ? 3 : i_EOPLW == "4px" ? 4 : 5
AFTOPLW = i_AFTOPLW=="1px" ? 1 : i_AFTOPLW == "2px" ? 2 : i_AFTOPLW == "3px" ? 3 : i_AFTOPLW == "4px" ? 4 : 5
WEEKOPPLW = i_WOPLW=="1px" ? 1 : i_WOPLW == "2px" ? 2 : i_WOPLW == "3px" ? 3 : i_WOPLW == "4px" ? 4 : 5
MONTHOPPLW = i_MONPLW=="1px" ? 1 : i_MONPLW == "2px" ? 2 : i_MONPLW == "3px" ? 3 : i_MONPLW == "4px" ? 4 : 5
// Label Size Function
LabelSize =LabelSizeInput=="Auto" ? size.auto : LabelSizeInput=="Tiny" ? size.tiny : LabelSizeInput=="Small" ? size.small : LabelSizeInput=="Normal" ? size.normal : LabelSizeInput=="Large" ? size.large : size.huge
// Creating Variables
var London_Start_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=LSVLC, width=1)
var London_End_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=LSVLC, width=1)
var LondonFill = linefill.new(London_Start_Vline, London_End_Vline, LSFC)
var NY_Start_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=NYSVLC, width=1)
var NY_End_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=NYSVLC, width=1)
var NYFill = linefill.new(NY_Start_Vline, NY_End_Vline, NYSFC)
var LC_Start_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=NYSVLC, width=1)
var LC_End_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=NYSVLC, width=1)
var LCFill = linefill.new(LC_Start_Vline, LC_End_Vline, LCSFC)
var PM_Start_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=PMSVLC, width=1)
var PM_End_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=PMSVLC, width=1)
var PMFill = linefill.new(PM_Start_Vline, PM_End_Vline, PMSFC)
var Asian_Start_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=ASVLC, width=1)
var Asian_End_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=ASVLC, width=1)
var AsianFill = linefill.new(Asian_Start_Vline, Asian_End_Vline, ASFC)
var Free_Start_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=ASVLC, width=1)
var Free_End_Vline = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=ASVLC, width=1)
var FreeFill = linefill.new(Free_Start_Vline, Free_End_Vline, FSFC)
var Midnight_Open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=MOPColor, width=1)
var London_Open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=LOPColor, width=1)
var NY_Open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=NYOPColor, width=1)
var Equities_Open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=EOPColor, width=1)
// When a New Day Starts, Start Drawing all lines
if newDay and dayofweek != dayofweek.sunday
// London Session
if (ShowLondon and DOM)
if ShowTSO
line.delete(London_Start_Vline[1])
line.delete(London_End_Vline[1])
linefill.delete(LondonFill[1])
London_Start_Vline := vline(LondonStartTime,transparentcol, line.style_solid, 1)
London_End_Vline := vline(LondonEndTime, transparentcol, line.style_solid, 1)
if ShowSFill
LondonFill := linefill.new(London_Start_Vline, London_End_Vline, LSFC)
// New York Session
if (ShowNY and DOM)
if ShowTSO
line.delete(NY_Start_Vline[1])
line.delete(NY_End_Vline[1])
linefill.delete(NYFill[1])
NY_Start_Vline := vline(NYStartTime, transparentcol, line.style_solid, 1)
NY_End_Vline := vline(NYEndTime, transparentcol, line.style_solid, 1)
if ShowSFill
NYFill := linefill.new(NY_Start_Vline, NY_End_Vline, NYSFC)
// London Close
if (ShowLC and DOM)
if ShowTSO
line.delete(LC_End_Vline[1])
linefill.delete(LCFill[1])
LC_Start_Vline := vline(LCStartTime, transparentcol, line.style_solid, 1)
LC_End_Vline := vline(LCEndTime, transparentcol, line.style_solid, 1)
if ShowSFill
LCFill := linefill.new(LC_Start_Vline, LC_End_Vline, LCSFC)
// PM Session
if (ShowPM and DOM)
if ShowTSO
line.delete(PM_Start_Vline[1])
line.delete(PM_End_Vline[1])
linefill.delete(PMFill[1])
PM_Start_Vline := vline(PMStartTime, transparentcol, line.style_solid, 1)
PM_End_Vline := vline(PMEndTime, transparentcol, line.style_solid, 1)
if ShowSFill
PMFill := linefill.new(PM_Start_Vline, PM_End_Vline, PMSFC)
// Asian Session
if (ShowAsian and DOM)
if ShowTSO
line.delete(Asian_Start_Vline[1])
line.delete(Asian_End_Vline[1])
linefill.delete(AsianFill[1])
Asian_Start_Vline := vline(AsianStartTime, transparentcol, line.style_solid, 1)
Asian_End_Vline := vline(AsianEndTime, transparentcol, line.style_solid, 1)
// if dayofweek == dayofweek.friday
// // line.delete(Asian_Start_Vline)
// // line.delete(Asian_End_Vline)
// Asian_Start_Vline := vline(MidnightOpenTime+244800000, transparentcol, line.style_solid, 1)
// Asian_End_Vline := vline(MidnightOpenTime+259200000, transparentcol, line.style_solid, 1)
if ShowSFill
AsianFill := linefill.new(Asian_Start_Vline, Asian_End_Vline, ASFC)
// Free Session
if (ShowFreeSesh and DOM)
if ShowTSO
line.delete(Free_Start_Vline[1])
line.delete(Free_End_Vline[1])
linefill.delete(FreeFill[1])
Free_Start_Vline := vline(FreeStartTime, transparentcol, line.style_solid, 1)
Free_End_Vline := vline(FreeEndTime, transparentcol, line.style_solid, 1)
if ShowSFill
FreeFill := linefill.new(Free_Start_Vline, Free_End_Vline, FSFC)
// Midnight Opening Price
if (ShowMOP and DOM)
if MOLHist == false
line.delete(Midnight_Open[1])
Midnight_Open := vline(MidnightOpenTime, MOPColor, MNOPLS, MOPLW)
// London Opening Price
if (ShowLOP and DOM)
if ShowTSO
line.delete(London_Open[1])
London_Open := vline(LondonOpenTime, LOPColor, LNOPLS, LOPLW)
// New York Opening Price
if (ShowNYOP and DOM)
if ShowTSO
line.delete(NY_Open[1])
NY_Open := vline(NYOpenTime, NYOPColor, NWYOPLS, NYOPLW)
// Equities Opening Price
if (ShowEOP and DOM)
if ShowTSO
line.delete(Equities_Open[1])
Equities_Open := vline(EquitiesOpenTime, EOPColor, EQOPLS, EOPLW)
// Variables
var label MOPLB = na
var line MOPLN = na
var label NYOPLB = na
var line NYOPLN = na
var label EOPLB = na
var line EOPLN = na
var line AFTLN = na
var label AFTLB = na
// New York Midnight Open Price line
var openMidnight = 0.0
if tMidnight
if not tMidnight[1]
openMidnight := open
else
openMidnight := math.max(open, openMidnight)
if (ShowMOPP and (openMidnight != openMidnight[1]) and DOM and barstate.isconfirmed)
label.delete(MOPLB[1])
if ShowMOPL == false
line.delete(MOPLN[1])
MOPLN := line.new(x1=tMidnight, y1=openMidnight, x2=tMidnight+86400000, xloc=xloc.bar_time, y2=openMidnight, color=MOPColP, style=MOPLSS, width=MOPPLW)
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
line.set_x2(MOPLN, tMidnight+259200000)
if ShowLabel
MOPLB := label.new(x=tMidnight+86400000, y=openMidnight, xloc=xloc.bar_time, color=LabelColor, textcolor=MOPColP, style=label.style_label_left, size=LabelSize, tooltip="Midnight Opening Price")
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
label.set_x(MOPLB, tMidnight+259200000)
if ShowLabelText
if SFistrue
if ShowPrices == true
label.set_text(MOPLB, " 00:00 | " + str.tostring(open))
else
label.set_text(MOPLB, " 00:00 ")
label.set_tooltip(MOPLB, "Midnight Opening Price")
else
if ShowPrices == true
label.set_text(MOPLB, " Midnight Opening Price | " + str.tostring(open))
else
label.set_text(MOPLB, " Midnight Opening Price ")
label.set_tooltip(MOPLB, "")
label.set_textcolor(MOPLB, LabelTextColor)
label.set_size(MOPLB,LabelSize)
if time > PMEndTime and time < (MidnightOpenTime + 86400000)
line.delete(MOPLN[0])
if Terminusinp != "Terminus @ Next Midnight" and ShowMOPL == false
line.set_x2(MOPLN, Terminus(Terminusinp))
label.set_x(MOPLB, Terminus(Terminusinp))
// New York Opening Price Line
if (ShowNYOPP and (time == NYOpenTime) and DOM)
label.delete(NYOPLB[1])
if ShowPrev == false
line.delete(NYOPLN[1])
NYOPLN := line.new(x1=NYOpenTime, y1=open, x2=NYOpenTime+55800000, xloc=xloc.bar_time, y2=open, color=NYOPColP, style=NYOPLSS, width=NYOPPLW)
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
line.set_x2(NYOPLN, NYOpenTime+228600000)
if ShowLabel
NYOPLB := label.new(x=NYOpenTime+55800000, y=open, xloc=xloc.bar_time, color=LabelColor, textcolor=NYOPColP, style=label.style_label_left, size=LabelSize, tooltip="New York Opening Price")
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
label.set_x(NYOPLB, NYOpenTime+228600000)
if ShowLabelText
if SFistrue
if ShowPrices == true
label.set_text(NYOPLB, " 08:30 | " + str.tostring(open))
else
label.set_text(NYOPLB, " 08:30 ")
label.set_tooltip(NYOPLB, "New York Opening Price")
else
if ShowPrices == true
label.set_text(NYOPLB, " New York Opening Price | " + str.tostring(open))
else
label.set_text(NYOPLB, " New York Opening Price ")
label.set_tooltip(NYOPLB, "")
label.set_textcolor(NYOPLB, LabelTextColor)
label.set_size(NYOPLB,LabelSize)
if Terminusinp != "Terminus @ Next Midnight" and ShowPrev == false
line.set_x2(NYOPLN, Terminus(Terminusinp))
label.set_x(NYOPLB, Terminus(Terminusinp))
// Equities Opening Price Line
if (ShowEOPP and (time == EquitiesOpenTime) and DOM)
label.delete(EOPLB[1])
if ShowPrev == false
line.delete(EOPLN[1])
EOPLN := line.new(x1=EquitiesOpenTime, y1=open, x2=EquitiesOpenTime+52200000, xloc=xloc.bar_time, y2=open, color=EOPColP, style=EOPLSS, width=EOPPLW)
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
line.set_x2(EOPLN, EquitiesOpenTime+225000000)
if ShowLabel
EOPLB := label.new(x=EquitiesOpenTime+52200000, y=open, xloc=xloc.bar_time, color=LabelColor, textcolor=EOPColP, style=label.style_label_left, size=LabelSize, tooltip="Equities Opening Price")
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
label.set_x(EOPLB, EquitiesOpenTime+225000000)
if ShowLabelText
if SFistrue
if ShowPrices == true
label.set_text(EOPLB, " 09:30 | " + str.tostring(open))
else
label.set_text(EOPLB, " 09:30 ")
label.set_tooltip(EOPLB, "Equities Opening Price")
else
if ShowPrices == true
label.set_text(EOPLB, " Equities Opening Price | " + str.tostring(open))
else
label.set_text(EOPLB, " Equities Opening Price ")
label.set_tooltip(EOPLB, "")
label.set_textcolor(EOPLB, LabelTextColor)
label.set_size(EOPLB,LabelSize)
if Terminusinp != "Terminus @ Next Midnight" and ShowPrev == false
line.set_x2(EOPLN, Terminus(Terminusinp))
label.set_x(EOPLB, Terminus(Terminusinp))
// Afternoon Opening Price Line
if (ShowAFTPP and (time == AfternoonOpenTime) and DOM)
label.delete(AFTLB[1])
if ShowPrev == false
line.delete(AFTLN[1])
AFTLN := line.new(x1=AfternoonOpenTime, y1=open, x2=EquitiesOpenTime+52200000, xloc=xloc.bar_time, y2=open, color=AFTOPColP, style=AFTOPLSS, width=AFTOPLW)
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
line.set_x2(AFTLN, EquitiesOpenTime+225000000)
if ShowLabel
AFTLB := label.new(x=EquitiesOpenTime+52200000, y=open, xloc=xloc.bar_time, color=LabelColor, textcolor=AFTOPColP, style=label.style_label_left, size=LabelSize, tooltip="Equities Opening Price")
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
label.set_x(AFTLB, EquitiesOpenTime+225000000)
if ShowLabelText
if SFistrue
if ShowPrices == true
label.set_text(AFTLB, " 01:30 | " + str.tostring(open))
else
label.set_text(AFTLB, " 01:30 ")
label.set_tooltip(AFTLB, " Afternoon Opening Price")
else
if ShowPrices == true
label.set_text(AFTLB, " Afternoon Opening Price | " + str.tostring(open))
else
label.set_text(AFTLB, " Afternoon Opening Price ")
label.set_tooltip(AFTLB, "")
label.set_textcolor(AFTLB, LabelTextColor)
label.set_size(AFTLB,LabelSize)
if Terminusinp != "Terminus @ Next Midnight" and ShowPrev == false
line.set_x2(AFTLN, Terminus(Terminusinp))
label.set_x(AFTLB, Terminus(Terminusinp))
// HTF Variables
var Weekly_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_WeekOpenCol, style=WeekOpenLS, width=1)
var Weekly_openlbl = label.new(x=na, y=na, xloc=xloc.bar_time, color=LabelColor, textcolor=LabelTextColor, style=label.style_label_left, size=LabelSize)
var WeeklyOpenTime = time
var Monthly_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_MonthOpenCol, style=MonthOpenLS, width=1)
var Monthly_openlbl = label.new(x=na, y=na, xloc=xloc.bar_time, color=LabelColor, textcolor=LabelTextColor, style=label.style_label_left, size=LabelSize)
var MonthlyOpenTime = time
// Get HTF Price levels
WeeklyOpen = request.security(syminfo.tickerid, "W", open, lookahead = barmerge.lookahead_on)
MonthlyOpen = request.security(syminfo.tickerid, "M", open, lookahead = barmerge.lookahead_on)
// Weekly Open
if newWeek
WeeklyOpenTime := time
if ShowWeekOpen and newDay and Last4Weeks
label.delete(Weekly_openlbl[1])
line.delete(Weekly_open[1])
// if ShowPrev == false
// line.delete(Weekly_open[1])
Weekly_open:= line.new(x1=WeeklyOpenTime-25200000, y1=WeeklyOpen, x2=EquitiesOpenTime+52200000, xloc=xloc.bar_time, y2=WeeklyOpen, color=i_WeekOpenCol, style=WeekOpenLS, width=WEEKOPPLW)
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
line.set_x2(Weekly_open, EquitiesOpenTime+225000000)
if ShowLabel
Weekly_openlbl := label.new(x=EquitiesOpenTime+52200000, y=WeeklyOpen, xloc=xloc.bar_time, color=LabelColor, textcolor=LabelTextColor, style=label.style_label_left, size=LabelSize, tooltip="Weekly Open: " + str.tostring(WeeklyOpen))
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
label.set_x(Weekly_openlbl, EquitiesOpenTime+225000000)
if ShowLabelText
if SFistrue
if ShowPrices == true
label.set_text(Weekly_openlbl," W.O. | " + str.tostring(WeeklyOpen))
else
label.set_text(Weekly_openlbl," W.O. ")
label.set_tooltip(Weekly_openlbl, " Weekly Opening Price ")
else
if ShowPrices == true
label.set_text(Weekly_openlbl," Weekly Open | " + str.tostring(WeeklyOpen))
else
label.set_text(Weekly_openlbl," Weekly Open ")
label.set_tooltip(Weekly_openlbl, "")
label.set_textcolor(Weekly_openlbl, LabelTextColor)
label.set_size(Weekly_openlbl, LabelSize)
if timeframe.multiplier > 60
line.set_x2(Weekly_open, AsianEndTime + 232000000)
label.set_x(Weekly_openlbl, AsianEndTime + 232000000)
if timeframe.period == "D"
line.set_x2(Weekly_open, AsianEndTime + 832000000)
label.set_x(Weekly_openlbl, AsianEndTime + 832000000)
if timeframe.period == "M"
line.delete(Weekly_open)
label.delete(Weekly_openlbl)
if Terminusinp != "Terminus @ Next Midnight" and DOM
line.set_x2(Weekly_open, Terminus(Terminusinp))
label.set_x(Weekly_openlbl, Terminus(Terminusinp))
// Monthly Open
if newMonth
MonthlyOpenTime := time
if showMonthOpen and newDay
line.delete(Monthly_open[1])
label.delete(Monthly_openlbl[1])
Monthly_open:= line.new(x1=MonthlyOpenTime, y1=MonthlyOpen, x2=AsianEndTime, xloc=xloc.bar_time, y2=MonthlyOpen, color=i_MonthOpenCol, style=MonthOpenLS, width=MONTHOPPLW)
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
line.set_x2(Monthly_open, EquitiesOpenTime+225000000)
if ShowLabel
Monthly_openlbl := label.new(x=AsianEndTime, y=MonthlyOpen, xloc=xloc.bar_time, color=LabelColor, textcolor=LabelTextColor, style=label.style_label_left, size=LabelSize, tooltip="Monthly Open: " + str.tostring(MonthlyOpen))
if dayofweek == dayofweek.friday and syminfo.type != "crypto"
label.set_x(Monthly_openlbl, EquitiesOpenTime+225000000)
if ShowLabelText
if SFistrue
if ShowPrices == true
label.set_text(Monthly_openlbl," M.O. | " + str.tostring(MonthlyOpen))
else
label.set_text(Monthly_openlbl," M.O. ")
label.set_tooltip(Monthly_openlbl, " Monthly Opening Price ")
else
if ShowPrices == true
label.set_text(Monthly_openlbl, " Monthly Open | " + str.tostring(MonthlyOpen))
else
label.set_text(Monthly_openlbl, " Monthly Open ")
label.set_tooltip(Monthly_openlbl, "")
label.set_textcolor(Monthly_openlbl, LabelTextColor)
label.set_size(Monthly_openlbl, LabelSize)
if timeframe.multiplier > 60
line.set_x2(Monthly_open, AsianEndTime + 232000000)
label.set_x(Monthly_openlbl, AsianEndTime + 232000000)
if timeframe.period == "D"
line.set_x2(Monthly_open, AsianEndTime + 832000000)
label.set_x(Monthly_openlbl, AsianEndTime + 832000000)
if timeframe.period == "W"
line.set_x2(Monthly_open, AsianEndTime + 2592000000)
label.set_x(Monthly_openlbl, AsianEndTime + 2592000000)
if timeframe.period == "M"
line.delete(Monthly_open)
label.delete(Monthly_openlbl)
if Terminusinp != "Terminus @ Next Midnight" and DOM
line.set_x2(Monthly_open, Terminus(Terminusinp))
label.set_x(Monthly_openlbl, Terminus(Terminusinp))
// CBDR Stuff
var float cbdr_hi = na
var float cbdr_lo = na
var float cbdr_diff = na
var box cbdrbox = na
var line cbdr_hi_line = na
var line cbdr_lo_line = na
var line dev01negline = na
var line dev02negline = na
var line dev03negline = na
var line dev04negline = na
var line dev01posline = na
var line dev02posline = na
var line dev03posline = na
var line dev04posline = na
if SessionBegins(CBDR) and DOM
cbdr_hi := high
cbdr_lo := low
cbdr_diff := cbdr_hi - cbdr_lo
if ShowTSO
box.delete(cbdrbox[1])
line.delete(dev01posline[1])
line.delete(dev01negline[1])
line.delete(dev02posline[1])
line.delete(dev02negline[1])
line.delete(dev03posline[1])
line.delete(dev03negline[1])
line.delete(dev04posline[1])
line.delete(dev04negline[1])
if ShowCBDR
cbdrbox := box.new(cbdrOpenTime, cbdr_hi, cbdrEndTime, cbdr_lo, color.new(CBDRBoxCol,90), 1, line.style_solid, extend.none, xloc.bar_time, color.new(CBDRBoxCol,90), txt0, size.auto, color.new(box_text_cbdr_col,80), text_wrap=text.wrap_auto)
if dayofweek == dayofweek.friday
box.set_right(cbdrbox, cbdrOpenTime+187200000)
line.set_x2(cbdr_hi_line, cbdrOpenTime+187200000)
line.set_x2(cbdr_lo_line, cbdrOpenTime+187200000)
if box_text_cbdr == false
box.set_text(cbdrbox, "")
if ShowDev and ShowCBDR and bool_cbdr_dev
for i = 1 to DevCount by 1
if i == 1
dev01posline := line.new(cbdrOpenTime, cbdr_hi + cbdr_diff * i, cbdrEndTime, cbdr_hi + cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev01negline := line.new(cbdrOpenTime, cbdr_hi - cbdr_diff * i, cbdrEndTime, cbdr_lo - cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev01posline, cbdrOpenTime+187200000)
line.set_x2(dev01negline, cbdrOpenTime+187200000)
if i == 2
dev02posline := line.new(cbdrOpenTime, cbdr_hi + cbdr_diff * i, cbdrEndTime, cbdr_lo + cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev02negline := line.new(cbdrOpenTime, cbdr_hi - cbdr_diff * i, cbdrEndTime, cbdr_lo - cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev02posline, cbdrOpenTime+187200000)
line.set_x2(dev02negline, cbdrOpenTime+187200000)
if i == 3
dev03posline := line.new(cbdrOpenTime, cbdr_hi + cbdr_diff * i, cbdrEndTime, cbdr_lo + cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev03negline := line.new(cbdrOpenTime, cbdr_hi - cbdr_diff * i, cbdrEndTime, cbdr_lo - cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev03posline, cbdrOpenTime+187200000)
line.set_x2(dev03negline, cbdrOpenTime+187200000)
if i == 4
dev04posline := line.new(cbdrOpenTime, cbdr_hi + cbdr_diff * i, cbdrEndTime, cbdr_lo + cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev04negline := line.new(cbdrOpenTime, cbdr_hi - cbdr_diff * i, cbdrEndTime, cbdr_lo - cbdr_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev04posline, cbdrOpenTime+187200000)
line.set_x2(dev04negline, cbdrOpenTime+187200000)
else if CBDRTime
cbdr_hi := math.max(high, cbdr_hi)
cbdr_lo := math.min(low, cbdr_lo)
cbdr_diff := cbdr_hi - cbdr_lo
for i = 1 to DevCount by 1
if i == 1 and ShowDev
line.set_y1(dev01posline, cbdr_hi + cbdr_diff * i)
line.set_y2(dev01posline, cbdr_hi + cbdr_diff * i)
line.set_y1(dev01negline, cbdr_lo - cbdr_diff * i)
line.set_y2(dev01negline, cbdr_lo - cbdr_diff * i)
if i == 2 and ShowDev
line.set_y1(dev02posline, cbdr_hi + cbdr_diff * i)
line.set_y2(dev02posline, cbdr_hi + cbdr_diff * i)
line.set_y1(dev02negline, cbdr_lo - cbdr_diff * i)
line.set_y2(dev02negline, cbdr_lo - cbdr_diff * i)
if i == 3 and ShowDev
line.set_y1(dev03posline, cbdr_hi + cbdr_diff * i)
line.set_y2(dev03posline, cbdr_hi + cbdr_diff * i)
line.set_y1(dev03negline, cbdr_lo - cbdr_diff * i)
line.set_y2(dev03negline, cbdr_lo - cbdr_diff * i)
if i == 4 and ShowDev
line.set_y1(dev04posline, cbdr_hi + cbdr_diff * i)
line.set_y2(dev04posline, cbdr_hi + cbdr_diff * i)
line.set_y1(dev04negline, cbdr_lo - cbdr_diff * i)
line.set_y2(dev04negline, cbdr_lo - cbdr_diff * i)
if (cbdr_hi > cbdr_hi[1])
if ShowCBDR
box.set_top(cbdrbox, cbdr_hi)
if (cbdr_lo < cbdr_lo[1])
if ShowCBDR
box.set_bottom(cbdrbox, cbdr_lo)
if DevDirection == "Upside Only"
line.delete(dev01negline)
line.delete(dev02negline)
line.delete(dev03negline)
line.delete(dev04negline)
else if DevDirection == "Downside Only"
line.delete(dev01posline)
line.delete(dev02posline)
line.delete(dev03posline)
line.delete(dev04posline)
// ASIA Stuff
var float asia_hi = na
var float asia_lo = na
var float asia_diff = na
var box asia_box = na
var line asia_hi_line = na
var line asia_lo_line = na
var line dev01negline_asia = na
var line dev02negline_asia = na
var line dev03negline_asia = na
var line dev04negline_asia = na
var line dev01posline_asia = na
var line dev02posline_asia = na
var line dev03posline_asia = na
var line dev04posline_asia = na
if SessionBegins(ASIA) and DOM
asia_hi := high
asia_lo := low
asia_diff := asia_hi - asia_lo
if ShowTSO
box.delete(asia_box[1])
line.delete(dev01posline_asia[1])
line.delete(dev01negline_asia[1])
line.delete(dev02posline_asia[1])
line.delete(dev02negline_asia[1])
line.delete(dev03posline_asia[1])
line.delete(dev03negline_asia[1])
line.delete(dev04posline_asia[1])
line.delete(dev04negline_asia[1])
if ShowASIA
asia_box := box.new(asiaOpenTime, asia_hi, asiaEndTime, asia_lo, color.new(ASIABoxCol,90), 1, line.style_solid, extend.none, xloc.bar_time, color.new(ASIABoxCol,90), txt1, size.auto, color.new(box_text_asia_col,80), text_wrap=text.wrap_auto)
if box_text_asia == false
box.set_text(asia_box, "")
if ShowDev and ShowASIA and bool_asia_dev
for i = 1 to DevCount by 1
if i == 1
dev01posline_asia := line.new(asiaOpenTime, asia_hi + asia_diff * i, asiaEndTime, asia_hi + asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev01negline_asia := line.new(asiaOpenTime, asia_hi - asia_diff * i, asiaEndTime, asia_lo - asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if i == 2
dev02posline_asia := line.new(asiaOpenTime, asia_hi + asia_diff * i, asiaEndTime, asia_lo + asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev02negline_asia := line.new(asiaOpenTime, asia_hi - asia_diff * i, asiaEndTime, asia_lo - asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if i == 3
dev03posline_asia := line.new(asiaOpenTime, asia_hi + asia_diff * i, asiaEndTime, asia_lo + asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev03negline_asia := line.new(asiaOpenTime, asia_hi - asia_diff * i, asiaEndTime, asia_lo - asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if i == 4
dev04posline_asia := line.new(asiaOpenTime, asia_hi + asia_diff * i, asiaEndTime, asia_lo + asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev04negline_asia := line.new(asiaOpenTime, asia_hi - asia_diff * i, asiaEndTime, asia_lo - asia_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
else if ASIATime
asia_hi := math.max(high, asia_hi)
asia_lo := math.min(low, asia_lo)
asia_diff := asia_hi - asia_lo
for i = 1 to DevCount by 1
if i == 1 and ShowDev
line.set_y1(dev01posline_asia, asia_hi + asia_diff * i)
line.set_y2(dev01posline_asia, asia_hi + asia_diff * i)
line.set_y1(dev01negline_asia, asia_lo - asia_diff * i)
line.set_y2(dev01negline_asia, asia_lo - asia_diff * i)
if i == 2 and ShowDev
line.set_y1(dev02posline_asia, asia_hi + asia_diff * i)
line.set_y2(dev02posline_asia, asia_hi + asia_diff * i)
line.set_y1(dev02negline_asia, asia_lo - asia_diff * i)
line.set_y2(dev02negline_asia, asia_lo - asia_diff * i)
if i == 3 and ShowDev
line.set_y1(dev03posline_asia, asia_hi + asia_diff * i)
line.set_y2(dev03posline_asia, asia_hi + asia_diff * i)
line.set_y1(dev03negline_asia, asia_lo - asia_diff * i)
line.set_y2(dev03negline_asia, asia_lo - asia_diff * i)
if i == 4 and ShowDev
line.set_y1(dev04posline_asia, asia_hi + asia_diff * i)
line.set_y2(dev04posline_asia, asia_hi + asia_diff * i)
line.set_y1(dev04negline_asia, asia_lo - asia_diff * i)
line.set_y2(dev04negline_asia, asia_lo - asia_diff * i)
if (asia_hi > asia_hi[1])
box.set_top(asia_box, asia_hi)
if (asia_lo < asia_lo[1])
box.set_bottom(asia_box, asia_lo)
if DevDirection == "Upside Only"
line.delete(dev01negline_asia)
line.delete(dev02negline_asia)
line.delete(dev03negline_asia)
line.delete(dev04negline_asia)
else if DevDirection == "Downside Only"
line.delete(dev01posline_asia)
line.delete(dev02posline_asia)
line.delete(dev03posline_asia)
line.delete(dev04posline_asia)
// FLOUT Stuff
var float flout_hi = na
var float flout_lo = na
var float flout_diff = na
var box floutbox = na
var line flout_hi_line = na
var line flout_lo_line = na
var line dev01negline_flout = na
var line dev02negline_flout = na
var line dev03negline_flout = na
var line dev04negline_flout = na
var line dev01posline_flout = na
var line dev02posline_flout = na
var line dev03posline_flout = na
var line dev04posline_flout = na
if SessionBegins(FLOUT) and DOM
flout_hi := high
flout_lo := low
flout_diff := flout_hi - flout_lo
if ShowTSO
box.delete(floutbox[1])
line.delete(dev01posline_flout[1])
line.delete(dev01negline_flout[1])
line.delete(dev02posline_flout[1])
line.delete(dev02negline_flout[1])
line.delete(dev03posline_flout[1])
line.delete(dev03negline_flout[1])
line.delete(dev04posline_flout[1])
line.delete(dev04negline_flout[1])
if ShowFLOUT
floutbox := box.new(floutOpenTime, flout_hi, floutEndTime, flout_lo, color.new(FLOUTBoxCol,90), 1, line.style_solid, extend.none, xloc.bar_time, color.new(FLOUTBoxCol,90), txt7, size.auto, color.new(box_text_flout_col,80), text_wrap=text.wrap_auto)
if dayofweek == dayofweek.friday
box.set_right(floutbox, floutOpenTime+201600000)
line.set_x2(flout_hi_line, floutOpenTime+201600000)
line.set_x2(flout_lo_line, floutOpenTime+201600000)
if box_text_cbdr == false
box.set_text(floutbox, "")
if ShowDev and ShowFLOUT and bool_flout_dev
for i = 0.5 to DevCount by 0.5
if i == 0.5
dev01posline_flout := line.new(floutOpenTime, flout_hi + flout_diff * i, floutEndTime, flout_hi + flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev01negline_flout := line.new(floutOpenTime, flout_hi - flout_diff * i, floutEndTime, flout_lo - flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev01posline_flout, floutOpenTime+201600000)
line.set_x2(dev01negline_flout, floutOpenTime+201600000)
if i == 1
dev02posline_flout := line.new(floutOpenTime, flout_hi + flout_diff * i, floutEndTime, flout_lo + flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev02negline_flout := line.new(floutOpenTime, flout_hi - flout_diff * i, floutEndTime, flout_lo - flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev02posline_flout, floutOpenTime+201600000)
line.set_x2(dev02negline_flout, floutOpenTime+201600000)
if i == 1.5
dev03posline_flout := line.new(floutOpenTime, flout_hi + flout_diff * i, floutEndTime, flout_lo + flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev03negline_flout := line.new(floutOpenTime, flout_hi - flout_diff * i, floutEndTime, flout_lo - flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev03posline_flout, floutOpenTime+201600000)
line.set_x2(dev03negline_flout, floutOpenTime+201600000)
if i == 2
dev04posline_flout := line.new(floutOpenTime, flout_hi + flout_diff * i, floutEndTime, flout_lo + flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
dev04negline_flout := line.new(floutOpenTime, flout_hi - flout_diff * i, floutEndTime, flout_lo - flout_diff * i, xloc=xloc.bar_time, color=DevLNCol, style=DEVLSS, width=DEVLW)
if dayofweek == dayofweek.friday
line.set_x2(dev04posline_flout, floutOpenTime+201600000)
line.set_x2(dev04negline_flout, floutOpenTime+201600000)
else if FLOUTTime
flout_hi := math.max(high, flout_hi)
flout_lo := math.min(low, flout_lo)
flout_diff := flout_hi - flout_lo
for i = 0.5 to DevCount by 0.5
if i == 0.5 and ShowDev
line.set_y1(dev01posline_flout, flout_hi + flout_diff * i)
line.set_y2(dev01posline_flout, flout_hi + flout_diff * i)
line.set_y1(dev01negline_flout, flout_lo - flout_diff * i)
line.set_y2(dev01negline_flout, flout_lo - flout_diff * i)
if i == 1 and ShowDev
line.set_y1(dev02posline_flout, flout_hi + flout_diff * i)
line.set_y2(dev02posline_flout, flout_hi + flout_diff * i)
line.set_y1(dev02negline_flout, flout_lo - flout_diff * i)
line.set_y2(dev02negline_flout, flout_lo - flout_diff * i)
if i == 1.5 and ShowDev
line.set_y1(dev03posline_flout, flout_hi + flout_diff * i)
line.set_y2(dev03posline_flout, flout_hi + flout_diff * i)
line.set_y1(dev03negline_flout, flout_lo - flout_diff * i)
line.set_y2(dev03negline_flout, flout_lo - flout_diff * i)
if i == 2 and ShowDev
line.set_y1(dev04posline_flout, flout_hi + flout_diff * i)
line.set_y2(dev04posline_flout, flout_hi + flout_diff * i)
line.set_y1(dev04negline_flout, flout_lo - flout_diff * i)
line.set_y2(dev04negline_flout, flout_lo - flout_diff * i)
if (flout_hi > flout_hi[1])
box.set_top(floutbox, flout_hi)
if (flout_lo < flout_lo[1])
box.set_bottom(floutbox, flout_lo)
if DevDirection == "Upside Only"
line.delete(dev01negline_flout)
line.delete(dev02negline_flout)
line.delete(dev03negline_flout)
line.delete(dev04negline_flout)
else if DevDirection == "Downside Only"
line.delete(dev01posline_flout)
line.delete(dev02posline_flout)
line.delete(dev03posline_flout)
line.delete(dev04posline_flout)
// Start of Table
cbdrpipc = toWhole(cbdr_diff)
asiapipc = toWhole(asia_diff)
var color cbdr_cellt_col = na
var color asia_cellt_col = na
var color L_profile_col = na
var color comp_green = color.new(#1cac78,0)
var color comp_red = color.new(#ff4040,0)
var color comp_gray = color.new(#808080,0)
var L_Profile = ""
if cbdrpipc > 15 and cbdrpipc < 40
cbdr_cellt_col := color.new(#1cac78,0) // Green
else
cbdr_cellt_col := color.new(#ff4040,0) // Red
if asiapipc >= 20 and asiapipc <= 40
asia_cellt_col := color.new(#1cac78,0) // Green
else
asia_cellt_col := color.new(#ff4040,0) // Red
if cbdrpipc > 15 and cbdrpipc < 40
L_Profile := "CBDR"
L_profile_col := Tab1txtCol
else if asiapipc >= 20 and asiapipc <= 40
L_Profile := "ASIA"
L_profile_col := Tab1txtCol
else
L_Profile := "FLOUT"
L_profile_col := Tab1txtCol
if BarInSession(midsesh) and Auto_Select == true and syminfo.type == "forex"
if cbdrpipc > 15 and cbdrpipc < 40
// ASIA
box.delete(asia_box)
line.delete(dev01posline_asia)
line.delete(dev01negline_asia)
line.delete(dev02posline_asia)
line.delete(dev02negline_asia)
line.delete(dev03posline_asia)
line.delete(dev03negline_asia)
line.delete(dev04posline_asia)
line.delete(dev04negline_asia)
// FLOUT
box.delete(floutbox)
line.delete(dev01posline_flout)
line.delete(dev01negline_flout)
line.delete(dev02posline_flout)
line.delete(dev02negline_flout)
line.delete(dev03posline_flout)
line.delete(dev03negline_flout)
line.delete(dev04posline_flout)
line.delete(dev04negline_flout)
else if asiapipc >= 20 and asiapipc <= 40
// CBDR
box.delete(cbdrbox)
line.delete(dev01posline)
line.delete(dev01negline)
line.delete(dev02posline)
line.delete(dev02negline)
line.delete(dev03posline)
line.delete(dev03negline)
line.delete(dev04posline)
line.delete(dev04negline)
// FLOUT
box.delete(floutbox)
line.delete(dev01posline_flout)
line.delete(dev01negline_flout)
line.delete(dev02posline_flout)
line.delete(dev02negline_flout)
line.delete(dev03posline_flout)
line.delete(dev03negline_flout)
line.delete(dev04posline_flout)
line.delete(dev04negline_flout)
else
// CBDR
box.delete(cbdrbox)
line.delete(dev01posline)
line.delete(dev01negline)
line.delete(dev02posline)
line.delete(dev02negline)
line.delete(dev03posline)
line.delete(dev03negline)
line.delete(dev04posline)
line.delete(dev04negline)
// ASIA
box.delete(asia_box)
line.delete(dev01posline_asia)
line.delete(dev01negline_asia)
line.delete(dev02posline_asia)
line.delete(dev02negline_asia)
line.delete(dev03posline_asia)
line.delete(dev03negline_asia)
line.delete(dev04posline_asia)
line.delete(dev04negline_asia)
// Table
var table ICTInfo = table.new(tabinp1, 2, 3, border_width=1)
if barstate.islast and syminfo.type == "forex" and Stats and DOM and (dayofweek != dayofweek.sunday)
CBDR_cell = "CBDR "
Asia_cell = "Asian Range "
CBDR_cell_pipc = " " + str.tostring(cbdrpipc) + " pips"
ASIA_cell_pipc = " " + str.tostring(asiapipc) + " pips"
if L_Prof == true
table.cell(ICTInfo, 0, 0, text=" Suggested SD ", bgcolor=CellBG, text_color=Tab1txtCol, text_halign=text.align_left, text_size=size.auto)
table.cell(ICTInfo, 0, 1, text=" Asian Range ", bgcolor=CellBG, text_color=Tab1txtCol, text_halign=text.align_left, text_size=size.auto)
table.cell(ICTInfo, 0, 2, text=" CBDR ", bgcolor=CellBG, text_color=Tab1txtCol, text_halign=text.align_left, text_size=size.auto)
if L_Prof == true
table.cell(ICTInfo, 1, 0, text=" "+ L_Profile + " ", bgcolor=CellBG, text_color=L_profile_col, text_halign=text.align_right, text_size=size.auto)
table.cell(ICTInfo, 1, 1, text=ASIA_cell_pipc, bgcolor=CellBG, text_color=asia_cellt_col, text_size=size.auto, text_halign=text.align_right)
table.cell(ICTInfo, 1, 2, text=CBDR_cell_pipc, bgcolor=CellBG, text_color=cbdr_cellt_col, text_size=size.auto, text_halign=text.align_right)
// Color Coding
var color Option1CC = na
var color Option2CC = na
var color Option3CC = na
var color Option4CC = na
if BIASOption1 == "Bullish"
Option1CC := comp_green
else if BIASOption1 == "Bearish"
Option1CC := comp_red
else
Option1CC := Tab2txtCol
if BIASOption2 == "Bullish"
Option2CC := comp_green
else if BIASOption2 == "Bearish"
Option2CC := comp_red
else
Option2CC := Tab2txtCol
if BIASOption3 == "Bullish"
Option3CC := comp_green
else if BIASOption3 == "Bearish"
Option3CC := comp_red
else
Option3CC := Tab2txtCol
if BIASOption4 == "Bullish"
Option4CC := comp_green
else if BIASOption4 == "Bearish"
Option4CC := comp_red
else
Option4CC := Tab2txtCol
var table BIAS_Table = table.new(tabinp2, 2, 20, bgcolor=TableBG2, border_width=1)
if barstate.islast and BIAS_M_Bool
if BIASbool1
table.cell(BIAS_Table, 0, 1, text = txt52, text_color = Tab2txtCol, text_halign=text.align_left)
table.cell(BIAS_Table, 1, 1, text = BIASOption1, text_size = size.normal, text_color = Option1CC, text_halign=text.align_right)
if BIASbool2
table.cell(BIAS_Table, 0, 2, text = txt53, text_color = Tab2txtCol, text_halign=text.align_left)
table.cell(BIAS_Table, 1, 2, text = BIASOption2, text_size = size.normal, text_color = Option2CC, text_halign=text.align_right)
if BIASbool3
table.cell(BIAS_Table, 0, 3, text = txt54, text_color = Tab2txtCol, text_halign=text.align_left)
table.cell(BIAS_Table, 1, 3, text = BIASOption3, text_size = size.normal, text_color = Option3CC, text_halign=text.align_right)
if BIASbool4
table.cell(BIAS_Table, 0, 4, text = txt55, text_color = Tab2txtCol, text_halign=text.align_left)
table.cell(BIAS_Table, 1, 4, text = BIASOption4, text_size = size.normal, text_color = Option4CC, text_halign=text.align_right)
var table NOTES_Table = table.new(tabinp3, 1, 20, bgcolor = TableBG2, border_width = 1)
if barstate.islast and NOTES_M_Bool
table.cell(NOTES_Table, 0,0, text = notes, text_size = size.normal, text_color = Tab3txtCol, text_halign=text.align_center)
// Day of the Week
txtMon = "M O N"
txtTue = "T U E"
txtWed = "W E D"
txtThu = "T H U"
txtFri = "F R I"
txtSat = "S A T"
txtSun = "S U N"
plotchar(showDOW and DOM and SL4W and Last4Weeks and (not ShowTWO)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.monday : false, offset=0, char=" ", text=txtMon , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and SL4W and Last4Weeks and (not ShowTWO)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.tuesday : false, offset=0, char=" ", text=txtTue , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and SL4W and Last4Weeks and (not ShowTWO)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.wednesday : false, offset=0, char=" ", text=txtWed , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and SL4W and Last4Weeks and (not ShowTWO)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.thursday : false, offset=0, char=" ", text=txtThu , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and SL4W and Last4Weeks and (not ShowTWO)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.friday : false, offset=0, char=" ", text=txtFri , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and ShowTWO and thisweek? hour == DOWTime and minute == 0 and dayofweek == dayofweek.monday : false, offset=0, char=" ", text=txtMon , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and ShowTWO and thisweek? hour == DOWTime and minute == 0 and dayofweek == dayofweek.tuesday : false, offset=0, char=" ", text=txtTue , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and ShowTWO and thisweek? hour == DOWTime and minute == 0 and dayofweek == dayofweek.wednesday : false, offset=0, char=" ", text=txtWed , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and ShowTWO and thisweek? hour == DOWTime and minute == 0 and dayofweek == dayofweek.thursday : false, offset=0, char=" ", text=txtThu , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and ShowTWO and thisweek? hour == DOWTime and minute == 0 and dayofweek == dayofweek.friday : false, offset=0, char=" ", text=txtFri , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and (not ShowTWO) and (not SL4W)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.monday : false, offset=0, char=" ", text=txtMon , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and (not ShowTWO) and (not SL4W)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.tuesday : false, offset=0, char=" ", text=txtTue , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and (not ShowTWO) and (not SL4W)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.wednesday : false, offset=0, char=" ", text=txtWed , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and (not ShowTWO) and (not SL4W)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.thursday : false, offset=0, char=" ", text=txtThu , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
plotchar(showDOW and DOM and (not ShowTWO) and (not SL4W)? hour == DOWTime and minute == 0 and dayofweek == dayofweek.friday : false, offset=0, char=" ", text=txtFri , color=color.new(i_DOWCol,100), location = DOWLoc, textcolor=i_DOWCol, editable=false)
// plotshape(ShowLondon? BarInSession(LDNsesh) : false, style = shape.square, size=size.auto, location =location.bottom, color = LSFC)
var int daycount = 0
var int SL4WC = 0
if SL4W == true
if dayofweek == dayofweek.monday
SL4WC := 0 + 28
if dayofweek == dayofweek.tuesday
SL4WC := 1 + 28
if dayofweek == dayofweek.wednesday
SL4WC := 2 + 28
if dayofweek == dayofweek.thursday
SL4WC := 3 + 28
if dayofweek == dayofweek.friday
SL4WC := 4 + 28
if dayofweek == dayofweek.saturday
SL4WC := 5 + 28
if dayofweek == dayofweek.sunday
SL4WC := 6 + 28
if SL4W
Cleanup(SL4WC)
if ShowTWO
if dayofweek == dayofweek.monday
daycount := 0
if dayofweek == dayofweek.tuesday
daycount := 1
if dayofweek == dayofweek.wednesday
daycount := 2
if dayofweek == dayofweek.thursday
daycount := 3
if dayofweek == dayofweek.friday
daycount := 4
if dayofweek == dayofweek.saturday
daycount := 5
if dayofweek == dayofweek.sunday
daycount := 6
if ShowTWO
Cleanup(daycount) |
Ichimoku [2022] [v5] [keivanipchihagh] | https://www.tradingview.com/script/ytn1TQxd-Ichimoku-2022-v5-keivanipchihagh/ | keivanipchihagh | https://www.tradingview.com/u/keivanipchihagh/ | 60 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © keivanipchihagh
//@version=5
indicator(title = "Ichimoku", overlay = true, timeframe = "", timeframe_gaps = true)
// Inputs
TK_show = input.bool(true, title = '', inline = '1') // Show Tenkan sen
TK_length = input.int(9, title = "Tenkan sen", minval = 1, inline = '1', tooltip = 'Also known as Conversion Line') // Tenkan sen
KJ_show = input.bool(true, title = '', inline = '2') // Show Kijun sen
KJ_length = input.int(26, title = "Kijun sen", minval = 1, inline = '2', tooltip = 'Also known as Base Line') // Kijun sen
CH_show = input.bool(true, title = '', inline = '5') // Show Chikou span
CH_length = input.int(26, title = "Chikou span", minval = 1, inline = '5', tooltip = 'Also known as Lagging Span') // Chikou span
SA_show = input.bool(true, title = '', inline = '3') // Show Sankou span A
SA_length = input.int(26, title = "Senkou span A", minval = 1, inline = '3', tooltip = 'Also known as Leading Span A') // Sankou span A
SB_show = input.bool(true, title = '', inline = '4') // Show Sankou span B
SB_length = input.int(52, title = "Senkou span B", minval = 1, inline = '4', tooltip = 'Also known as Leading Span B') // Sankou span B
TK_KJ_cross_show = input.bool(true, title = 'Tenkan-Sen & Kijun-Sen crossovers') // Tenkan-Sen & Kijun-Sen crossovers
_104_show = input.bool(false, title = '104 line (x4 times the timeframe)') // Show 104 line
_208_show = input.bool(false, title = '208 line (x8 times the timeframe)') // Show 208 line
QL_show = input.bool(false, title = 'Quality line') // Quality line
// Calculations
TK = TK_show ? math.avg(ta.lowest(TK_length), ta.highest(TK_length)) : na // Tenkan sen
KJ = KJ_show ? math.avg(ta.lowest(KJ_length), ta.highest(KJ_length)) : na // Kijun sen
SB = SB_show ? math.avg(ta.lowest(SB_length), ta.highest(SB_length)) : na // Sankou span B
SA = SA_show ? math.avg(TK, KJ) : na // Sankou span A
CH = CH_show ? close : na // Chikou span
_104 = _104_show ? math.avg(ta.lowest(104), ta.highest(104)) : na // 104 line
_208 = _208_show ? math.avg(ta.lowest(208), ta.highest(208)) : na // 208 line
TK_KJ_cross_up = TK_KJ_cross_show ? ta.crossover(TK, KJ) : na // Tenkan-Sen & Kijun-Sen upwards crossover
TK_KJ_cross_down = TK_KJ_cross_show ? ta.crossover(KJ, TK) : na // Tenkan-Sen & Kijun-Sen downwards crossover
// Colors
TK_color = color.new(#B22833, 0) // Tanken sen
KJ_color = color.new(#1848CC, 0) // Kijun sen
CH_color = color.new(#056656, 0) // Chikous span
SA_color = color.new(#4CAF50, 50) // Sankou span A
SB_color = color.new(#FF0000, 40) // Sankou span B
GK_color = color.new(#4CAF50, 85) // Green Komu cloud
RK_color = color.new(#FF0000, 85) // Red Kumo cloud
_104_color = color.new(#9C27B0, 20) // 104 line
_108_color = color.new(#9C27B0, 30) // 208 line
QL_color = color.new(#FF9800, 0) // Quality line
// Plots
plot(TK, linewidth = 2, color = TK_color, title = "Tenkan sen") // Tenkan sen
plot(KJ, linewidth = 2, color = KJ_color, title = "Kijun sen") // Kijun sen
plot(CH, offset = -CH_length, linewidth = 1, color = CH_color, title = "Chikou span") // Chikou span
SenkouA = plot(SA, offset = CH_length, linewidth = 1, color = SA_color, title = "Senkou span A") // Senkou span A
SenkouB = plot(SB, offset = CH_length, linewidth = 1, color = SB_color, title = "Senkou span B") // Senkou span B
fill(SenkouA, SenkouB, title = 'Kumo cloud', color = SA > SB ? GK_color : RK_color) // Kumo cloud
plot(_104, linewidth = 2, color = _104_color, title = "104 line") // 104 line
plot(_208, linewidth = 4, color = _108_color, title = "208 line") // 208 line
plot(QL_show ? KJ : na, linewidth = 1, offset = 26, color = QL_color, title = "Quality line") // Quality line
bgcolor(TK_KJ_cross_up ? GK_color : na, offset = -1, title = 'Upwards Tenkan sen & Kijun sen crossover') // Tenkan-Sen & Kijun-Sen upwards crossover
bgcolor(TK_KJ_cross_down ? RK_color : na, offset = -1, title = 'Downwards Tenkan sen & Kijun sen crossover') // Tenkan-Sen & Kijun-Sen downwards crossover |
NSE Bank Nifty - Constituent Strength | https://www.tradingview.com/script/oNbxMUZq-NSE-Bank-Nifty-Constituent-Strength/ | Sharad_Gaikwad | https://www.tradingview.com/u/Sharad_Gaikwad/ | 74 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sharad_Gaikwad
//BEGIN {
//@version=5
indicator("NSE Bank Nifty - Constituent Strength", overlay=false)
// Input parameters {
src = input.source(title = 'Data Source', defval = close)
tf = input.timeframe(title = 'Timeframe', defval = 'D')
ma_type = input.string(title = 'Moving average type', defval = 'SMA', options = ['SMA', 'EMA'])
ma_len = input.int(title = 'Moving average length', defval = 20)
show_chart = input.string(title = 'Show line chart for', defval = 'S1', options = ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'S11', 'S12'])
s1 = input('NSE:HDFCBANK')
s2 = input('NSE:ICICIBANK')
s3 = input('NSE:KOTAKBANK')
s4 = input('NSE:AXISBANK')
s5 = input('NSE:SBIN')
s6 = input('NSE:INDUSINDBK')
s7 = input('NSE:AUBANK')
s8 = input('NSE:BANDHANBNK')
s9 = input('NSE:FEDERALBNK')
s10 = input('NSE:IDFCFIRSTB')
s11 = input('NSE:PNB')
s12 = input('NSE:RBLBANK')
// } Input parameters
//Common functions {
tab = table.new(position=position.bottom_left, columns=2, rows=6,frame_color = color.yellow, frame_width = 1, border_color = color.blue, border_width = 1)
msg(int row, int col, string msg_str, clr=color.blue) =>
table.cell(table_id=tab, column=col, row=row, text=msg_str, text_color=clr)
tab1 = table.new(position=position.top_center, columns=1, rows=1,frame_color = color.yellow, frame_width = 1, border_color = color.blue, border_width = 1)
msg1(int row, int col, string msg_str, clr=color.blue) =>
table.cell(table_id=tab1, column=col, row=row, text=msg_str, text_color=clr)
t(_val) =>
ret_val = str.tostring(_val)
strength(ind_price, element_price, symbol_code) =>
cmp_strength = element_price / ind_price
ma_strength = ma_type == 'SMA' ? ta.sma(element_price / ind_price, ma_len) : ta.ema(element_price / ind_price, ma_len)
s_color = cmp_strength > ma_strength ? color.green : cmp_strength < ma_strength ? color.red : color.blue
show_plot = show_chart == symbol_code ? true : false
[s_color, cmp_strength, ma_strength, show_plot]
// } Common functions
//Data collection {
ind_cmp = request.security("NSE:BANKNIFTY", tf, src)
[s1_strength, s1_cmp, s1_ma, s1_plot] = request.security(s1, tf, strength(ind_cmp, src, 'S1'))
[s2_strength, s2_cmp, s2_ma, s2_plot] = request.security(s2, tf, strength(ind_cmp, src, 'S2'))
[s3_strength, s3_cmp, s3_ma, s3_plot] = request.security(s3, tf, strength(ind_cmp, src, 'S3'))
[s4_strength, s4_cmp, s4_ma, s4_plot] = request.security(s4, tf, strength(ind_cmp, src, 'S4'))
[s5_strength, s5_cmp, s5_ma, s5_plot] = request.security(s5, tf, strength(ind_cmp, src, 'S5'))
[s6_strength, s6_cmp, s6_ma, s6_plot] = request.security(s6, tf, strength(ind_cmp, src, 'S6'))
[s7_strength, s7_cmp, s7_ma, s7_plot] = request.security(s7, tf, strength(ind_cmp, src, 'S7'))
[s8_strength, s8_cmp, s8_ma, s8_plot] = request.security(s8, tf, strength(ind_cmp, src, 'S8'))
[s9_strength, s9_cmp, s9_ma, s9_plot] = request.security(s9, tf, strength(ind_cmp, src, 'S9'))
[s10_strength, s10_cmp, s10_ma, s10_plot] = request.security(s10, tf, strength(ind_cmp, src, 'S10'))
[s11_strength, s11_cmp, s11_ma, s11_plot] = request.security(s11, tf, strength(ind_cmp, src, 'S11'))
[s12_strength, s12_cmp, s12_ma, s12_plot] = request.security(s12, tf, strength(ind_cmp, src, 'S12'))
// } Data collection
//Display data {
msg(0, 0, syminfo.ticker(s1), s1_strength)
msg(0, 1, syminfo.ticker(s2), s2_strength)
msg(1, 0, syminfo.ticker(s3), s3_strength)
msg(1, 1, syminfo.ticker(s4), s4_strength)
msg(2, 0, syminfo.ticker(s5), s5_strength)
msg(2, 1, syminfo.ticker(s6), s6_strength)
msg(3, 0, syminfo.ticker(s7), s7_strength)
msg(3, 1, syminfo.ticker(s8), s8_strength)
msg(4, 0, syminfo.ticker(s9), s9_strength)
msg(4, 1, syminfo.ticker(s10), s10_strength)
msg(5, 0, syminfo.ticker(s11), s11_strength)
msg(5, 1, syminfo.ticker(s12), s12_strength)
// Display data }
// Plots {
plot_for = s1_plot ? syminfo.ticker(s1) :
s2_plot ? syminfo.ticker(s2) :
s3_plot ? syminfo.ticker(s3) :
s4_plot ? syminfo.ticker(s4) :
s5_plot ? syminfo.ticker(s5) :
s6_plot ? syminfo.ticker(s6) :
s7_plot ? syminfo.ticker(s7) :
s8_plot ? syminfo.ticker(s8) :
s9_plot ? syminfo.ticker(s9) :
s10_plot ? syminfo.ticker(s10) :
s11_plot ? syminfo.ticker(s11) : syminfo.ticker(s12)
price = s1_plot ? s1_cmp :
s2_plot ? s2_cmp :
s3_plot ? s3_cmp :
s4_plot ? s4_cmp :
s5_plot ? s5_cmp :
s6_plot ? s6_cmp :
s7_plot ? s7_cmp :
s8_plot ? s8_cmp :
s9_plot ? s9_cmp :
s10_plot ? s10_cmp :
s11_plot ? s11_cmp : s12_cmp
ma = s1_plot ? s1_ma :
s2_plot ? s2_ma :
s3_plot ? s3_ma :
s4_plot ? s4_ma :
s5_plot ? s5_ma :
s6_plot ? s6_ma :
s7_plot ? s7_ma :
s8_plot ? s8_ma :
s9_plot ? s9_ma :
s10_plot ? s10_ma :
s11_plot ? s11_ma : s12_ma
clr = s1_plot ? s1_strength :
s2_plot ? s2_strength :
s3_plot ? s3_strength :
s4_plot ? s4_strength :
s5_plot ? s5_strength :
s6_plot ? s6_strength :
s7_plot ? s7_strength :
s8_plot ? s8_strength :
s9_plot ? s9_strength :
s10_plot ? s10_strength :
s11_plot ? s11_strength : s12_strength
plot(price, title = 'Price line', color = clr)
plot(ma, title = 'MA line', color = color.blue)
msg1(0, 0, plot_for)
// } Plots
// } END
|
ICT NEW YORK MIDNIGHT OPEN AND 8.30 AM OPEN | https://www.tradingview.com/script/Pt0Kk3PV-ICT-NEW-YORK-MIDNIGHT-OPEN-AND-8-30-AM-OPEN/ | AlphaICTrader | https://www.tradingview.com/u/AlphaICTrader/ | 852 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ©ALPHAICTRADER
//@version=5
indicator("ICT NEW YORK MIDNIGHT OPEN AND 8.30 AM OPEN", "ICT MIDNIGHT AND 8.30AM OPEN", true, max_lines_count=500)
iMDisplay = input.bool (true, "Display", group="New York Midnight Day Divider")
iMDColor = input.color (#58A2B0, "Color", group="New York Midnight Day Divider")
iMDStyle = input.string ("Solid", "Line Style", options=["Solid", "Dotted", "Dashed"], group="New York Midnight Day Divider")
//iMDHistory = input.bool (false, "History", group="New York Midnight Day Divider")
iMTime = input.session ('0000-0001:1234567', "Session", group="New York Midnight Open")
iMStyle = input.string ("Dashed", "Line Style", options=["Solid", "Dotted", "Dashed"], group="New York Midnight Open")
iMColor = input.color (#58A2B0, "Color", group="New York Midnight Open")
iMHistory = input.bool (true, "History", group="New York Midnight Open")
iMLabel = input.bool (true, "Show Label", group="New York Midnight Open")
i8Display = input.bool (true, "Display", group="New York 8:30 Open")
i8Time = input.session ('0830-0831:1234567', "Session", group="New York 8:30 Open")
i8Style = input.string ("Dotted", "Line Style", options=["Solid", "Dotted", "Dashed"], group="New York 8:30 Open")
i8Color = input.color (#58A2B0, "Color", group="New York 8:30 Open")
i8History = input.bool (true, "History", group="New York 8:30 Open")
i8Label = input.bool (true, "Show Label", group="New York 8:30 Open")
tMidnight = time ("1", iMTime)
t830 = time ("1", i8Time)
_MStyle = iMStyle == "Solid" ? line.style_solid : iMStyle == "Dotted" ? line.style_dotted : line.style_dashed
_8Style = i8Style == "Solid" ? line.style_solid : i8Style == "Dotted" ? line.style_dotted : line.style_dashed
_DStyle = iMDStyle == "Solid" ? line.style_solid : iMDStyle == "Dotted" ? line.style_dotted : line.style_dashed
//==== Midnight Open ====
if iMDisplay
var line dayLine = na
dayLine :=line.new(tMidnight, high, tMidnight, low, xloc.bar_time, extend.both, iMDColor, _DStyle, 1)
//if not iMDHistory
//line.delete(dayLine[1])
if iMDisplay
var openMidnight = 0.0
if tMidnight
if not tMidnight[1]
openMidnight := open
else
openMidnight := math.max(open, openMidnight)
var label lb = na
var line lne = na
if openMidnight != openMidnight[1]
if barstate.isconfirmed
line.set_x2(lne, tMidnight)
lne := line.new(tMidnight, openMidnight, last_bar_time + 14400000/2, openMidnight, xloc.bar_time, extend.none, iMColor, _MStyle, 1)
if iMLabel
lb := label.new(last_bar_time + 14400000/2, openMidnight, "Midnight", xloc.bar_time, yloc.price, na, label.style_none, iMColor, size.normal, text.align_right)
label.delete(lb[1])
if not iMHistory
line.delete(lne[1])
//===========================
//==== 8:30 Open ====
if i8Display
var open830 = 0.0
if t830
if not t830[1]
open830 := open
else
open830 := math.max(open, open830)
var label lb2 = na
var line lne2 = na
if open830 != open830[1]
if barstate.isconfirmed
line.set_x2(lne2, t830 - 30600000)
lne2 := line.new(t830, open830, last_bar_time + 14400000/2, open830, xloc.bar_time, extend.none, i8Color, _8Style, 1)
if i8Label
lb2 := label.new(last_bar_time + 14400000/2, open830, "8:30", xloc.bar_time, yloc.price, na, label.style_none, i8Color, size.normal, text.align_right)
label.delete(lb2[1])
if not i8History
line.delete(lne2[1])
//=========================== |
TMA Legacy - "The Arty" | https://www.tradingview.com/script/E134IFpx-TMA-Legacy-The-Arty/ | Hotchachachaaa | https://www.tradingview.com/u/Hotchachachaaa/ | 317 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Hotchachachaaa
//Thanks also to SamX for letting me use your session timer and the members of my discord for helping put this together.
//@version=5
indicator(title="TMA Overlay", shorttitle="TMA Overlay", overlay=true)
// ### Four Smoothed Moving Averages
typeofMA1 = input.string(title="Type of Moving Average", defval="SMMA", options=["RMA", "SMA", "EMA", "WMA", "VWMA", "SMMA", "TMA", "HullMA", "DEMA", "TEMA"],group="Moving Averages")
averageSource= close
length_ma1 = input.int(21, title = "Length 1",group="Moving Averages")
length_ma2 = input.int(50, title = "Length 2",group="Moving Averages")
length_ma3 = input.int(100, title = "Length 3",group="Moving Averages")
length_ma4 = input.int(200, title = "Length 4",group="Moving Averages")
f_smma(averageSource, averageLength) =>
smma = 0.0
smma := na(smma[1]) ? ta.sma(averageSource, averageLength) : (smma[1] * (averageLength - 1) + averageSource) / averageLength
smma
f_hullma(averageSource, averageLength) =>
ta.wma(2 * ta.wma(averageSource, averageLength / 2) - ta.wma(averageSource, averageLength), math.round(math.sqrt(averageLength)))
f_tma(averageSource, averageLength) =>
ta.sma(ta.sma(averageSource, averageLength), averageLength)
f_dema(averageSource, averageLength) =>
emaValue = ta.ema(averageSource, averageLength)
2 * emaValue - ta.ema(emaValue, averageLength)
f_tema(averageSource, averageLength) =>
ema1 = ta.ema(averageSource, averageLength)
ema2 = ta.ema(ema1, averageLength)
ema3 = ta.ema(ema2, averageLength)
(3 * ema1) - (3 * ema2) + ema3
f_ma(smoothing, averageSource, averageLength) =>
switch str.upper(smoothing)
"SMA" => ta.sma(averageSource, averageLength)
"EMA" => ta.ema(averageSource, averageLength)
"WMA" => ta.wma(averageSource, averageLength)
"HMA" => ta.hma(averageSource, averageLength)
"RMA" => ta.rma(averageSource, averageLength)
"SMMA" => f_smma(averageSource, averageLength)
"SWMA" => ta.swma(averageSource)
"ALMA" => ta.alma(averageSource, averageLength, 0.85, 6)
"VWMA" => ta.vwma(averageSource, averageLength)
=> runtime.error("Moving average type '" + smoothing +
"' not found!"), na
MA1 = f_ma(typeofMA1, averageSource, length_ma1)
MA2 = f_ma(typeofMA1, averageSource, length_ma2)
MA3 = f_ma(typeofMA1, averageSource, length_ma3)
MA4 = f_ma(typeofMA1, averageSource, length_ma4)
///////////////dynamic line coloring
dynamic = input.bool (title="Use Dynamic Line Color", defval=false )
src=close
length = 10
beta = 1
alpha = 1
var b = array.new_float(0)
var css = array.new_color(na)
if barstate.isfirst
for i = 0 to length-1
x = i/(length-1)
w = math.pow(x,alpha-1)*math.pow(1-x,beta-1)
array.push(b,w)
array.push(css,#FF1100), array.push(css,#FF1200), array.push(css,#FF1400), array.push(css,#FF1500), array.push(css,#FF1700), array.push(css,#FF1800), array.push(css,#FF1A00), array.push(css,#FF1B00), array.push(css,#FF1D00), array.push(css,#FF1F00), array.push(css,#FF2000), array.push(css,#FF2200), array.push(css,#FF2300), array.push(css,#FF2500), array.push(css,#FF2600), array.push(css,#FF2800), array.push(css,#FF2900), array.push(css,#FF2B00), array.push(css,#FF2D00), array.push(css,#FF2E00), array.push(css,#FF3000), array.push(css,#FF3100), array.push(css,#FF3300), array.push(css,#FF3400), array.push(css,#FF3600), array.push(css,#FF3700), array.push(css,#FF3900), array.push(css,#FF3B00), array.push(css,#FF3C00), array.push(css,#FF3E00), array.push(css,#FF3F00), array.push(css,#FF4100), array.push(css,#FF4200), array.push(css,#FF4400), array.push(css,#FF4500), array.push(css,#FF4700), array.push(css,#FF4900), array.push(css,#FF4A00), array.push(css,#FF4C00), array.push(css,#FF4D00), array.push(css,#FF4F00), array.push(css,#FF5000), array.push(css,#FF5200), array.push(css,#FF5300), array.push(css,#FF5500), array.push(css,#FF5700), array.push(css,#FF5800), array.push(css,#FF5A00), array.push(css,#FF5B00), array.push(css,#FF5D00), array.push(css,#FF5E00), array.push(css,#FF6000), array.push(css,#FF6200), array.push(css,#FF6300), array.push(css,#FF6500), array.push(css,#FF6600), array.push(css,#FF6800), array.push(css,#FF6900), array.push(css,#FF6B00), array.push(css,#FF6C00), array.push(css,#FF6E00), array.push(css,#FF7000), array.push(css,#FF7100), array.push(css,#FF7300), array.push(css,#FF7400), array.push(css,#FF7600), array.push(css,#FF7700), array.push(css,#FF7900), array.push(css,#FF7A00), array.push(css,#FF7C00), array.push(css,#FF7E00), array.push(css,#FF7F00), array.push(css,#FF8100), array.push(css,#FF8200), array.push(css,#FF8400), array.push(css,#FF8500), array.push(css,#FF8700), array.push(css,#FF8800), array.push(css,#FF8A00), array.push(css,#FF8C00), array.push(css,#FF8D00), array.push(css,#FF8F00), array.push(css,#FF9000), array.push(css,#FF9200), array.push(css,#FF9300), array.push(css,#FF9500), array.push(css,#FF9600), array.push(css,#FF9800), array.push(css,#FF9A00), array.push(css,#FF9B00), array.push(css,#FF9D00), array.push(css,#FF9E00), array.push(css,#FFA000), array.push(css,#FFA100), array.push(css,#FFA300), array.push(css,#FFA400), array.push(css,#FFA600), array.push(css,#FFA800), array.push(css,#FFA900), array.push(css,#FFAB00), array.push(css,#FDAC00), array.push(css,#FBAD02), array.push(css,#F9AE03), array.push(css,#F7AE04), array.push(css,#F5AF06), array.push(css,#F3B007), array.push(css,#F1B108), array.push(css,#EFB20A), array.push(css,#EDB30B), array.push(css,#EBB30C), array.push(css,#E9B40E), array.push(css,#E7B50F), array.push(css,#E4B610), array.push(css,#E2B712), array.push(css,#E0B813), array.push(css,#DEB814), array.push(css,#DCB916), array.push(css,#DABA17), array.push(css,#D8BB18), array.push(css,#D6BC1A), array.push(css,#D4BD1B), array.push(css,#D2BD1C), array.push(css,#D0BE1E), array.push(css,#CEBF1F), array.push(css,#CCC020), array.push(css,#C9C122), array.push(css,#C7C223), array.push(css,#C5C224), array.push(css,#C3C326), array.push(css,#C1C427), array.push(css,#BFC528), array.push(css,#BDC62A), array.push(css,#BBC72B), array.push(css,#B9C72C), array.push(css,#B7C82E), array.push(css,#B5C92F), array.push(css,#B3CA30), array.push(css,#B0CB32), array.push(css,#AECC33), array.push(css,#ACCC34), array.push(css,#AACD36), array.push(css,#A8CE37), array.push(css,#A6CF38), array.push(css,#A4D03A), array.push(css,#A2D13B), array.push(css,#A0D13C), array.push(css,#9ED23E), array.push(css,#9CD33F), array.push(css,#9AD440), array.push(css,#98D542), array.push(css,#95D643), array.push(css,#93D644), array.push(css,#91D746), array.push(css,#8FD847), array.push(css,#8DD948), array.push(css,#8BDA4A), array.push(css,#89DB4B), array.push(css,#87DB4C), array.push(css,#85DC4E), array.push(css,#83DD4F), array.push(css,#81DE50), array.push(css,#7FDF52), array.push(css,#7CE053), array.push(css,#7AE054), array.push(css,#78E156), array.push(css,#76E257), array.push(css,#74E358), array.push(css,#72E45A), array.push(css,#70E55B), array.push(css,#6EE55C), array.push(css,#6CE65E), array.push(css,#6AE75F), array.push(css,#68E860), array.push(css,#66E962), array.push(css,#64EA63), array.push(css,#61EA64), array.push(css,#5FEB66), array.push(css,#5DEC67), array.push(css,#5BED68), array.push(css,#59EE6A), array.push(css,#57EF6B), array.push(css,#55EF6C), array.push(css,#53F06E), array.push(css,#51F16F), array.push(css,#4FF270), array.push(css,#4DF372), array.push(css,#4BF473), array.push(css,#48F474), array.push(css,#46F576), array.push(css,#44F677), array.push(css,#42F778), array.push(css,#40F87A), array.push(css,#3EF97B), array.push(css,#3CF97C), array.push(css,#3AFA7E), array.push(css,#38FB7F), array.push(css,#36FC80), array.push(css,#34FD82), array.push(css,#32FE83), array.push(css,#30FF85),
den = array.sum(b)
//----
sum = 0.
for i = 0 to length-1
sum := sum + MA1[i]*array.get(b,i)
filt = sum/den
os = ta.rsi(filt,length)/100
dynColor = array.get(css,math.round(os*199))
///////////////plot MAs
plot_ma1 = plot(MA1, color= dynamic ? dynColor: color.green , linewidth=1, title = "MA1")
plot_ma2 = plot(MA2, color= dynamic ? dynColor: color.red , linewidth=1, title = "MA2")
plot_ma3 = plot(MA3, color= dynamic ? dynColor: color.yellow, linewidth=1, title = "MA3")
plot_ma4 = plot(MA4, color= dynamic ? dynColor: color.white, linewidth=1, title = "MA4")
// Trend Fill
rsi1 =ta.rsi(close,14)
smmaLen = 50
//input(50, minval=1, title="SMMA Length", group = "Smoothed MA")
smmaSrc = rsi1
smma = 0.0
smma := na(smma[1]) ? ta.sma(smmaSrc, smmaLen) : (smma[1] * (smmaLen - 1) + smmaSrc) / smmaLen
trendFill = input(title="Show Trend Fill", defval=true, group = "Smoothed MA Inputs")
transparencyValue= trendFill ? math.abs(rsi1-smma): na
bColor = if rsi1 > smma
color.from_gradient(transparencyValue,0, 50, color.new(color.lime, 80), color.lime)
else
color.from_gradient(transparencyValue,0, 50, color.new(color.red, 80),color.red)
fill(plot_ma1,plot_ma2,bColor,title="RSI Fill")
// End ###
// ### 3 Line Strike
bearS = input.bool(title="Show Bearish 3 Line Strike", defval=true, group = "3 Line Strike")
bullS = input.bool(title="Show Bullish 3 Line Strike", defval=true, group = "3 Line Strike")
bearSig = close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close < open[1]
bullSig = close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close > open[1]
plotshape(bullS ? bullSig : na, style=shape.triangleup, color=color.green, location=location.belowbar, size = size.small, title="3 Line Strike Up")
plotshape(bearS ? bearSig : na, style=shape.triangledown, color=color.red, location=location.abovebar, size = size.small, title="3 Line Strike Down")
alertcondition(bullSig, title="Bullish 3-line", message="[CurrencyPair] [TimeFrame], Bullish 3-line Strike")
alertcondition(bearSig, title="Bearish 3-line", message="[CurrencyPair] [TimeFrame], Bearish 3-line Strike")
// End ###
//### Engulfing Candles
bearE = input.bool(title="Show Bearish Big A$$ Candles", defval=true, group = "Big A$$ Candles")
bullE = input.bool(title="Show Bullish Big A$$ Candles", defval=true, group = "Big A$$ Candles")
strictBAC=input.string(title = "Strict/Not",defval="Strict", options=["Not","Strict"])
openBarPrevious = open[1]
closeBarPrevious = close[1]
openBarCurrent = open
closeBarCurrent = close
//If current bar open is less than equal to the previous bar close AND current bar open is less than previous bar open AND current bar close is greater than previous bar open THEN True
bullishEngulfing = strictBAC == "Not" ? openBarCurrent <= closeBarPrevious and openBarCurrent < openBarPrevious and closeBarCurrent > openBarPrevious : strictBAC == "Strict" ? close<MA1 and close>MA4 and openBarCurrent <= closeBarPrevious and openBarCurrent < openBarPrevious and closeBarCurrent > openBarPrevious :na
//If current bar open is greater than equal to previous bar close AND current bar open is greater than previous bar open AND current bar close is less than previous bar open THEN True
bearishEngulfing = strictBAC == "Not" ? openBarCurrent >= closeBarPrevious and openBarCurrent > openBarPrevious and closeBarCurrent < openBarPrevious : strictBAC == "Strict" ? close>MA1 and close< MA4 and openBarCurrent >= closeBarPrevious and openBarCurrent > openBarPrevious and closeBarCurrent < openBarPrevious : na
//bullishEngulfing/bearishEngulfing return a value of 1 or 0; if 1 then plot on chart, if 0 then don't plot
plotshape(bullE ? bullishEngulfing : na, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.tiny, title="Big Ass Candle Up" )
plotshape(bearE ? bearishEngulfing : na, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.tiny, title="Big Ass Candle Down")
alertcondition(bullishEngulfing, title="Bullish Engulfing", message="[CurrencyPair] [TimeFrame], Bullish candle engulfing previous candle")
alertcondition(bearishEngulfing, title="Bearish Engulfing", message="[CurrencyPair] [TimeFrame], Bearish candle engulfing previous candle")
// ### Trading Session
// Inputs
//
// session windows
g_Sessions = 'Session Settings'
showLondonSession = input.bool(title='', defval=true, group=g_Sessions, inline='showLondonSession')
londonSession = input.session(title='London Session', defval='0300-1200', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showLondonSession')
showNYSession = input.bool(title='', defval=true, group=g_Sessions, inline='showNYSession')
nySession = input.session(title='New York Session', defval='0800-1700', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showNYSession')
showTokyoSession = input.bool(title='', defval=false, group=g_Sessions, inline='showTokyoSession')
tokyoSession = input.session(title='Tokyo Session', defval='2000-0400', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showTokyoSession')
showSydneySession = input.bool(title='', defval=false, group=g_Sessions, inline='showSydneySession')
sydneySession = input.session(title='Sydney Session', defval='1700-0200', group=g_Sessions, tooltip='Default values are US Eastern (UTC -5), please adjust as needed!', inline='showSydneySession')
//
// Low/High Resolution
// res = input.timeframe(title='Session High/Low Timeframe', defval='D', options=['D', 'W', 'M'], group='Session High/Low Resolution', tooltip='Select the time interval to use for identifying ' +
// 'the session-high and session-low data points. This affects what is shown on the chart as the session high/low. For timeframes less than 1 week, the daily value is recommended.')
//
// Color inputs
g_Colors = 'Color inputs'
londonBGColor = input.color(title='London Session - Background:', group=g_Colors, defval=color.rgb(0, 255, 0, 90), inline='lc', tooltip='Colors to use for identifying London/Europe session info')
londonTextColor = input.color(title='Label Text:', group=g_Colors, defval=color.rgb(0, 0, 0, 0), inline='lc', tooltip='Colors to use for identifying London/Europe session info')
nyBGColor = input.color(title='New York Session - Background:', group=g_Colors, inline="nc", defval=color.rgb(255, 0, 0, 90), tooltip='Colors to use for identifying New York/US session info')
nyTextColor = input.color(title='Label Text:', group=g_Colors, inline="nc", defval=color.rgb(255, 255, 255, 0), tooltip='Colors to use for identifying New York/US session info')
asiaBGColor = input.color(title='Tokyo Session - Background:', group=g_Colors, inline="tc", defval=color.rgb(255, 255, 0, 90), tooltip='Colors to use for identifying Tokyo/Asia session info')
asiaTextColor = input.color(title='Label Text:', group=g_Colors, inline="tc", defval=color.rgb(0, 0, 0, 0), tooltip='Colors to use for identifying Tokyo/Asia session info')
ausBGColor = input.color(title='Sydney Session - Background:', group=g_Colors, inline="ss", defval=color.rgb(0, 255, 255, 90), tooltip='Colors to use for identifying Sydney/Australia session info')
ausTextColor = input.color(title='Label Text:', group=g_Colors, inline="ss", defval=color.rgb(0, 0, 0, 0), tooltip='Colors to use for identifying Sydney/Australia session info')
//
// High/Low control inputs
doHighLowDiffLabels = input.bool(title='Label session high/low difference', defval=false, group='hlControls', tooltip='Show labels indicating difference between session high and session low')
// Functions
//
// Function to determine if current bar falls into the input session
isInSession(session) =>
barSessionTime = time(timeframe.period, session)
inSession = not na(barSessionTime)
inSession
// Force-pull price via security function to help ensure consistency on non-standard chart types...
//
// Explicitly define our ticker to help ensure that we're always getting ACTUAL price instead of relying on the input
// ticker info and input vars (as they tend to inherit the type from what's displayed on the current chart)
realPriceTicker = ticker.new(prefix=syminfo.prefix, ticker=syminfo.ticker)
//
// This MAY be unnecessary, but in testing I've found some oddities when trying to use this on varying chart types
// like on the HA chart, where the source referece for the price skews to the values for the current chart type
// instead of the expected pure-price values. For example, the 'source=close' reference - 'close' would be actual price
// close on a normal candlestick chart, but would be the HA close on the HA chart.
[o, h, l, c] = request.security(symbol=realPriceTicker, timeframe='', expression=[open, high, low, close], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
// Session - London
//
// Full-height fill
bgcolor(color=isInSession(londonSession) and showLondonSession ? londonBGColor : na, title='London Session', editable=false)
//
// Track session high/low
var float londonSessionHigh = na
var float londonSessionLow = na
var float londonSessionOpen = na
var float londonSessionClose = na
var bool isLondonSessionStart = false
isInLondonSession = isInSession(londonSession)
if (isInLondonSession)
// In session, check for session start...
if (not isInLondonSession[1])
// Start of session, reset high and low tracking vars
londonSessionHigh := h
londonSessionLow := l
isLondonSessionStart := true
londonSessionOpen := o
else
londonSessionHigh := math.max(h, londonSessionHigh[1])
londonSessionLow := math.min(l, londonSessionLow[1])
// Being a bit lazy here and updating close every candle instead of explicitly
// waiting for the last candle close to grab the session close value, but the result
// will still be the same...
londonSessionClose := c
// Calculate session high/low diff
// plot(title="LondonHigh", series=isInLondonSession ? londonSessionHigh : na, color=londonBGColor, style=plot.style_circles)
// plot(title="LondonLow", series=isInLondonSession ? londonSessionLow : na, color=londonBGColor, style=plot.style_circles)
londonSessDiff = londonSessionHigh[1] - londonSessionLow[1]
// Plot session high/low diff as label if enables
if (isInLondonSession[1] and not isInLondonSession and doHighLowDiffLabels and showLondonSession)
r = color.r(londonBGColor)
g = color.g(londonBGColor)
b = color.b(londonBGColor)
isCloseBelowOpen = londonSessionClose < londonSessionOpen ? true : false
label.new(bar_index[1], isCloseBelowOpen ? londonSessionLow : londonSessionHigh, str.tostring(londonSessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=londonTextColor)
// Session - New York
bgcolor(color=isInSession(nySession) and showNYSession ? nyBGColor : na, title='New York Session', editable=false)
//
// Track session high/low
var float nySessionHigh = na
var float nySessionLow = na
var float nySessionOpen = na
var float nySessionClose = na
var bool isNYSessionStart = false
isInNYSession = isInSession(nySession)
if (isInNYSession)
// In session, check for session start...
if (not isInNYSession[1])
// Start of session, reset high and low tracking vars
nySessionHigh := h
nySessionLow := l
isNYSessionStart := true
nySessionOpen := o
else
nySessionHigh := math.max(h, nySessionHigh[1])
nySessionLow := math.min(l, nySessionLow[1])
// Being a bit lazy here and updating close every candle instead of explicitly
// waiting for the last candle close to grab the session close value, but the result
// will still be the same...
nySessionClose := c
// Calculate session high/low diff
nySessDiff = nySessionHigh[1] - nySessionLow[1]
// Plot session high/low diff as label if enables
if (isInNYSession[1] and not isInNYSession and doHighLowDiffLabels and showNYSession)
r = color.r(nyBGColor)
g = color.g(nyBGColor)
b = color.b(nyBGColor)
isCloseBelowOpen = nySessionClose < nySessionOpen ? true : false
label.new(bar_index[1], isCloseBelowOpen ? nySessionLow : nySessionHigh, str.tostring(nySessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=nyTextColor)
// Session - Tokyo
bgcolor(color=isInSession(tokyoSession) and showTokyoSession ? asiaBGColor : na, title='Tokyo Session', editable=false)
//
// Track session high/low
var float tokyoSessionHigh = na
var float tokyoSessionLow = na
var float tokyoSessionOpen = na
var float tokyoSessionClose = na
var bool isTokyoSessionStart = false
isInTokyoSession = isInSession(tokyoSession)
if (isInTokyoSession)
// In session, check for session start...
if (not isInTokyoSession[1])
// Start of session, reset high and low tracking vars
tokyoSessionHigh := h
tokyoSessionLow := l
isTokyoSessionStart := true
tokyoSessionOpen := o
else
tokyoSessionHigh := math.max(h, tokyoSessionHigh[1])
tokyoSessionLow := math.min(l, tokyoSessionLow[1])
// Being a bit lazy here and updating close every candle instead of explicitly
// waiting for the last candle close to grab the session close value, but the result
// will still be the same...
tokyoSessionClose := c
// Calculate session high/low diff
tokyoSessDiff = tokyoSessionHigh[1] - tokyoSessionLow[1]
// Plot session high/low diff as label if enables
if (isInTokyoSession[1] and not isInTokyoSession and doHighLowDiffLabels and showTokyoSession)
r = color.r(asiaBGColor)
g = color.g(asiaBGColor)
b = color.b(asiaBGColor)
isCloseBelowOpen = tokyoSessionClose < tokyoSessionOpen ? true : false
label.new(bar_index[1], isCloseBelowOpen ? tokyoSessionLow : tokyoSessionHigh, str.tostring(tokyoSessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=asiaTextColor)
// Session - Sydney
bgcolor(color=isInSession(sydneySession) and showSydneySession ? ausBGColor : na, title='Sydney Session', editable=false)
//
// Track session high/low
var float sydneySessionHigh = na
var float sydneySessionLow = na
var float sydneySessionOpen = na
var float sydneySessionClose = na
var bool isSydneySessionStart = false
isInSydneySession = isInSession(sydneySession)
if (isInSydneySession)
// In session, check for session start...
if (not isInSydneySession[1])
// Start of session, reset high and low tracking vars
sydneySessionHigh := h
sydneySessionLow := l
isSydneySessionStart := true
sydneySessionOpen := o
else
sydneySessionHigh := math.max(h, sydneySessionHigh[1])
sydneySessionLow := math.min(l, sydneySessionLow[1])
// Being a bit lazy here and updating close every candle instead of explicitly
// waiting for the last candle close to grab the session close value, but the result
// will still be the same...
sydneySessionClose := c
// Calculate session high/low diff
sydneySessDiff = sydneySessionHigh[1] - sydneySessionLow[1]
// Plot session high/low diff as label if enables
if (isInSydneySession[1] and not isInSydneySession and doHighLowDiffLabels and showSydneySession)
r = color.r(ausBGColor)
g = color.g(ausBGColor)
b = color.b(ausBGColor)
isCloseBelowOpen = sydneySessionClose < sydneySessionOpen ? true : false
label.new(bar_index[1], isCloseBelowOpen ? sydneySessionLow : sydneySessionHigh, str.tostring(sydneySessDiff, format.mintick), style=isCloseBelowOpen ? label.style_label_up : label.style_label_down, color=color.rgb(r, g, b, 0), textcolor=ausTextColor)
|
Interactive Volume Profile - Based on LTF volume | https://www.tradingview.com/script/NLPel1Y0-Interactive-Volume-Profile-Based-on-LTF-volume/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 1,049 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
// __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
// / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
// $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
// $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
// $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
// $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
// $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
// $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
// $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
//
//
//
//@version=5
indicator("Interactive Volume Profile - Based on LTF volume", shorttitle='LtfVP', overlay=true, max_boxes_count=500, max_labels_count=500)
import HeWhoMustNotBeNamed/arrays/1 as pa
lowerTimeFrame = input.timeframe('1', 'Lower Timeframe', tooltip='Lower the timeframe more granular the calculation will be. But, it also means less number of bars can be used. Should always be less than current timeframe', confirm=true)
applyMaxAvailable = input.bool(false, 'Apply for max available bars', tooltip='If selected will ignore start and end time and draw volume profile for maximum available data', confirm=true)
source = input.string('traded', 'Volume Source', options=['absolute', 'traded'], tooltip='absolute - volume\ntraded - volume*price', confirm=true)
startTime = input.time(0,'Start', tooltip='Time range start for volume profile calculation', confirm=true)
endTime = input.time(0,'End', tooltip='Time range end for volume profile calculation', confirm=true)
numberOfLevels = input.int(100, 'Number of Levels', minval=10, maxval=500, step=50, tooltip='Number of volume bars to display', confirm=true)
transparency = input.int(80, 'Transparency', minval=0, maxval=100, step=10, tooltip='Transparency of volume profile bars')
showBorder = input.bool(true, 'Border', tooltip='Display borders for volume profile bars')
borderWidth = showBorder? 1 : 0
showVolume = input.bool(true, 'Display Volume', tooltip='Display volume on bars')
usePercentile = input.bool(false, 'Percentile', tooltip='Use percentile to define bar length instead of percent')
colorLow = input.color(color.yellow, '', inline='c', group='Colors')
colorHigh = input.color(color.red, '', inline='c', group='Colors')
// referenceType = input.string(xloc.bar_time, 'Drawing reference', options=[xloc.bar_time, xloc.bar_index])
referenceType = xloc.bar_time
var priceArray = array.new<float>()
var volumeArray = array.new<float>()
[tickVolumes, tickPrices] = request.security_lower_tf(syminfo.tickerid, lowerTimeFrame, [source == 'absolute'? volume : (volume*close), close], true)
var startBar = 0
var endBar = 0
var realStartTime = 0
var realEndTime = 0
if(time >= math.min(startTime, endTime) and time <= math.max(startTime, endTime)) or applyMaxAvailable
if(array.size(tickVolumes) != 0)
startBar := startBar == 0? (referenceType == xloc.bar_index ? bar_index : time) : startBar
endBar := (referenceType == xloc.bar_index ? bar_index : time)
for [index, tickVolume] in tickVolumes
tickPrice = array.get(tickPrices, index)
idx = array.binary_search(priceArray, tickPrice)
if(idx == -1)
idxi = array.binary_search_rightmost(priceArray, tickPrice)
array.insert(priceArray, idxi, tickPrice)
array.insert(volumeArray, idxi, tickVolume)
else
array.set(volumeArray, idx, array.get(volumeArray, idx)+tickVolume)
highest = array.max(priceArray)
lowest = array.min(priceArray)
levelDiff = (highest-lowest)/numberOfLevels
levelStart = array.new<float>()
levelEnd = array.new<float>()
vProfileMatrix = matrix.new<float>()
startPrice = lowest
while(startPrice < highest)
st = startPrice
startPrice := startPrice + levelDiff
en = startPrice
matrix.add_col(vProfileMatrix, matrix.columns(vProfileMatrix), array.from(st, en, 0.0))
if(matrix.rows(vProfileMatrix) > 0 and barstate.islast)
startArray = matrix.row(vProfileMatrix, 0)
printed = false
for [index, price] in priceArray
vol = array.get(volumeArray, index)
nIndex = math.min(array.binary_search_leftmost(startArray, price), numberOfLevels-1)
matrix.set(vProfileMatrix, 2, nIndex, matrix.get(vProfileMatrix, 2, nIndex)+vol)
maxV = array.max(matrix.row(vProfileMatrix, 2))
var boxArray = array.new<box>()
var labelArray = array.new<label>()
pa.clear(boxArray)
if(not applyMaxAvailable)
var line startLine = na
var line endLine = na
line.delete(startLine)
line.delete(endLine)
startLine := line.new(startTime, high, startTime, low, extend=extend.both, xloc=xloc.bar_time, color=color.maroon, width=2)
endLine := line.new(endTime, high, endTime, low, extend=extend.both, xloc=xloc.bar_time, color=color.maroon, width=2)
cVolumeArray = matrix.row(vProfileMatrix, 2)
for [i, currentV] in cVolumeArray
vPercent = usePercentile? array.percentrank(cVolumeArray, i)/100 : currentV/maxV
left = startBar
right = math.floor(left + vPercent*(endBar-left))
bottom = matrix.get(vProfileMatrix, 0, i)
top = matrix.get(vProfileMatrix, 1, i)
barcolor = color.new(color.from_gradient(vPercent, 0, 1, colorLow, colorHigh), transparency)
vText = showVolume? str.tostring(currentV) : ''
bx = box.new(left, top, right, bottom, bgcolor=barcolor, border_color=barcolor,
text=vText, text_size=size.auto, text_color=color.white, text_halign=text.align_left,
border_width=borderWidth, xloc=referenceType)
array.push(boxArray, bx) |
Pre-Market levels for Futures | https://www.tradingview.com/script/3gymGQ6G-Pre-Market-levels-for-Futures/ | panuchi007 | https://www.tradingview.com/u/panuchi007/ | 117 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © convicted
//@version=4
study(title="High_Low levels", shorttitle="/ES P.M levels", overlay=true)
//Daily high and low
dailyhigh = security(syminfo.tickerid, 'D', high)
dailylow = security(syminfo.tickerid, 'D', low)
//Yesterday high and low
previousdayhigh = security(syminfo.tickerid, 'D', high[1])
previousdaylow = security(syminfo.tickerid, 'D', low[1])
//Premarket high and low
t = time("1440","0400-0930") // 1440 is the number of minutes in a whole day.
is_first = na(t[1]) and not na(t) or t[1] < t
ending_hour = 8
ending_minute = 30
pm_high = float(na)
pm_low = float(na)
k = int(na)
if is_first and barstate.isnew and ((hour < ending_hour or hour >= 16) or (hour == ending_hour and minute < ending_minute))
pm_high := high
pm_low := low
else
pm_high := pm_high[1]
pm_low := pm_low[1]
if high > pm_high and ((hour < ending_hour or hour >= 1600) or (hour == ending_hour and minute < ending_minute))
pm_high := high
if low < pm_low and ((hour < ending_hour or hour >= 1600) or (hour == ending_hour and minute < ending_minute))
pm_low := low
LastOnly = true
if LastOnly==true
k:=-9999
else
k:=0
//After Hours high and low
ti = time("1440","1600-2000") // 1440 is the number of minutes in a whole day.
is_first1 = na(ti[1]) and not na(ti) or ti[1] < ti
ending_hour1 = 20
ending_minute1 = 00
ah_high = float(na)
ah_low = float(na)
g = int(na)
if is_first1 and barstate.isnew and ((hour < ending_hour1 or hour >= 20) or (hour == ending_hour1 and minute < ending_minute1))
ah_high := high
ah_low := low
else
ah_high := ah_high[1]
ah_low := ah_low[1]
if high > ah_high and ((hour < ending_hour1 or hour >= 2000) or (hour == ending_hour1 and minute < ending_minute1))
ah_high := high
if low < ah_low and ((hour < ending_hour1 or hour >= 2000) or (hour == ending_hour1 and minute < ending_minute1))
ah_low := low
LastOnly1 = true
if LastOnly1==true
g:=-9999
else
g:=0
//Just a variable here for the label coordinates
td = time - time[5]
//Daily high and low lines
plot(dailyhigh, style=plot.style_line,title="Daily high", color=#b71c1c, linewidth=2, trackprice=true,offset=k)
dh = label.new(x=time+td, y=dailyhigh, text = "Day High", xloc = xloc.bar_time, style = label.style_none, textcolor = #000000, size = size.small, textalign = text.align_right)
label.delete(dh[1])
plot(dailylow, style=plot.style_line,title="Daily low",color=#1b5e20, linewidth=2, trackprice=true,offset=k)
dl = label.new(x=time+td, y=dailylow, text = "Day low", xloc = xloc.bar_time, style = label.style_none, textcolor = #000000, size = size.small, textalign = text.align_right)
label.delete(dl[1])
//Premarket high and low lines
plot(pm_high, style=plot.style_line,title="Premarket high", trackprice=true, color=#f44336, linewidth=2,offset=k)
pmh = label.new(x=time+td, y=pm_high, text = "PM High", xloc = xloc.bar_time, style = label.style_none, textcolor = #000000, size = size.small, textalign = text.align_right)
label.delete(pmh[1])
plot(pm_low, style=plot.style_line,title="Premarket low", trackprice=true, color=#4caf50, linewidth=2,offset=k)
pml = label.new(x=time+td, y=pm_low, text = "PM Low", xloc = xloc.bar_time, style = label.style_none, textcolor = #000000, size = size.small, textalign = text.align_right)
label.delete(pml[1])
|
Everything Bitcoin [Kioseff Trading] | https://www.tradingview.com/script/7Gx1fMgO-Everything-Bitcoin-Kioseff-Trading/ | KioseffTrading | https://www.tradingview.com/u/KioseffTrading/ | 1,131 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © KioseffTrading
//@version=5
indicator("Everything Bitcoin [Kioseff Trading]", overlay = true, max_labels_count = 500, max_boxes_count = 500, max_lines_count = 500, max_bars_back = 500)
TFdata = input.string(defval = "Close", title = "Low TF Data",
options =
[
"Close",
"High",
"Low",
"Open",
"HL2",
"HLC3",
"OHLC4",
"HLCC4",
"Volume",
"RSI",
"EMA 20",
"%b",
"Stochastic",
"VWAP"
]
)
TF = input.string(defval = "1 Minute", title = "TF Chart Period",
options =
[
"1 Minute",
"3 Minute",
"5 Minute",
"15 Minute",
"30 Minute",
"45 Minute",
"1 Hour",
"2 Hour",
"3 Hour",
"4 Hour",
"Custom"
]
)
custom = input.int(defval = 1, minval = 1, maxval = 1440,
title = "Custom Timeframe Interval (Minutes)",
tooltip = 'This setting activates when "TF Chart Period" is set to "Custom". Inactive otherwsie.')
show = input.string(defval = "Yes", title = "Show Floating BTC Table?", options = ["Yes", "No", "All Data In Stat Table"])
show1 = input.string(defval = "Yes", title = "Show BTC Stat Table?", options = ["Yes", "No"])
show2 = input.string(defval = "Yes", title = "Show Regression Channel?", options = ["Yes", "No"])
trueTF = switch TF
"1 Minute" => "1"
"3 Minute" => "3"
"5 Minute" => "5"
"15 Minute" => "15"
"30 Minute" => "30"
"45 Minute" => "45"
"1 Hour" => "60"
"2 Hour" => "120"
"3 Hour" => "180"
"4 Hour" => "240"
"Custom" => str.tostring(custom)
tablePos = input.string(defval = "Bottom Right", title = "Stat Table Position",
options =
["Top Left", "Top Center", "Top Right",
"Bottom Left", "Bottom Center", "Bottom Right",
"Middle Left", "Middle Center", "Midde Right"])
quandl(x) =>
request.quandl("BCHAIN/" + x)
price = quandl("MKPRU") // True price
vol = quandl("TRVOU") // Volume
difficulty = quandl("DIFF") // Difficulty
wallet = quandl("MWNUS") // My Wallet# Of Users
size = quandl("AVBLS") // Average Block Size
api = quandl("BLCHS") // api.blockchain size
con = quandl("ATRCT") // Median Transaction Confirmation Time
rev = quandl("MIREV") // Miners Revenue
tate = quandl("HRATE") // Hash rate
cost = quandl("CPTRA") // Cost per transaction
percentage = quandl("CPTRV") // Cost % of transaction volume
usd = quandl("ETRVU") // Transaction Volume USD
output = quandl("TOUTV") // Total output volume
tpb = quandl("NTRBL") // Number Of Transactions Per Block
unique = quandl("NADDU") // # of unique BTC addresses
pop = quandl("NTREP") // # of BTC transactions excluding popular addresses
tot = quandl("NTRAT") // Total number of transactions
day = quandl("NTRAN") // Daily # of transcationss
totfees = quandl("TRFUS") // Total transaction fees USD
mc = quandl("MKTCP") // Market cap
tbtc = quandl("TOTBC") // Tot btc
// _______________________________________________________
//
// Normalize Data
// _______________________________________________________
var box [] volArray = array.new_box ()
var line [] volLineArray = array.new_line ()
var line [] perLineArray = array.new_line ()
var label [] costLabArray = array.new_label ()
var float [] volAvg2 = array.new_float(30)
var box [] contain = array.new_box (1)
var line [] MC = array.new_line ()
var line [] MC2 = array.new_line ()
var float [] MCdata = array.new_float(31)
var box [] blackBox = array.new_box (1)
var label [] blackBoxLab = array.new_label ()
var label [] stat = array.new_label ()
var box [] blackBox1 = array.new_box (1)
var box [] fee = array.new_box ()
var box [] FEE = array.new_box ()
var line [] sep = array.new_line (2)
var label [] arrows = array.new_label ()
var box stat5 = na
normalizedData() =>
var float hiVol = 0.0
var float loVol = 0.0
var float priceHi = 0.0
var float mcNorm = 0.0
var float hiMC = 0.0
var float loMC = 0.0
var float hiCost = 0.0
var float loCost = 0.0
var float hiFees = 0.0
var float loFees = 0.0
var float hiPer = 0.0
var float loPer = 0.0
volNormalized = (vol - loVol) / (hiVol - loVol)
calc = (math.pow((volNormalized + 1) * 2.15, 10) + priceHi)
fincalc = math.min(math.avg(priceHi * 2, priceHi), calc)
boxMax = math.max(priceHi * 2, fincalc)
mcNormalized = (mc - loMC) / (hiMC - loMC)
calcMC = math.avg(priceHi * 2,priceHi * 2,priceHi * 2, priceHi * 2,priceHi) * .005
calcHold = math.avg(priceHi * 2,priceHi * 2,priceHi * 2, priceHi * 2, priceHi * 2, priceHi)
var float MCcalc = calcHold
costNormalized = (percentage - loCost) / (hiCost - loCost)
calcHoldCost = math.avg(boxMax * 1.07, boxMax )
calcCost = math.avg(boxMax * 1.07, boxMax ) * .005
var float Costcalc = calcHoldCost
FeesNormalized = (totfees - loFees) / (hiFees - loFees)
calcHoldFees = math.avg(boxMax *.95, boxMax )
calcFees = math.avg(boxMax *.95, boxMax ) * .005
var float Feescalc = calcHoldFees
perNormalized = (cost - loPer) / (hiPer - loPer)
calcPer = (math.pow((perNormalized + 1), 20)) + math.avg(priceHi * 2, priceHi * 2, priceHi)
fincalcPer = math.min(boxMax * .915, calcPer)
if year(time) > 2018
hiVol := hiVol[1] > vol ? hiVol[1] : vol
loVol := loVol[1] < vol ? loVol[1] : vol
hiMC := hiMC[1] > mc ? hiMC[1] : mc
loMC := loMC[1] < mc ? loMC[1] : mc
if hiVol != hiVol[1]
priceHi := high
hiCost := hiCost[1] > percentage ? hiCost[1] : percentage
loCost := loCost[1] < percentage ? loCost[1] : percentage
hiFees := hiFees[1] > totfees ? hiFees[1] : totfees
loFees := loFees[1] < totfees ? loFees[1] : totfees
hiPer := hiPer[1] > cost ? hiPer[1] : cost
loPer := loPer[1] < cost ? loPer[1] : cost
if mc >= mc[1]
MCcalc := MCcalc[1] + calcMC
else if mc < mc[1]
MCcalc := MCcalc[1] - calcMC
if ta.change(priceHi)
MCcalc := calcHold
if MCcalc > priceHi * 2
MCcalc := calcHold
if MCcalc < math.avg(priceHi * 2,priceHi * 2,priceHi * 2, priceHi * 2,priceHi)
MCcalc := calcHold
if percentage >= percentage[1]
Costcalc := Costcalc[1] + calcCost
else if percentage < percentage[1]
Costcalc := Costcalc[1] - calcCost
if ta.change(priceHi)
Costcalc := calcHoldCost
if Costcalc > boxMax * 1.07
Costcalc := calcHoldCost
if Costcalc < boxMax * 1.005
Costcalc := calcHoldCost
if totfees >= totfees[1]
Feescalc := Feescalc[1] + calcFees
else if totfees < totfees[1]
Feescalc := Feescalc[1] - calcFees
if ta.change(priceHi)
Feescalc := calcHoldFees
if Feescalc > boxMax * .99
Feescalc := calcHoldFees
if Feescalc < boxMax * .955
Feescalc := calcHoldFees
[volNormalized, priceHi, calc, fincalc, boxMax, mcNormalized, MCcalc,
calcHold, Costcalc, calcHoldCost, calcCost, calcHoldFees, Feescalc,
calcPer, fincalcPer, perNormalized]
[volNorm, priceChart, calc, fincalc, boxMax, mcNormalized, MCcalc,
calcHold, Costcalc, calcCostHold, calcCost, calcHoldPer, Percalc,
calcFees, fincalcFees, feesNormalized]
= normalizedData()
cond(x) =>
switch show
"Yes" => x
"No" => na
"All Data In Stat Table" => na
cond1(x) =>
switch show1
"Yes" => x
"No" => na
"All Data In Stat Table" => x
if last_bar_index - bar_index <= 50
//
array.push(blackBox, box.new(bar_index + 51, box.get_top(array.get(contain, array.size(contain) - 1)), bar_index + 81,
math.avg(priceChart * 2, priceChart * 2, priceChart),
bgcolor = cond(color.new(#000000, 50)), border_color = cond(color.blue)))
array.push(blackBox1, box.new(bar_index + 81, box.get_top(array.get(contain, array.size(contain) - 1)), bar_index + 120,
math.avg(priceChart * 2, priceChart * 2, priceChart),
bgcolor = priceChart == priceChart[38] ? cond(color.new(#000000, 50)) : cond(color.new(color.blue, 90)), border_color = cond(color.blue)))
for i = 0 to 29
array.set(volAvg2, i, fincalc[i])
array.set(MCdata, i, MCcalc[i])
if show == "Yes"
if priceChart == priceChart[30]
array.push(volLineArray, line.new(bar_index + (80 - i),
math.max(box.get_bottom(array.get(contain, 0)),
array.avg(volAvg2)[i + 1]), bar_index + (81 - i),
math.max(box.get_bottom(array.get(contain, 0)),
array.avg(volAvg2)[i])))
if barstate.islast
for i = 0 to 29
array.push(volArray, box.new(bar_index + (80 - i),
array.get(volAvg2, (i)) > priceChart ? array.get(volAvg2, i) :
priceChart + array.get(volAvg2, i), bar_index + (81 - i),
priceChart, bgcolor = na,
border_color = close[i] - open[i] >= 0 ? cond(color.green) : cond(color.red)))
for i = 0 to 29
if priceChart == priceChart[29]
array.push(MC, line.new(bar_index + (79 - i),
array.get(MCdata, i + 1), bar_index + (80 - i),
array.get(MCdata, i), color = cond(#03ff00)))
if array.size(MC2) > 0
for j = 0 to array.size(MC2) - 1
line.delete(array.shift(MC2))
else if priceChart != priceChart[29]
if array.size(MC) > 0
for n = 0 to array.size(MC) - 1
line.delete(array.shift(MC))
break
if priceChart[1] != priceChart[29]
array.push(MC2, line.new(bar_index + (79), array.get(MCdata, 1), bar_index + (80), array.get(MCdata, 0), color = cond(#03ff00)))
if array.size(MC2) > 29
line.delete(array.shift(MC2))
if array.size(MC) > 0
if array.size(MC2) > 0
for i = 0 to array.size(MC2) - 1
line.delete(array.shift(MC2))
if priceChart[38] == priceChart
if array.size(perLineArray) > 38
for n = 0 to 37
line.delete(array.shift(perLineArray))
if priceChart[38] != priceChart
array.push(perLineArray, line.new(bar_index + (119),
Costcalc[1], bar_index + (120),
Costcalc, color = cond(#ffe500), style = line.style_dotted))
if array.size(perLineArray) > 38
line.delete(array.shift(perLineArray))
if array.size(sep) >= 2
if array.size(perLineArray) > 0
if line.get_y1(array.get(perLineArray, array.size(perLineArray) - 1)) >
box.get_top(array.get(contain, array.size(contain) - 1))
or line.get_y1(array.get(perLineArray, array.size(perLineArray)- 1)) <
line.get_y1(array.get(sep, array.size(sep) - 1))
line.delete(array.pop(perLineArray))
for i = 0 to 37
if priceChart[38] == priceChart
array.push(perLineArray, line.new(bar_index + (119 - i),
Costcalc[i + 1], bar_index + (120 - i),
Costcalc[i], color = cond(#ffe500), style = line.style_dotted))
else if priceChart != priceChart[1]
if array.size(perLineArray) > 0
for x = 0 to array.size(perLineArray) - 1
line.delete(array.shift(perLineArray))
break
if array.size(sep) >= 2
for i = 1 to 38
if priceChart == priceChart [38]
if array.size(fee) > 38
for n = 0 to 37
box.delete(array.shift(fee))
if array.size(blackBox1) > 0
array.push(fee, box.new(bar_index + (119 - i), fincalcFees[i],
bar_index + (120 - i), math.avg(priceChart * 2, priceChart * 2, priceChart) * 1.003,
border_color = close[i] > open[i] ? cond(#00ffff) : cond(color.white), bgcolor = na))
else
break
if priceChart != priceChart[1]
if priceChart[1] == priceChart[2]
if array.size(fee) > 0
for n = 0 to array.size(fee) - 1
box.delete(array.shift(fee))
for i = 0 to 36
array.push(costLabArray, label.new(bar_index + (119 - i),
Percalc[i], textcolor = cond(#5d00ff), text = "𝅇", color = na))
if array.size(fee) == 0
array.push(FEE, box.new(bar_index + (119), fincalcFees,
bar_index + (120), math.avg(priceChart * 2, priceChart * 2, priceChart) * 1.003,
border_color = close > open ? cond(#00ffff) : cond(color.white), bgcolor = na))
if array.size(FEE) > 38
box.delete(array.shift(FEE))
if array.size(MC) > 30
for i = 0 to 29
line.delete(array.shift(MC))
if priceChart == priceChart[38]
if array.size(FEE) > 0
for i = 0 to array.size(FEE) - 1
box.delete(array.shift(FEE))
if priceChart != priceChart[30]
if array.size(volLineArray) > 0
for i = 0 to array.size(volLineArray) - 1
line.delete(array.shift(volLineArray))
if array.size(FEE) > 0
for i = 0 to array.size(FEE) - 1
if box.get_top(array.get(FEE, i)) > boxMax * .93
box.delete(array.get(FEE, i))
if array.size(costLabArray) > 0
if array.size(sep) > 1
for i = 0 to array.size(costLabArray) - 1
if label.get_y(array.get(costLabArray, i)) >
line.get_y1(array.get(sep, array.size(sep) - 2))
or label.get_y(array.get(costLabArray, i)) <
line.get_y1(array.get(sep, array.size(sep) - 1))
label.delete(array.get(costLabArray, i))
array.push(stat, label.new(bar_index + 67, math.avg(priceChart * 2, priceChart * 2, priceChart) * .935, text = "Exchange Volume \n" + str.tostring(vol, format.volume),
color = na,
size = size.normal,
textcolor = cond(#00ffff),
style = label.style_label_up))
array.push(stat, label.new(bar_index + 85, box.get_bottom(array.get(contain, array.size(contain) - 1)) * .965,
text = "Transaction Volume USD: $" + str.tostring(usd, format.volume),
color = na, size = size.small, textcolor = cond(color.white),
style = label.style_label_up))
array.push(stat, label.new(bar_index + 135, box.get_top(array.get(contain, array.size(contain) - 1)),
text = "Cost % of \nTransaction Volume: \n" + str.tostring(percentage, format.percent),
color = na, size = size.small, textcolor = cond(color.white),
style = label.style_label_up))
if array.size(stat) > 2
array.push(stat, label.new(bar_index + 135, label.get_y(array.get(stat, array.size(stat) - 1)) * .90,
text = "Total Transaction\n Fees USD: \n$" + str.tostring(totfees, "###,###,###.00"),
color = na,
size = size.small,
textcolor = cond(color.white),
style = label.style_label_up))
if array.size(stat) > 3
array.push(stat, label.new(bar_index + 136, label.get_y(array.get(stat, array.size(stat) - 1)) * .88,
text = "Cost Per Transaction: \n$" + str.tostring(cost, "###,###,###.00"),
color = na, size = size.small,
textcolor = cond(color.white),
style = label.style_label_up))
array.push(stat, label.new(bar_index + 100, math.avg(box.get_bottom(array.get(contain, array.size(contain) - 1)),
box.get_bottom(array.get(contain, array.size(contain) - 1)),
box.get_top(array.get(contain, array.size(contain) - 1))),
text = "Median Transaction \n Confrimation Time" ,
color = na, size = size.small,
textcolor = cond(color.white), style = label.style_label_up))
stat5 := box.new(bar_index + 90, label.get_y(array.get(stat, array.size(stat)- 1)) * .97, bar_index + 110, label.get_y(array.get(stat, array.size(stat)- 1)) * .88,
text = str.tostring(con, format.mintick) + "ᵐ" ,
bgcolor = cond(#000000),
text_size = size.large,
border_color = cond(color.blue),
text_color = cond(color.red))
array.push(arrows, label.new(
bar_index + 126,
box.get_top(array.get(contain, array.size(contain) - 1)) * .957,
text = "⏎",
textcolor = cond(#ffe500),
color = na, size = size.huge
))
array.push(arrows, label.new(
bar_index + 126,
label.get_y(array.get(stat, array.size(stat) - 3)) * .957,
text = "⏎",
textcolor = cond(#5d00ff),
color = na, size = size.huge
))
array.push(arrows, label.new(
bar_index + 126,
math.avg(priceChart * 2, priceChart * 2, priceChart) * .99,
text = "⏎",
color = na,
textcolor = close > open ? cond(#00ffff) : cond(color.white), size = size.huge
))
if array.size(stat) > 4
array.push(sep, line.new(bar_index + 81, boxMax,
bar_index + 120,
boxMax,
color = cond(color.blue)))
array.push(sep, line.new(bar_index + 81, boxMax * .93 ,
bar_index + 120,
boxMax * .93,
color = cond(color.blue)))
box.delete(stat5[1])
if array.size(arrows) > 3
for i = 0 to 2
label.delete(array.shift(arrows))
array.push(blackBoxLab, label.new(bar_index + 66, box.get_top(array.get(contain, array.size(contain) - 1)) * .955,
text = "Market Cap \n" + str.tostring(mc, format.volume),
style = label.style_label_up,
color = na,
textcolor = cond(#03ff00)))
array.push(contain, box.new(bar_index + 51, math.max(boxMax * 1.07, priceChart * 1.75),
bar_index + 120,
priceChart,
bgcolor = na,
border_color = cond(color.blue)))
if array.size(contain) > 1
box.delete(array.shift(contain))
if array.size(blackBox) > 1
box.delete(array.shift(blackBox))
if array.size(blackBoxLab) > 1
label.delete(array.shift(blackBoxLab))
if array.size(blackBox1) > 1
box.delete(array.shift(blackBox1))
if array.size(sep) > 2
for i = 0 to 1
line.delete(array.shift(sep))
if array.size(stat) > 6
for i = 0 to 5 by 1
label.delete(array.shift(stat))
if array.size(volArray) > 30
for i = 0 to 29
box.delete(array.shift(volArray))
if array.size(volLineArray) > 30
for i = 0 to 29
line.delete(array.shift(volLineArray))
if array.size(volArray) > 0
for i = 0 to array.size(volArray) - 1
if box.get_top(array.get(volArray, i)) >
math.avg(priceChart * 2, priceChart * 2, priceChart)[0]
box.delete(array.get(volArray, i))
if array.size(costLabArray) > 37
for i = 0 to 36
label.delete(array.shift(costLabArray))
position = switch tablePos
"Top Left" => position.top_left
"Top Center" => position.top_center
"Top Right" => position.top_right
"Bottom Left" => position.bottom_left
"Bottom Center" => position.bottom_center
"Bottom Right" => position.bottom_right
"Middle Left" => position.middle_left
"Middle Center" => position.middle_center
"Midde Right" => position.middle_right
color textCond = cond1(color.white)
var table tab = na
tab := table.new(position, 100, 100 , bgcolor = cond1(color.new(color.blue, 90)),
frame_width = 1,
frame_color = cond1(color.white),
border_width = 1,
border_color = cond1(color.white))
table.cell(tab, 0, 0, text = "Difficulty", text_color = textCond, text_size = size.small)
table.cell(tab, 1, 0, text = str.tostring(difficulty, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 1, text = "My Wallet # of Users", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 1, text = str.tostring(wallet, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 2, text = "Average Block Size", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 2, text = str.tostring(size, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 3, text = "Hash Rate", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 3, text = str.tostring(tate, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 4, text = "Transactions Per Block", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 4, text = str.tostring(tpb, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 5, text = "# of Unique BTC Adresses", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 5, text = str.tostring(unique, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 6, text = "Total Output Volume", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 6, text = str.tostring(output, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 0, 7, text = "# of Transactions \n(Excluding Popular Addresses)", text_color = textCond,text_size = size.small)
table.cell(tab, 1, 7, text = str.tostring(pop, "###,###,###"), text_color = textCond,text_size = size.small)
if show == "All Data In Stat Table"
table.cell(tab, 2, 0, text = "Exchange Volume", text_color = textCond, text_size = size.small)
table.cell(tab, 3, 0, text = str.tostring(vol, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 1, text = "Transaction Volume USD", text_color = textCond,text_size = size.small)
table.cell(tab, 3, 1, text = str.tostring(usd, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 2, text = "Median Transaction \n Confirmation Time", text_color = textCond,text_size = size.small)
table.cell(tab, 3, 2, text = str.tostring(con, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 3, text = "Cost Per Transaction", text_color = textCond,text_size = size.small)
table.cell(tab, 4, 3, text = str.tostring(cost, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 4, text = "Total Transaction Fees USD", text_color = textCond,text_size = size.small)
table.cell(tab, 4, 4, text = str.tostring(totfees, "###,###,###.0000"), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 5, text = "Cost % of Transaction Volume", text_color = textCond,text_size = size.small)
table.cell(tab, 4, 5, text = str.tostring(percentage, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 6, text = "Market Cap", text_color = textCond,text_size = size.small)
table.cell(tab, 4, 6, text = str.tostring(mc,format.volume), text_color = textCond,text_size = size.small)
table.cell(tab, 2, 7, text = "Total BTC", text_color = textCond,text_size = size.small)
table.cell(tab, 4, 7, text = str.tostring(tbtc, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 4, 0, text = "Miners' Revenue", text_color = textCond, text_size = size.small)
table.cell(tab, 5, 0, text = str.tostring(rev, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 4, 1, text = "api.blockchain Size", text_color = textCond,text_size = size.small)
table.cell(tab, 5, 1, text = str.tostring(api, "###,###,###"), text_color = textCond,text_size = size.small)
table.cell(tab, 4, 2, text = "Total Transactions", text_color = textCond,text_size = size.small)
table.cell(tab, 5, 2, text = str.tostring(tot, "###,###,###"), text_color = textCond,text_size = size.small)
table.merge_cells(tab, 2, 3, 3, 3)
table.merge_cells(tab, 2, 4, 3, 4)
table.merge_cells(tab, 2, 5, 3, 5)
table.merge_cells(tab, 2, 6, 3, 6)
table.merge_cells(tab, 2, 7, 3, 7)
table.merge_cells(tab, 4, 3, 5, 3)
table.merge_cells(tab, 4, 4, 5, 4)
table.merge_cells(tab, 4, 5, 5, 5)
table.merge_cells(tab, 4, 6, 5, 6)
table.merge_cells(tab, 4, 7, 5, 7)
// _______________________________________________________
//
// Defining Fiscal Quarter Periods
// _______________________________________________________
var startCalculations = matrix.new<float>(3, 5)
var float [] Qcalculations = array.new_float()
var float [] cumulCalc = array.new_float()
var float [] x = array.new_float()
if barstate.isfirst
for c = 0 to matrix.columns(startCalculations) - 1
matrix.set(startCalculations, 0, c, 0)
matrix.set(startCalculations, 1, c, 0)
array.push(Qcalculations, 0)
if bar_index > 0
if year(time) != year(time[1])
matrix.set(startCalculations, 0, 0, 1)
array.push(cumulCalc, rev)
matrix.set(startCalculations, 1, 0, array.sum(cumulCalc))
if matrix.get(startCalculations, 0, 0) == 1
if time >= timestamp(year(time), 01,01,00,00,05) and time <= timestamp(year(time), 03, 31, 23, 59, 59)
matrix.set(startCalculations, 0, 1, 1)
array.push(Qcalculations, rev)
matrix.set(startCalculations, 1, 1, array.sum(Qcalculations))
else
matrix.set(startCalculations, 0, 1, 0)
matrix.set(startCalculations, 1, 1, 0)
if matrix.get(startCalculations, 0, 1)[1] == 1
if matrix.get(startCalculations, 0, 1) == 0
array.clear(Qcalculations)
array.clear(x)
if time >= timestamp(year(time), 04, 1, 00, 00, 00) and time <= timestamp(year(time), 06, 30, 23, 59, 59)
matrix.set(startCalculations, 0, 2, 1)
array.push(Qcalculations, rev)
matrix.set(startCalculations, 1, 2, array.sum(Qcalculations))
else
matrix.set(startCalculations, 0, 2, 0)
matrix.set(startCalculations, 1, 2, 0)
if matrix.get(startCalculations, 0, 2)[1] == 1
if matrix.get(startCalculations, 0, 2) == 0
array.clear(Qcalculations)
array.clear(x)
if time >= timestamp(year(time), 07, 1, 00, 00, 00) and time <= timestamp(year(time), 09, 30, 23, 59, 59)
matrix.set(startCalculations, 0, 3, 1)
array.push(Qcalculations, rev)
matrix.set(startCalculations, 1, 3, array.sum(Qcalculations))
else
matrix.set(startCalculations, 0, 3, 0)
matrix.set(startCalculations, 1, 3, 0)
if matrix.get(startCalculations, 0, 3)[1] == 1
if matrix.get(startCalculations, 0, 3) == 0
array.clear(Qcalculations)
array.clear(x)
if time >= timestamp(year(time), 10, 1, 00, 00, 00) and time <= timestamp(year(time), 12, 31, 23, 59, 59)
matrix.set(startCalculations, 0, 4, 1)
array.push(Qcalculations, rev)
matrix.set(startCalculations, 1, 4, array.sum(Qcalculations))
else
matrix.set(startCalculations, 0, 4, 0)
matrix.set(startCalculations, 1, 4, 0)
if time == timestamp(year(time), 01, 01, 00, 00, 00)
array.clear(Qcalculations)
array.clear(x)
lin() =>
array.push(x, close)
X = array.sum(x) / array.size(x) -
(ta.linreg(close, array.size(x), 0) -
ta.linreg(close, array.size(x), 1)) *
math.floor(array.size(x) / 2) + 0.5 *
(ta.linreg(close, array.size(x), 0) -
ta.linreg(close, array.size(x), 1))
Y = (array.sum(x) / array.size(x) -
(ta.linreg(close, array.size(x), 0) -
ta.linreg(close, array.size(x), 1)) *
math.floor(array.size(x) / 2)) +
(ta.linreg(close, array.size(x), 0) -
ta.linreg(close, array.size(x), 1)) *
(array.size(x) - 1)
stDev = ta.stdev(X, array.size(x) > 0 ? array.size(x) : 1) * 4
[X, Y, stDev]
[X, Y, stDev] = lin()
cond2(x) =>
switch show2
"Yes" => x
"No" => na
cond3(x) =>
switch show
"Yes" => x
"No" => x
"All Data in Stat Table" => color.new(color.white, 100)
vars() =>
n = array.size(x)[1]
n1 = ta.highest(math.ceil(high), n > 0 ? n : 1)
[n, n1]
[n, n1] = vars()
var line [] xy = array.new_line(2)
var linefill[] xyfill = array.new_linefill(2)
var line [] xyperm = array.new_line()
var linefill[] permfill = array.new_linefill()
var label [] minlab = array.new_label()
var label [] minlabperm = array.new_label()
array.push(xy, line.new(bar_index + 1 - array.size(x), X + stDev, bar_index+ 20, Y + stDev, color = cond2(color.blue)))
array.push(xy, line.new(bar_index + 1 - array.size(x), X - stDev, bar_index + 20, Y - stDev, color = cond2(color.blue)))
array.push(xyfill, linefill.new(array.get(xy, array.size(xy) - 1), array.get(xy, array.size(xy) - 2), color = cond2(color.new(color.blue, 90))))
array.push(minlab, label.new(bar_index, math.max(high, X + stDev, Y + stDev), style = label.style_label_down, text = "Cumulative Miners' Revenue\n$" +
str.tostring(matrix.get(startCalculations, 1 ,
matrix.get(startCalculations, 0, 1) == 1 ? 1 :
matrix.get(startCalculations, 0, 2) == 1 ? 2 :
matrix.get(startCalculations, 0, 3) == 1 ? 3 : 4
),format.volume ) + " USD", textcolor = cond3(#000000),
color = cond3(color.new(#ffffff, 40)), size = size.small
))
if array.size(xy) > 2
for i = 0 to 1
line.delete(array.shift(xy))
if array.size(xyfill) > 2
for i = 0 to 1
linefill.delete(array.shift(xyfill))
if array.size(x) == 1
array.push(xyperm, line.new(bar_index - n, X[1] + stDev[1], bar_index, Y[1] + stDev[1], color = cond2(color.new(#ffffff, 30)), style = line.style_dashed, width = 2))
array.push(xyperm, line.new(bar_index - n, X[1] - stDev[1], bar_index, Y[1] - stDev[1], color = cond2(color.new(#ffffff, 30)), style = line.style_dashed, width = 2))
array.push(permfill, linefill.new(array.get(xyperm, array.size(xyperm) - 1), array.get(xyperm, array.size(xyperm) - 2), color = cond2(color.new(#ffffff, 90))))
array.push(minlabperm, label.copy(array.get(minlab, 0)[1]))
label.set_x(array.get(minlabperm, array.size(minlabperm) - 1), math.ceil(bar_index - n / 2))
label.set_y(array.get(minlabperm, array.size(minlabperm) - 1), math.max(Y[math.ceil(n / 2)] + stDev[math.ceil(n /2)], n1) * 1.12)
label.set_style(array.get(minlabperm, array.size(minlabperm) - 1), label.style_label_center)
label.set_color(array.get(minlabperm, array.size(minlabperm) - 1), cond3(color.new(#000000, 40)))
label.set_textcolor(array.get(minlabperm, array.size(minlabperm) - 1), cond3(color.white))
label.set_size(array.get(minlabperm, array.size(minlabperm) - 1), size.tiny)
if array.size(minlab) > 1
label.delete(array.shift(minlab))
// _______________________________________________________
//
// Lower Timeframe
// _______________________________________________________
[middle, upper, lower] = ta.bb(close, 20, 2.0)
b = (close - lower)/(upper - lower)
k = ta.stoch(close, high, low, 14)
request = switch TFdata
"Close" => close
"High" => high
"Low" => low
"Open" => open
"HL2" => hl2
"HLC3" => hlc3
"OHLC4" => ohlc4
"HLCC4" => hlcc4
"Volume" => volume
"RSI" => ta.rsi(close, 14)
"EMA 20" => ta.ema(close, 20)
"%b" => b
"Stochastic" => k
"VWAP" => ta.vwap
TIME = switch TF
"1 Minute" => " Minutes"
"5 Minute" => " Minutes"
"15 Minute" => " Minutes"
"30 Minute" => " Minutes"
"45 Minute" => " Minutes"
"1 Hour" => " Hours"
"2 Hour" => " Hours"
"3 Hour" => " Hours"
"4 Hour" => " Hours"
"Custom" => " Minutes"
MULT = switch TF
"1 Minute" => 1
"5 Minute" => 5
"15 Minute" => 15
"30 Minute" => 30
"45 Minute" => 45
"1 Hour" => 1
"2 Hour" => 2
"3 Hour" => 3
"4 Hour" => 4
"Custom" => custom
var table TAB = na
var string [] tri = array.new_string()
var string [] GL = array.new_string()
lowTF = request.security_lower_tf(syminfo.tickerid, trueTF, request)
show4 = input.string("Yes", title = "Show LTF Data?", options = ["Yes", "No"])
lowTFstring = ""
SIZE() =>
array.size(lowTF) > 30 ? 30 : array.size(lowTF) > 0 and array.size(lowTF) <= 30 ? array.size(lowTF) - 1 : na
array.reverse(lowTF)
if barstate.islast
if show4 == "Yes"
if array.size(lowTF) > 1
for i = 1 to SIZE()
if array.get(lowTF, i) < array.get(lowTF, i - 1)
array.push(tri, "△")
array.push(GL, "+")
else if array.get(lowTF, i) >= array.get(lowTF, i - 1)
array.push(tri, "▼")
array.push(GL, "-")
if array.size(tri) > 1
if array.size(GL) > 1
if array.size(lowTF) > 1
for j = 1 to SIZE()
lowTFstring := lowTFstring + str.tostring(array.get(lowTF, j - 1), "###,###,###.00") + " " +
str.tostring((j - 1) * MULT) + TIME + " " + array.get(tri, j- 1) + " (" +
array.get(GL, j - 1) + " " + str.tostring(math.abs(array.get(lowTF, j - 1) -
array.get(lowTF, j)), "###,###,###.00") + ")\n"
TAB := table.new(position.top_right, 100, 100, bgcolor = color.new(color.green, 90), border_color = color.white, frame_color = color.white, frame_width = 1, border_width = 1)
if array.size(tri) > 0
for i = 1 to SIZE()
table.cell(TAB, 0, 0, str.tostring(MULT) + TIME + " " + TFdata, text_color = color.white, text_halign = text.align_center, text_size = size.small)
table.cell(TAB, 0, 1, lowTFstring, text_color = color.white, text_halign = text.align_left)
// _______________________________________________________
//
// Optional Plots
// _______________________________________________________
plot(price ,display = display.none, title = "True Price ", color = color.blue )
plot(vol ,display = display.none, title = "Exchange Volume ", color = color.red )
plot(difficulty ,display = display.none, title = "Difficulty ", color = color.green )
plot(wallet ,display = display.none, title = "My Wallet # of Users ", color = color.orange )
plot(size ,display = display.none, title = "Average Block Size ", color = color.yellow )
plot(api ,display = display.none, title = "api.blockchain Size ", color = color.purple )
plot(con ,display = display.none, title = "Median Transaction Confirmation Time ", color = color.gray )
plot(rev ,display = display.none, title = "Miners' Revenue", color = color.white )
plot(tate ,display = display.none, title = "Hash Rate", color = color.teal )
plot(cost ,display = display.none, title = "Cost Per Transaction", color = color.olive )
plot(percentage ,display = display.none, title = "Cost % of Transaction Volume", color = color.maroon )
plot(usd ,display = display.none, title = "Transaction Volume USD", color = color.silver )
plot(output ,display = display.none, title = "Total Output Volume", color = color.navy )
plot(tpb ,display = display.none, title = "Number of Transactions Per Block", color = color.lime )
plot(unique ,display = display.none, title = "# of Unique BTC Addresses", color = color.fuchsia)
plot(tot ,display = display.none, title = "Total Number of Transactions", color = color.black )
plot(day ,display = display.none, title = "Daily Number of Transactions", color = color.aqua )
plot(totfees ,display = display.none, title = "Total Transaction Fees (USD) ", color = #000000 )
plot(mc ,display = display.none, title = "Market Cap", color = #148328 )
plot(pop ,display = display.none, title = "# of BTC Transactions Excluding Popular Addresses ", color = #437891 )
plot(tbtc ,display = display.none, title = "Total BTC ", color = #538271 )
if timeframe.isintraday
runtime.error("This script runs on DWM charts")
|
Volume Impulse & Candlestick Patterns - Fontiramisu | https://www.tradingview.com/script/Zx7msQXc-Volume-Impulse-Candlestick-Patterns-Fontiramisu/ | Fontiramisu | https://www.tradingview.com/u/Fontiramisu/ | 277 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Author : @Fontiramisu
// Indicator showing volume impulse & candlestick pattern.
//@version=5
indicator("Candlestick Patterns & Volume Signal - Fontiramisu", shorttitle = "Pattern & Volume Sign", overlay=true)
// ----------------- Candlestick Patterns ----------------- [
tfInput = input.timeframe("")
tfClose = request.security(syminfo.tickerid, tfInput, close)
tfHigh = request.security(syminfo.tickerid, tfInput, high)
tfLow = request.security(syminfo.tickerid, tfInput, low)
tfOpen = request.security(syminfo.tickerid, tfInput, open)
//bar_index request.security(syminfo.tickerid, tfInput, bar_index)
// Calculate Input Parameters.
lenghtSizeAvgBody = input.int(14, title="Lenght Size Avg Body", tooltip="Lenght used to calculate the average body size (ema method is used)", group="Calculate Parameters")
// Calculate Variables.
C_DownTrend = true
C_UpTrend = true
var trendRule1 = "SMA50"
var trendRule2 = "SMA50, SMA200"
var trendRule = input.string(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"], group="Calculate Parameters")
if trendRule == trendRule1
priceAvg = ta.sma(tfClose, 50)
C_DownTrend := tfClose < priceAvg
C_UpTrend := tfClose > priceAvg
if trendRule == trendRule2
sma200 = ta.sma(tfClose, 200)
sma50 = ta.sma(tfClose, 50)
C_DownTrend := tfClose < sma50 and sma50 < sma200
C_UpTrend := tfClose > sma50 and sma50 > sma200
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body
C_BodyHi = math.max(tfClose, tfOpen)
C_BodyLo = math.min(tfClose, tfOpen)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ta.ema(C_Body, lenghtSizeAvgBody)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = tfHigh - C_BodyHi
C_DnShadow = C_BodyLo - tfLow
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = tfOpen < tfClose
C_BlackBody = tfOpen > tfClose
C_Range = tfHigh-tfLow
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
C_ShadowEquals = C_UpShadow == C_DnShadow or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals
// Y Pos for label.
patternLabelPostfLow = tfLow - (ta.atr(30) * 0.7)
patternLabelPostfHigh = tfHigh + (ta.atr(30) * 0.7)
// Show Parameter.
label_color_bullish = input(color.blue, "Label Color Bullish", group="show parameters")
label_color_bearish = input(color.red, "Label Color Bearish", group="show parameters")
label_color_neutral = input(color.gray, "Label Color Neutral", group="show parameters")
CandleType = input.string(title = "Pattern Type", defval="Both", options=["Bullish", "Bearish", "Both"], group="show parameters")
// Engulfing.
EngulfingInput = input(title = "Show Engulfing" ,defval=true, group="Engulfing Pattern")
isCompareAvgBodyEngulfing = input(title = "VS avg body" ,defval=false, group="Engulfing Pattern", tooltip="Check the box if you want to compare body candle to average of the last few ones, otherwise it will be compare to the last one")
engulfingMultiplier = input.float(defval=3, title = "Engulfing Multiplier", group="Engulfing Pattern", tooltip="Minimum multiplier to validate the pattern")
bodyCompareEngulfing = isCompareAvgBodyEngulfing ? C_BodyAvg : C_Body[1]
C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and tfOpen <= tfClose[1] and tfClose >= tfOpen[1] and C_Body > bodyCompareEngulfing * engulfingMultiplier
alertcondition(C_EngulfingBullish, title = "Engulfing – Bullish", message = "New Engulfing – Bullish pattern detected")
if C_EngulfingBullish and EngulfingInput and (("Bullish" == CandleType) or CandleType == "Both")
var ttBullishEngulfing = "Engulfing\nAt the end of a given downward trend, there will most likely be a reversal pattern. To distinguish the first day, this candlestick pattern uses a small body, foltfLowed by a day where the candle body fully overtakes the body from the day before, and tfCloses in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to completely overtake the range (tfHigh to tfLow), rather only the tfOpen and the tfClose."
label.new(bar_index, patternLabelPostfLow, text="BE", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = ttBullishEngulfing)
C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and tfOpen >= tfClose[1] and tfClose < tfOpen[1] and C_Body > bodyCompareEngulfing * engulfingMultiplier
alertcondition(C_EngulfingBearish, title = "Engulfing – Bearish", message = "New Engulfing – Bearish pattern detected")
if C_EngulfingBearish and EngulfingInput and (("Bearish" == CandleType) or CandleType == "Both")
var ttBearishEngulfing = "Engulfing\nAt the end of a given uptrend, a reversal pattern will most likely appear. During the first day, this candlestick pattern uses a small body. It is then foltfLowed by a day where the candle body fully overtakes the body from the day before it and tfCloses in the trend’s opposite direction. Although similar to the outside reversal chart pattern, it is not essential for this pattern to fully overtake the range (tfHigh to tfLow), rather only the tfOpen and the tfClose."
label.new(bar_index, patternLabelPostfHigh, text="BE", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = ttBearishEngulfing)
// ]----------------- Volume Signals ----------------- [
// Inputs.
showVolumeImpulseInput = input.bool(true,"Show Volume Impulse", group="Volume")
lengthVolume = input.int(20,"Volume Period", group="Volume", tooltip="Lenght of the average volume calculated")
factor = input.float(3.5,"Volume Multiplier", minval=0, group="Volume", tooltip="Factor you want to set to compare actual volume with average volume")
// Helping vars.
smaVolume = ta.sma(volume, lengthVolume)
isVolUp = close > open
isVolDown = open > close
isVolImpulse = volume > smaVolume * factor
// Cond + label
if showVolumeImpulseInput
if isVolImpulse and isVolUp
label.new(bar_index, patternLabelPostfLow, text="VI", style=label.style_label_up, color = label_color_bullish, textcolor=color.white, tooltip = "Volume Impulse Up")
else if isVolImpulse and isVolDown
label.new(bar_index, patternLabelPostfHigh, text="VI", style=label.style_label_down, color = label_color_bearish, textcolor=color.white, tooltip = "Volume Impulse Down")
// ] DEBUG -- Show Table -- [
// show_table = input(true, "Show table with stats", group = "Drawings")
// if show_table
// var table ATHtable = table.new(position.bottom_right, 10, 10, frame_color = color.gray, bgcolor = color.gray, border_width = 1, frame_width = 1, border_color = color.white)
// table.cell(ATHtable, 0, 0, text="C_LongBody", bgcolor=color.silver, tooltip="")
// // table.cell(ATHtable, 1, 0, text="na", bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 1, 0, text=str.tostring(C_LongBody), bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 0, 1, text="C_UpTrend", bgcolor=color.silver, tooltip="")
// table.cell(ATHtable, 1, 1, text=str.tostring(C_UpTrend), bgcolor=color.green, tooltip="")
// // ]
|
Asia Reversal Zone | https://www.tradingview.com/script/gyMF5j3s-Asia-Reversal-Zone/ | NeverWishing | https://www.tradingview.com/u/NeverWishing/ | 48 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © NeverWishing
//@version=5
indicator(title="Asia Reversal Zone", shorttitle="ARZ", overlay=true)
// Get user input
timezone = input.session(title="Timezone To Highlight", defval="2048-2128")
alertSessionStart = input.bool(title="Alert When Session Starts?", defval=true)
alertWhenSessionStarts = input.session(title="Alert When Session Starts At", defval="0830-0830")
alertSessionEnd = input.bool(title="Alert When Session Ends?", defval=true)
alertWhenSessionEnds = input.session(title="Alert When Session Ends At", defval="1830-1830")
paintBg = input.bool(title="Paint Background?", defval=true)
blankInsideCandles = input.bool(title="Color Candles Within Zone?", defval=false)
hideOn240AndAbove = input.bool(title="Hide on 4HR And Above?", defval=false)
hideTimeframeCB = input.bool(title="Hide On Other Timeframe?", defval=false)
hideTimeframe = input.string(title="Other Timeframe To Hide", defval="60")
// Determine whether or not this timeframe is to be ignored
hide = hideTimeframeCB and timeframe.period == hideTimeframe or
hideOn240AndAbove and
(timeframe.period == "240" or
timeframe.period == "D" or
timeframe.period == "W" or
timeframe.period == "M")
// InSession() determines if a price bar falls inside the specified session
InSession(sess) => na(time(timeframe.period, sess + ":1234567")) == false
// Color the background of each relevant session and/or bar
bgcolor(color=InSession(timezone) and paintBg and not hide ? color.new(color.red, 75) : na, title="Not In Session")
barcolor(color=InSession(timezone) and blankInsideCandles and not hide ? color.white : na)
// Send out an alert if this candle meets our conditions
alertcondition((InSession(alertWhenSessionStarts) and alertSessionStart) or (InSession(alertWhenSessionEnds) and alertSessionEnd), title="Session Alert!", message="Session signal for {{ticker}}")
plot(close)
|
Polarity Divergences | https://www.tradingview.com/script/84Sr3GS4-Polarity-Divergences/ | TradingView | https://www.tradingview.com/u/TradingView/ | 478 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TradingView
//@version=5
indicator("Polarity Divergences", overlay = true)
// Polarity Divergences
// v2, 2022.07.30
// This code was written using the recommendations from the Pine Script™ User Manual's Style Guide:
// https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html
bool showCharUpInput = input.bool(false, "Show character on divergences for up bars")
string charUpInput = input.string("↗", " Character", inline = "01")
color charUpColorInput = input.color(color.lime, "", inline = "01")
bool charUpBelowInput = input.bool(true, "Below bar", inline = "01")
bool showCharDnInput = input.bool(false, "Show character on divergences for down bars")
string charDnInput = input.string("↘", " Character", inline = "02")
color charDnColorInput = input.color(color.fuchsia, "", inline = "02")
bool charDnAboveInput = input.bool(true, "Above bar", inline = "02")
bool fillBodiesInput = input.bool(true, "Fill candle bodies on divergences")
// @function Selects a LTF from the chart's TF.
// @returns (simple string) A timeframe string.
ltfStep() =>
int MS_IN_DAY = 1000 * 60 * 60 * 24
int tfInMs = timeframe.in_seconds() * 1000
string result =
switch
tfInMs < MS_IN_DAY => "1"
tfInMs < MS_IN_DAY * 7 => "30"
=> "D"
// Calculate the polarity of the chart bar.
float chartBarPolarity = math.sign(close - open)
// Fetch an array containing the +1/0/-1 polarity of each intrabar.
float[] polaritiesArray = request.security_lower_tf(syminfo.tickerid, ltfStep(), chartBarPolarity)
// Calculate the average polarity of intrabars.
float intrabarPolarity = math.sign(array.sum(polaritiesArray))
// Color the chart bar orange when the majority of intrabar polarities does not match that of the chart bar.
barcolor(fillBodiesInput and intrabarPolarity != chartBarPolarity ? color.orange : na)
// Plot characters showing divergence direction, if enabled.
plotchar(showCharUpInput ? intrabarPolarity < chartBarPolarity : na, "Div. on up bar", charUpInput, charUpBelowInput ? location.belowbar : location.abovebar, charUpColorInput, size = size.tiny)
plotchar(showCharDnInput ? intrabarPolarity > chartBarPolarity : na, "Div. on down bar", charDnInput, charDnAboveInput ? location.abovebar : location.belowbar, charDnColorInput, size = size.tiny)
|
LNL Squeeze Arrows | https://www.tradingview.com/script/PAlPBCb9-LNL-Squeeze-Arrows/ | lnlcapital | https://www.tradingview.com/u/lnlcapital/ | 385 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// L&L Squeeze Arrows
//
// Squeeze Arrows pinpoint the exact moment where the squeeze momentum change happens (momentum change is CRUCIAL for the squeeze setup)
//
// Two types of arrows: 1.Squezee Arrows - showing the best entries for this setup. 2.Slingshot Arrows - showing the current direction of the squeeze (caution / confirmation tool)
//
// If an opposite arrow is plotted = stay away from the trade & wait for the true momentum change (Last Arrow is the valid signal)
//
// Created by © L&L Capital
//
indicator("LNL Squeeze Arrows",shorttitle="Squeeze Arrows", overlay=true)
// Inputs
length = 20
SqueezeCount = input(defval = 5,title='Squeze Dots Trigger')
// Squeeze Calculations
BB_mult = 2.0
BB_basis = ta.sma(close, length)
dev = BB_mult * ta.stdev(close, length)
BB_upper = BB_basis + dev
BB_lower = BB_basis - dev
KC_mult_high = 1.0
KC_mult_mid = 1.5
KC_mult_low = 2.0
KC_basis = ta.sma(close, length)
devKC = ta.sma(ta.tr, length)
KC_upper_high = KC_basis + devKC * KC_mult_high
KC_lower_high = KC_basis - devKC * KC_mult_high
KC_upper_mid = KC_basis + devKC * KC_mult_mid
KC_lower_mid = KC_basis - devKC * KC_mult_mid
KC_upper_low = KC_basis + devKC * KC_mult_low
KC_lower_low = KC_basis - devKC * KC_mult_low
NoSqz = BB_lower < KC_lower_low or BB_upper > KC_upper_low
//LowSqz = BB_lower >= KC_lower_low or BB_upper <= KC_upper_low
MidSqz = BB_lower >= KC_lower_mid or BB_upper <= KC_upper_mid
//HighSqz = BB_lower >= KC_lower_high or BB_upper <= KC_upper_high
SqzOff = BB_lower < KC_lower_mid and BB_upper > KC_upper_mid
// Squeeze Histogram Calculations
momo = ta.linreg(close - math.avg(math.avg(ta.highest(high, length), ta.lowest(low, length)), ta.sma(close, length)), length, 0)
iff_1 = momo > 0 and momo > nz(momo[1]) // Histogram Pos & Up
iff_2 = momo < 0 and momo < nz(momo[1]) // Histogram Neg & Dn
momo_color = momo > 0 ? iff_1 : iff_2
HistogramUp = iff_1
HistogramDn = iff_2
// Arrows Calculations
GreenCandle = close > open
RedCandle = close < open
ema8 = ta.ema(close, 8)
ema21 = ta.ema(close, 24)
ema34 = ta.ema(close, 34)
ema55 = ta.ema(close, 55)
StackedEMAsUp = ema8 > ema21 and ema34 > ema55
StackedEMAsDn = ema8 < ema21 and ema34 < ema55
// Squeeze Trigger Calculations
normal = 0.0
normal := nz(normal[1])
if (SqzOff)
normal := 0
else
if (MidSqz)
normal := normal + 1
SqueezeTrigger = (normal >= SqueezeCount)
// Fisher Shift Arrows
flength = 5
high_ = ta.highest(hl2, flength)
low_ = ta.lowest(hl2, flength)
round_(val) => val > .99 ? .999 : val < -.99 ? -.999 : val
value = 0.0
value := round_(.66 * ((hl2 - low_) / math.max(high_ - low_, .001) - .5) + .67 * nz(value[1]))
fish1 = 0.0
fish1 := .5 * math.log((1 + value) / math.max(1 - value, .001)) + .5 * nz(fish1[1])
fish2 = fish1[1]
FisherUp =ta.crossover(fish1,fish2) and fish1 < 0
FisherDn = ta.crossunder(fish1,fish2) and fish1 > 0
// Plots
// Squeeze Arrow Up
SqueezeSignalUp = MidSqz and GreenCandle and HistogramUp and StackedEMAsUp and SqueezeTrigger
plotshape(SqueezeSignalUp,title='Squeeze Up',style=shape.triangleup,location=location.belowbar,color=(color.aqua),size=size.small)
// Squeeze Arrow Down
SqueezeSignalDn = MidSqz and RedCandle and HistogramDn and StackedEMAsDn and SqueezeTrigger
plotshape(SqueezeSignalDn,title='Squeeze Down',style=shape.triangledown,location=location.abovebar,color=(#cc0000),size=size.small)
// Slingshot Arrow Up
SlingshotSignalUp = MidSqz and momo > 0 and momo[1] > 0 and momo[2] < 0
plotshape(SlingshotSignalUp,title='Slingshot Up',style=shape.triangleup,location=location.belowbar,color=(color.yellow),size=size.small)
// Slingshot Arrow Dn
SlingshotSignalDn = MidSqz and momo < 0 and momo[1] < 0 and momo[2] > 0
plotshape(SlingshotSignalDn,title='Slingshot Down',style=shape.triangledown,location=location.abovebar,color=(color.yellow),size=size.small)
// Fisher Shift Signal Up
ShiftSignalUp = MidSqz[15] and NoSqz and momo < 0 and FisherUp
plotshape(ShiftSignalUp,title='Shift Up',style=shape.triangleup,location=location.belowbar,color=(color.purple),size=size.tiny)
// Fisher Shift Signal Dn
ShiftSignalDn = MidSqz[15] and NoSqz and momo > 0 and FisherDn
plotshape(ShiftSignalDn,title='Shift Down',style=shape.triangledown,location=location.abovebar,color=(color.purple),size=size.tiny)
|
London Reversal Zone | https://www.tradingview.com/script/lSNVtGUc-London-Reversal-Zone/ | NeverWishing | https://www.tradingview.com/u/NeverWishing/ | 124 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © For Shannon xox
//@version=5
indicator(title="London Reversal Zone", shorttitle="LRZ", overlay=true)
// Get user input
timezone = input.session(title="Timezone To Highlight", defval="0416-0448")
alertSessionStart = input.bool(title="Alert When Session Starts?", defval=true)
alertWhenSessionStarts = input.session(title="Alert When Session Starts At", defval="0830-0830")
alertSessionEnd = input.bool(title="Alert When Session Ends?", defval=true)
alertWhenSessionEnds = input.session(title="Alert When Session Ends At", defval="1830-1830")
paintBg = input.bool(title="Paint Background?", defval=true)
blankInsideCandles = input.bool(title="Color Candles Within Zone?", defval=false)
hideOn240AndAbove = input.bool(title="Hide on 4HR And Above?", defval=false)
hideTimeframeCB = input.bool(title="Hide On Other Timeframe?", defval=false)
hideTimeframe = input.string(title="Other Timeframe To Hide", defval="60")
// Determine whether or not this timeframe is to be ignored
hide = hideTimeframeCB and timeframe.period == hideTimeframe or
hideOn240AndAbove and
(timeframe.period == "240" or
timeframe.period == "D" or
timeframe.period == "W" or
timeframe.period == "M")
// InSession() determines if a price bar falls inside the specified session
InSession(sess) => na(time(timeframe.period, sess + ":1234567")) == false
// Color the background of each relevant session and/or bar
bgcolor(color=InSession(timezone) and paintBg and not hide ? color.new(color.red, 75) : na, title="Not In Session")
barcolor(color=InSession(timezone) and blankInsideCandles and not hide ? color.white : na)
// Send out an alert if this candle meets our conditions
alertcondition((InSession(alertWhenSessionStarts) and alertSessionStart) or (InSession(alertWhenSessionEnds) and alertSessionEnd), title="Session Alert!", message="Session signal for {{ticker}}")
plot(close)
|
Liquidity Heatmap LTF [LuxAlgo] | https://www.tradingview.com/script/ZX1z1Z2r-Liquidity-Heatmap-LTF-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 3,316 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("LTF Activity Heatmap [LuxAlgo]"
, overlay = true
, max_boxes_count = 500
, max_lines_count = 500)
//------------------------------------------------------------------------------
//Settings
//------------------------------------------------------------------------------
res = input.timeframe('1','LTF Timeframe')
//--------------
//Style settings
//--------------
heatmap_color0 = input(#0a0032,'Heatmap'
, group = 'Style'
, inline = 'inline0')
heatmap_color1 = input(#880e4f,''
, group = 'Style'
, inline = 'inline0')
heatmap_color2 = input(#ffeb3b,''
, group = 'Style'
, inline = 'inline0')
bull_color = input(#0cb51a,'Lines'
, group = 'Style'
, inline = 'inline1')
bear_color = input(#ff1100,''
, group = 'Style'
, inline = 'inline1')
//------------------------------------------------------------------------------
//Requests ltf open, close, volume series
//------------------------------------------------------------------------------
n = bar_index
c = request.security_lower_tf(syminfo.tickerid, res, close)
o = request.security_lower_tf(syminfo.tickerid, res, open)
v = request.security_lower_tf(syminfo.tickerid, res, volume)
//------------------------------------------------------------------------------
//Display heatmaps
//------------------------------------------------------------------------------
css1 = close > open ? bull_color : bear_color
if array.size(c) != 0
//--------------------------------------------------------------------------
//Highlight candle range
//--------------------------------------------------------------------------
line.new(n
, high
, n
, low
, color = css1)
//--------------------------------------------------------------------------
//Display heatmap
//--------------------------------------------------------------------------
for i = 0 to array.size(c)-1
get_v = array.get(v,i)
get_o = array.get(o,i)
get_c = array.get(c,i)
css0 = color.from_gradient(
get_v
, array.min(v)
, array.max(v)
, heatmap_color0
, heatmap_color1)
box.new(
n
, get_o
, n+1
, get_c
, bgcolor = get_v == array.max(v) ? heatmap_color2 : css0
, border_color = na)
//----------------------------------------------------------------------
//Highest body with highest volume
//----------------------------------------------------------------------
if get_v == array.max(v)
line.new(
n
, get_c
, n+1
, get_c
, color = css1)
line.new(
n
, get_o
, n+1
, get_o
, color = css1) |
Heikin Ashi Oscillator | https://www.tradingview.com/script/Hf0SZc4m-Heikin-Ashi-Oscillator/ | TraderHalai | https://www.tradingview.com/u/TraderHalai/ | 122 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TraderHalai
//@version=5
indicator("Smoothed Heikin Ashi Oscillator - TraderHalai", " SHA Oscillator - TraderHalai", overlay=false)
//Inputs
i_useSmooth = input ( true, "Use smoothing Heikin Ashi")
i_smoothingMethod = input.string("SMA", "Method", options=["SMA", "EMA", "HMA", "VWMA", "RMA"])
i_smoothingPeriod = input ( 10, "Smoothing period")
i_infoBox = input ( true, "Show Info Box" )
i_decimalP = input ( 2, "Prices Decimal Places")
i_boxOffSet = input ( 5, "Info Box Offset" )
i_repaint = input (true, "Repaint - Keep on for live / Off for backtest")
i_col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")
i_col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
i_col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
i_col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
timeperiod = timeframe.period
//Security functions to avoid repaint, as per PineCoders
f_secureSecurity(_symbol, _res, _src) => request.security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
f_security(_symbol, _res, _src, _repaint) => request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
f_secSecurity2(_symbol, _res, _src) => request.security(_symbol, _res, _src[1])
candleClose = f_security(syminfo.tickerid, timeperiod, close, i_repaint)
candleOpen = f_security(syminfo.tickerid, timeperiod, open, i_repaint)
candleLow = f_security(syminfo.tickerid, timeperiod, low, i_repaint)
candleHigh = f_security(syminfo.tickerid, timeperiod, high, i_repaint)
haTicker = ticker.heikinashi(syminfo.tickerid)
haClose = f_security(haTicker, timeperiod, close, i_repaint)
haOpen = f_security(haTicker, timeperiod, open, i_repaint)
haLow = f_security(haTicker, timeperiod, low, i_repaint)
haHigh= f_security(haTicker, timeperiod, high, i_repaint)
reverseClose = (2 * (haOpen[1] + haClose[1])) - candleHigh - candleLow - candleOpen
if(reverseClose < candleLow)
reverseClose := (candleLow + reverseClose) / 2
if(reverseClose > candleHigh)
reverseClose := (candleHigh + reverseClose) / 2
//Smoothing
smaSmoothed = ta.sma(reverseClose, i_smoothingPeriod)
emaSmoothed = ta.ema(reverseClose, i_smoothingPeriod)
hmaSmoothed = ta.hma(reverseClose, i_smoothingPeriod)
vwmaSmoothed = ta.vwma(reverseClose, i_smoothingPeriod)
rmaSmoothed = ta.rma(reverseClose, i_smoothingPeriod)
shouldApplySmoothing = i_useSmooth and i_smoothingPeriod > 1
smoothedReverseClose = reverseClose
if(shouldApplySmoothing)
if(i_smoothingMethod == "SMA")
smoothedReverseClose := smaSmoothed
else if(i_smoothingMethod == "EMA")
smoothedReverseClose := emaSmoothed
else if(i_smoothingMethod == "HMA")
smoothedReverseClose := hmaSmoothed
else if(i_smoothingMethod == "VWMA")
smoothedReverseClose := vwmaSmoothed
else if(i_smoothingMethod == "RMA")
smoothedReverseClose := rmaSmoothed
else
smoothedReverseClose := reverseClose // Default to non-smoothed for invalid smoothing type
haBull = candleClose >= smoothedReverseClose
delta = candleClose - smoothedReverseClose
haPivotPrice = smoothedReverseClose + delta[1]
haDirectionText = haBull ? 'BULLISH Above: ' + '\t\t\t\t\t\t\t\t' : 'BEARISH Below: ' + '\t\t\t\t\t\t\t\t'
haPivotText = (haBull and delta > delta[1]) ? 'EXPANDING above: ' + '\t\t\t\t': (not(haBull) and delta < delta[1]) ? 'EXPANDING below: ' + '\t\t\t\t' : (haBull and delta <= delta[1]) ? 'CONTRACTING below: ' : (not(haBull and delta >= delta[1])) ? 'CONTRACTING above: ' : 'Currently equals'
haCol = haBull and delta > delta[1] ? i_col_grow_above : haBull and delta < delta[1] ? i_col_fall_above : not(haBull) and delta < delta[1] ? i_col_fall_below : not(haBull) and delta > delta[1] ? i_col_grow_below : color.gray
f_truncdNum ( Val, DecPl ) =>
Fact = math.pow (10, DecPl)
int( Val * Fact) / Fact
// Compute Info Label
var label Infobox = na
labelXLoc = time_close + ( i_boxOffSet * ( time_close - time_close[1] ) )
infoBoxText = haDirectionText + str.tostring(f_truncdNum(smoothedReverseClose, i_decimalP)) + '\n' + haPivotText + + str.tostring(f_truncdNum(haPivotPrice, i_decimalP))
///////////////////////////////////////////////////////////////////////////////
// InfoBox Plot
if i_infoBox
Infobox := label.new ( labelXLoc, 0, infoBoxText, xloc.bar_time, yloc.price, color.new(#00000f, 50), label.style_label_left, color.white )
label.delete ( Infobox[1] )
plot(delta, color=haCol, style=plot.style_columns)
hline(0)
|
Fibo-Auto | https://www.tradingview.com/script/kxQCgbPa/ | MrMagic09 | https://www.tradingview.com/u/MrMagic09/ | 72 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MrMagic09
//@version=5
indicator("Auto-Fibo",shorttitle="Fibo+",overlay=true)
src1=input.source(high,"SourceHigh",tooltip="High is recommended for fibonacci retracement")
src2=input.source(low,"SourceLow",tooltip="Low is recommended for fibonacci retracement")
bars=input.int(1000,"Bars",minval=2)//check bar number
res=ta.highest(src1,bars)
lineLength=input.int(title="Line Length",defval=20,minval=10,step=5)
sup=ta.lowest(src2,bars)
lowestbar=ta.lowestbars(src2,bars)
highestbar=ta.lowestbars(src1,bars)
lowbar=math.abs(ta.lowestbars(src1,bars))
highbar=math.abs(ta.highestbars(src2,bars))
//Finding pivot points
plot(sup,title="Bottom",linewidth=2,trackprice=true,show_last=1,display=display.none,color=color.red)
plot(res,trackprice=true,linewidth=2,title="Top",show_last=1,display=display.none,color=color.red)
control = lowbar > highbar ? true : false //checking which is left (lowest or highest)
//fibo levels
fibo2681= control == false ? sup+(res-sup)*2681/1000 : res-(res-sup)*2681/1000
fibo1681= control == false ? sup+(res-sup)*1681/1000 : res-(res-sup)*1681/1000
fibo786 = control == false ? sup+(res-sup)*786/1000 : res-(res-sup)*786/1000
fibo618 = control == false ? sup+(res-sup)*618/1000 : res-(res-sup)*618/1000
fibo500 = control == false ? sup+(res-sup)*500/1000 : res-(res-sup)*500/1000
fibo382 = control == false ? sup+(res-sup)*382/1000 : res-(res-sup)*382/1000
fibo236 = control == false ? sup+(res-sup)*236/1000 : res-(res-sup)*236/1000
//plotting
plot(fibo2681,color=color.lime,linewidth=2,title="2.681",display=display.none,trackprice=true,show_last=1)
plot(fibo1681,color=color.purple,linewidth=2,title="1.681",display=display.none,trackprice=true,show_last=1)
plot(fibo786,color=color.red,linewidth=2,title="0.786",trackprice=true,show_last=1)
plot(fibo618,color=color.blue,linewidth=2,title="0.618",trackprice=true,show_last=1)
plot(fibo500,color=color.green,linewidth=2,title="0.500",trackprice=true,show_last=1)
plot(fibo382,color=color.lime,linewidth=2,title="0.382",trackprice=true,show_last=1)
plot(fibo236,color=color.purple,linewidth=2,title="0.236",trackprice=true,show_last=1)
FindingBarIndex(bars1)=>
int barindex=1
a=ta.highest(high,bars)
for i=1 to bars1
if high[i]!=a
barindex+=1
if high[i]==a
break
barindex
//plotting pivot points
plot(ta.highest(high,bars),title="Top",offset=-FindingBarIndex(bars)+lineLength,show_last=lineLength,linewidth=3,color=color.red)
FindingBarIndex2(bars2)=>
int barindex1=1
b=ta.lowest(low,bars)
for c=1 to bars2
if low[c]!=b
barindex1+=1
if low[c]==b
break
barindex1
plot(ta.lowest(low,bars),title="Bottom",offset=-FindingBarIndex2(bars)+lineLength,show_last=lineLength,linewidth=3,color=color.blue) |
Harmonic Pattern Possibility Table | https://www.tradingview.com/script/zVmggoSW-Harmonic-Pattern-Possibility-Table/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 126 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
//@version=5
indicator('Harmonic Pattern Possibility Table', shorttitle = 'HPPT')
// 0. Inputs
// 1. Variables
// 2. Switches
// 3. Arrays
// 4. Custom functions
// 5. Construct
// ————————————————————————————————————————————————————————————————————————————— 0. Inputs {
T0 = 'Small font size recommended for mobile app or multiple layout'
value = input.float( 0.371, 'Value', minval = 0.371, maxval = 0.913, step = 0.001, tooltip = '0.371 <= Value <= 0.913')
i_s_ABC = input.string('All', 'ALT BAT / BAT / CRAB', options = ['All', 'ALT BAT', 'BAT', 'CRAB'], tooltip = 'Value = 0.382') // 'ALT BAT, BAT, CRAB'
i_s_BC = input.string('All', 'BAT / CRAB', options = ['All', 'BAT', 'CRAB'], tooltip = '0.383 <= Value <= 0.500') // 'ALT BAT, BAT, CRAB'
i_s_CG = input.string('All', 'CRAB / GARTLEY', options = ['All', 'CRAB', 'GARTLEY'], tooltip = '0.599 <= Value <= 0.618') // 'CRAB', 'GARTLEY'
i_s_font = input.string('normal', 'Font size', options = ['tiny', 'small', 'normal', 'large', 'huge'], tooltip = T0)
i_s_Y = input.string('middle', 'Table Position', options = ['top', 'middle', 'bottom'], inline = '0')
i_s_X = input.string('center', '', options = ['left', 'center', 'right'], inline = '0')
// }
// ————————————————————————————————————————————————————————————————————————————— 1. Variables {
var string animal = na
var animalTable = table.new(i_s_Y + '_' + i_s_X, 12, 14, border_width = 1)
cn = color.new(color.blue, 100)
cw = color.white
cy = color.yellow
str_ABC = 'ALT BAT, BAT, CRAB'
str_BC = 'BAT, CRAB'
str_CG = 'CRAB, GARTLEY'
p0 = math.rphi
p1 = math.phi
p2 = math.rphi + 2
p3 = math.rphi + 3
// }
// ————————————————————————————————————————————————————————————————————————————— 2. Switches {
[d_min_ABC, d_max_ABC, d_nom_ABC, s_nom_ABC] = switch i_s_ABC
// [d_min_ABC, d_max_ABC, d_nom_ABC, s_nom_ABC]
'All' => [ 2, p3, 1.13 , 1.27]
'ALT BAT' => [ 2, p3, 1.13 , 1.27]
'BAT' => [ p1, p2, .886, 1.13]
'CRAB' => [ p2, p3, p1, 2. ]
[d_min_BC, d_max_BC, d_nom_BC, s_nom_BC] = switch i_s_BC
// [d_min_BC, d_max_BC, d_nom_BC, s_nom_BC]
'All' => [ p1, p2, p2, p2]
'BAT' => [ p1, p2, .886, 1.13 ]
'CRAB' => [ p2, p3, p1, 2. ]
[d_min_CG, d_max_CG, d_nom_CG, s_nom_CG] = switch i_s_CG
// [d_min_CG, d_max_CG, d_nom_CG, s_nom_CG]
'All' => [ p2, p3, p1, 2. ]
'CRAB' => [ p2, p3, p1, 2. ]
'GARTLEY' => [ p1, p1, .786, 1. ]
// }
// ————————————————————————————————————————————————————————————————————————————— 3. Arrays {
// 0 1 2 3 4 5 6 7
possible_animal = array.from('ALT BAT', str_ABC, str_BC, 'CRAB', str_CG, 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
selected_animal = array.from('ALT BAT', i_s_ABC, i_s_BC, 'CRAB', i_s_CG, 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
priority_animal = array.from('ALT BAT', 'ALT BAT', 'BAT', 'CRAB', 'CRAB', 'GARTLEY', 'BUTTERFLY', 'DEEP CRAB')
b_min = array.from( .371, .382, .383, .501, .599, .619, .762, .886)
b_max = array.from( .381, .382, .5 , .598, p0, .637, .81 , .93 )
c_min = array.from( .382, .382, .382, .382, .382, .382, .382, .382)
c_max = array.from( .886, .886, .886, .886, .886, .886, .886, .886)
d_min = array.from( 2. , d_min_ABC, d_min_BC, p2, d_min_CG, 1.13 , p1, p2)
d_max = array.from( p3, d_max_ABC, d_max_BC, p3, d_max_CG, 1.618, 2.24 , p3)
d_nom = array.from( 1.13 , d_nom_ABC, d_nom_BC, p1, d_nom_CG, .786, 1.27 , p1)
s_nom = array.from( 1.27 , s_nom_ABC, s_nom_BC, 2. , s_nom_CG, 1. , 1.414, 2. )
min_max = array.from('Min', 'Max')
pattern = array.from('Possible', 'Priority', 'Selected')
arr_bool = array.new_bool(8)
for _index = 0 to 7
array.set(arr_bool, _index, value >= array.get(b_min, _index) and value <= array.get(b_max, _index))
// }
// ————————————————————————————————————————————————————————————————————————————— 4. Custom functions {
color_get(_id, int _index) => array.get(_id, _index) <= 1 ? color.red : color.blue
str_get(_id, int _index, int _int = 0) =>
expr = switch _int
1 => '>= '
2 => '<= '
txt = str.tostring( array.get(_id, _index), expr + '0.000')
txt
// }
// ————————————————————————————————————————————————————————————————————————————— 5. Construct {
if array.includes(arr_bool, true)
animal := array.get(possible_animal, array.indexof(arr_bool, array.includes(arr_bool, true)))
if barstate.islast
// title from input
table.cell(animalTable, 0, 0, 'Harmonic Pattern Possibility Table', bgcolor = cw, text_size = i_s_font), table.merge_cells(animalTable, 0, 0, 11, 0)
table.cell(animalTable, 0, 1, 'Input (B = XA)', bgcolor = cw, text_size = i_s_font), table.merge_cells(animalTable, 0, 1, 5, 1)
table.cell(animalTable, 6, 1, 'Output (D = XA)', bgcolor = cw, text_size = i_s_font), table.merge_cells(animalTable, 6, 1, 11, 1)
table.cell(animalTable, 0, 2, str.tostring(value, '0.000'), bgcolor = cy, text_size = i_s_font), table.merge_cells(animalTable, 0, 2, 5, 2)
table.cell(animalTable, 6, 2, animal, bgcolor = cy, text_size = i_s_font), table.merge_cells(animalTable, 6, 2, 11, 2)
// blank row
table.cell(animalTable, 0, 3, ' ', bgcolor = cn, text_size = i_s_font, text_color = cn), table.merge_cells(animalTable, 0, 3, 11, 3)
// sub title no 1
table.cell(animalTable, 0, 4, 'B = XA', bgcolor = cw, text_size = i_s_font), table.merge_cells(animalTable, 0, 4, 5, 4)
table.cell(animalTable, 6, 4, 'C = AB', bgcolor = cw, text_size = i_s_font), table.merge_cells(animalTable, 6, 4, 7, 4)
table.cell(animalTable, 8, 4, 'D = BC', bgcolor = cw, text_size = i_s_font), table.merge_cells(animalTable, 8, 4, 9, 4)
table.cell(animalTable, 10, 4, 'D = XA', bgcolor = cw, text_size = i_s_font)
table.cell(animalTable, 11, 4, 'Stop Loss', bgcolor = cw, text_size = i_s_font)
// sub title no 2
table.cell(animalTable, 0, 5, 'No', bgcolor = cw)
for _column = 0 to 2
table.cell(animalTable, _column + 3, 5, array.get(pattern, _column) + '\nPattern', bgcolor = cw, text_size = i_s_font)
// sub title no 2 (Min, Max)
for _column = 0 to 1
table.cell(animalTable, _column + 1, 5, array.get(min_max, _column), bgcolor = cw, text_size = i_s_font)
table.cell(animalTable, _column + 6, 5, array.get(min_max, _column), bgcolor = cw, text_size = i_s_font)
table.cell(animalTable, _column + 8, 5, array.get(min_max, _column), bgcolor = cw, text_size = i_s_font)
table.cell(animalTable, _column + 10, 5, 'Nom', bgcolor = cw, text_size = i_s_font)
// values for each animal pattern
for _row = 0 to 7
table.cell(animalTable, 0, _row + 6, str.tostring(_row), text_size = i_s_font, bgcolor = cw)
table.cell(animalTable, 1, _row + 6, str_get( b_min, _row, 1), text_size = i_s_font, bgcolor = color_get(b_min, _row))
table.cell(animalTable, 2, _row + 6, str_get( b_max, _row, 2), text_size = i_s_font, bgcolor = color_get(b_max, _row))
table.cell(animalTable, 3, _row + 6, array.get(possible_animal, _row), text_size = i_s_font, bgcolor = cw)
table.cell(animalTable, 4, _row + 6, array.get(priority_animal, _row), text_size = i_s_font, bgcolor = cw)
table.cell(animalTable, 5, _row + 6, array.get(selected_animal, _row), text_size = i_s_font, bgcolor = cw)
table.cell(animalTable, 6, _row + 6, str_get( c_min, _row, 1), text_size = i_s_font, bgcolor = color_get(c_min, _row))
table.cell(animalTable, 7, _row + 6, str_get( c_max, _row, 2), text_size = i_s_font, bgcolor = color_get(c_max, _row))
table.cell(animalTable, 8, _row + 6, str_get( d_min, _row, 1), text_size = i_s_font, bgcolor = color_get(d_min, _row))
table.cell(animalTable, 9, _row + 6, str_get( d_max, _row, 2), text_size = i_s_font, bgcolor = color_get(d_max, _row))
table.cell(animalTable, 10, _row + 6, str_get( d_nom, _row), text_size = i_s_font, bgcolor = color_get(d_nom, _row))
table.cell(animalTable, 11, _row + 6, str_get( s_nom, _row), text_size = i_s_font, bgcolor = color_get(s_nom, _row))
// if animal is true
if array.includes(possible_animal, animal)
for _column = 0 to 11
table.cell_set_bgcolor(animalTable, _column, array.indexof(arr_bool, array.includes(arr_bool, true)) + 6, cy)
// } |
Volatility Trigger Index | https://www.tradingview.com/script/YLeS9WVf/ | ExpensiveJok | https://www.tradingview.com/u/ExpensiveJok/ | 27 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ExpensiveJok
// This indicator calculates the standard deviation of the rate of change. The purpose of the scrip is only educational.
//@version=5
indicator("Volatility Trigger Index", shorttitle = "Vol.Trig.Index", overlay = false)
//-------------------------- TIPS -----------------------------
length_tip = "Number of candles to lookback."
zone_b_tip = "Value of the index in which we look for lower values to enter the market."
zone_s_tip = "Value of the index in which we look for higher values to exit the market."
bg_zone_tip= "It allows the script to colour the background."
//-------------------------- INPUTS --------------------------
length = input.int(title = "Length", defval = 20, minval = 1, tooltip = length_tip, group = "INDEX")
//Zone_b = Zone of buys. Zone_s = Zone of sells.
zone_b = input.float(title = "Low lvl", defval = 0.4, tooltip = zone_b_tip, group = "INDEX")
zone_s = input.float(title = "High lvl", defval = 0.6, tooltip = zone_s_tip, group = "INDEX")
//------ VISUAL
bg_zone = input.bool(title = "Background", defval = true, tooltip = bg_zone_tip, group = "VISUAL")
//----------------------- PROCESS ---------------------------
roc = ta.roc(close, length)
vol = ta.stdev(roc, length)
zone_col = vol <= zone_b ? #14ff00 : vol >= zone_s ? #ff9800 : #3c78d8
breakoutFillColor = vol >= zone_s ? color.new(#ff9800, 90) : vol <= zone_b ? color.new(#14ff00, 90) : color.new(color.white, 100)
//----------------------------- PLOTS ---------------------------------------------
bgcolor(bg_zone ? breakoutFillColor : color.new(color.white, 100))
plot(vol, title="VR", color= zone_col) |
Input Source | https://www.tradingview.com/script/wb5e69eL-Input-Source/ | PineCoders | https://www.tradingview.com/u/PineCoders/ | 119 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCoders
//@version=5
indicator("Input Source", "", true)
// Input source
// v1, 2022.05.28 14:43
// This code was written using the recommendations from the Pine Script™ User Manual's Style Guide:
// https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html
sourceStrToFloat(series string srcString) =>
float result = switch srcString
"open" => open
"high" => high
"low" => low
"close" => close
"hl2" => hl2
"hlc3" => hlc3
"ohlc4" => ohlc4
"hlcc4" => hlcc4
// Real `input.source()` call allowing an external input.
float src1Input = input.source(close, "Input allowing an external input")
// Two more input sources not allowing an external input.
float src2Input = sourceStrToFloat(input.string("high", "Source 2", options = ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4", "hlcc4"]))
float src3Input = sourceStrToFloat(input.string("low", "Source 3", options = ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4", "hlcc4"]))
plot(src1Input, "src1Input")
plot(src2Input, "src2Input", color.orange)
plot(src3Input, "src3Input", color.green)
|
Worth of value | https://www.tradingview.com/script/mgwGhvKv-Worth-of-value/ | Mathdox | https://www.tradingview.com/u/Mathdox/ | 8 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mathdepoorter
//@version=5
indicator(shorttitle="Value", title="Worth of value")
float Amount = input.float(title="Quantity", defval=0.0)
float Paid = input.float(title="Paid", defval=0.0)
float Percent = input.float(title="Percent (inc. btw)", defval=0.0)
Kost = Amount - 1*(Amount * Percent / 100)
float c = close * Kost //50
plotColor = if c > Paid
color.green
else
color.red
var label LL = label.new(na, na, "€")
label.set_xy(LL, bar_index, c)
label.set_text(LL, "€" + str.tostring(c, format.mintick))
label.set_textcolor(LL, textcolor=color.white)
plot(c, color=plotColor)
var line2 = line.new(time, open, time + 60 * 60 * 24, close, xloc=xloc.bar_time, style=line.style_dashed)
line.set_width(line2, 5)
|
Accelerating Dual Momentum Score | https://www.tradingview.com/script/LyF7R2tF/ | noooob | https://www.tradingview.com/u/noooob/ | 85 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © noooob
//@version=4
study(title="Accelerating Dual Momentum Score", shorttitle="ADMS")
month1 = input(21,title="1M")
month3 = input(63,title="3M")
month6 = input(126,title="6M")
getRateOfReturn(price, length) =>
return = (price/price[length]-1)*100
m1 = getRateOfReturn(close, month1)
m3 = getRateOfReturn(close, month3)
m6 = getRateOfReturn(close, month6)
w = (m1+m3+m6)/3
wColor = w>0?color.new(#00ddff,0):color.new(#ff3333,0)
plot(w, title="W",style=plot.style_columns,color=wColor) |
Abdul Rehman Trading Strategy | https://www.tradingview.com/script/AxUea2Bg-Abdul-Rehman-Trading-Strategy/ | alrehmanansari | https://www.tradingview.com/u/alrehmanansari/ | 531 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © alrehmanansari
//@version=5
indicator("Abdul Rehman Trading Strategy", overlay=true)
TD = 0
TS = 0
TD := close > close[4] ? nz(TD[1])+1 : 0
TS := close < close[4] ? nz(TS[1])+1 : 0
TDUp = TD - ta.valuewhen(TD < TD[1], TD, 1 )
TDDn = TS - ta.valuewhen(TS < TS[1], TS, 1 )
plotshape(TDUp==7?true:na,style=shape.triangledown,color=color.red, text="7", textcolor=color.red, location=location.abovebar)
plotshape(TDUp==8?true:na,style=shape.triangledown,color=color.red, text="8", textcolor=color.red, location=location.abovebar)
plotshape(TDUp==9?true:na,style=shape.labeldown,color=color.red, text="SHORT", textcolor=color.white, location=location.abovebar)
plotshape(TDDn==7?true:na,style=shape.triangleup, color=color.green, text="7", textcolor=color.green, location=location.belowbar)
plotshape(TDDn==8?true:na,style=shape.triangleup, color=color.green, text="8", textcolor=color.green, location=location.belowbar)
plotshape(TDDn==9?true:na,style=shape.labelup, color=color.green, text="LONG", textcolor=color.white, location=location.belowbar) |
Index Reversal Range with Volatility Index or VIX | https://www.tradingview.com/script/u1xPMxT5-Index-Reversal-Range-with-Volatility-Index-or-VIX/ | Arun_K_Bhaskar | https://www.tradingview.com/u/Arun_K_Bhaskar/ | 536 | study | 5 | MPL-2.0 | // This crs code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Arun_K_Bhaskar
//@version=5
indicator(title="Index Reversal Range with Volatility Index or VIX", shorttitle="Index VIX Range", format=format.price, precision=2, overlay=true)//, timeframe="", timeframe_gaps=true)
ttVIX = "Type the Symbol of Volatility Index or VIX which measures volatility of the market. Eg: 'NSE:INDIAVIX' for 'NSE:NIFTY' Index"
input_vix = input.symbol(defval="NSE:INDIAVIX", title="Input VIX", confirm=true, tooltip=ttVIX)
gpTF = "Timeframe"
show_1m = input.bool(false, title="1 min ", group=gpTF, inline="1")
show_5m = input.bool(true, title="5 min ", group=gpTF, inline="1")
show_30m = input.bool(true, title="30 min ", group=gpTF, inline="1")
show_1h = input.bool(false, title="Hourly ", group=gpTF, inline="2")
show_D = input.bool(true, title="Daily ", group=gpTF, inline="2")
show_W = input.bool(false, title="Weekly ", group=gpTF, inline="2")
show_M = input.bool(false, title="Monthly ", group=gpTF, inline="3")
show_3M = input.bool(false, title="Quarterly", group=gpTF, inline="3")
show_6M = input.bool(false, title="Halfyearly", group=gpTF, inline="3")
show_1Y = input.bool(false, title="Yearly", group=gpTF, inline="4")
show_label = input.bool(true, title="Label")
color_1m = #00bcf2
color_5m = #ff8c00
color_30m = #00b294
color_1h = #e81123
color_D = #009e49
color_W = #ec008c
color_M = #bad80a
color_3M = #68217a
color_6M = #00188f
color_1Y = #fff100
//////////////////////////////////////////////////////////////////// 1 Minute Index Range
vix_ltp_1min = request.security(input_vix, "1", close, barmerge.gaps_on, barmerge.lookahead_on)
min_1_val = (vix_ltp_1min / math.sqrt(252 * 375)) / 100
min_1_upper = close + (close * min_1_val)
min_1_lower = close - (close * min_1_val)
plot(show_1m ? min_1_upper : na, title="1 Minute Upper", color=color.new(color_1m, 0))
plot(show_1m ? min_1_lower : na, title="1 Minute Lower", color=color.new(color_1m, 0))
//////////////////////////////////////////////////////////////////// 5 Minute Index Range
vix_ltp_5min = request.security(input_vix, "5", close, barmerge.gaps_on, barmerge.lookahead_on)
min_5_val = (vix_ltp_5min / math.sqrt(252 * 375 / 5)) / 100
min_5_upper = close + (close * min_5_val)
min_5_lower = close - (close * min_5_val)
plot(show_5m ? min_5_upper : na, title="5 Minute Upper", color=color.new(color_5m, 0))
plot(show_5m ? min_5_lower : na, title="5 Minute Lower", color=color.new(color_5m, 0))
//////////////////////////////////////////////////////////////////// 30 Minute Index Range
vix_ltp_30min = request.security(input_vix, "30", close, barmerge.gaps_on, barmerge.lookahead_on)
min_30_val = (vix_ltp_30min / math.sqrt(252 * 375 / 30)) / 100
min_30_upper = close + (close * min_30_val)
min_30_lower = close - (close * min_30_val)
plot(show_30m ? min_30_upper : na, title="30 Minute Upper", color=color.new(color_30m, 0))
plot(show_30m ? min_30_lower : na, title="30 Minute Lower", color=color.new(color_30m, 0))
//////////////////////////////////////////////////////////////////// Hourly Index Range
vix_ltp_1h = request.security(input_vix, "60", close, barmerge.gaps_on, barmerge.lookahead_on)
hourly_val = (vix_ltp_1h / math.sqrt(252 * 375 / 60)) / 100
hour_upper = close + (close * hourly_val)
hour_lower = close - (close * hourly_val)
plot(show_1h ? hour_upper : na, title="Hourly Upper", color=color.new(color_1h, 0))
plot(show_1h ? hour_lower : na, title="Hourly Lower", color=color.new(color_1h, 0))
//////////////////////////////////////////////////////////////////// Daily Index Range
vix_ltp_D = request.security(input_vix, "D", close, barmerge.gaps_on, barmerge.lookahead_on)
daily_val = (vix_ltp_D / math.sqrt(252)) / 100
day_upper = close + (close * daily_val)
day_lower = close - (close * daily_val)
plot(show_D ? day_upper : na, title="Daily Upper", color=color.new(color_D, 0))
plot(show_D ? day_lower : na, title="Daily Lower", color=color.new(color_D, 0))
//////////////////////////////////////////////////////////////////// Weekly Index Range
vix_ltp_W = request.security(input_vix, "W", close, barmerge.gaps_on, barmerge.lookahead_on)
weekly_val = (vix_ltp_W / math.sqrt(52)) / 100
week_upper = close + (close * weekly_val)
week_lower = close - (close * weekly_val)
plot(show_W ? week_upper : na, title="Weekly Upper", color=color.new(color_W, 0))
plot(show_W ? week_lower : na, title="Weekly Lower", color=color.new(color_W, 0))
//////////////////////////////////////////////////////////////////// Monthly Index Range
vix_ltp_M = request.security(input_vix, "M", close, barmerge.gaps_on, barmerge.lookahead_on)
monthly_val = (vix_ltp_M / math.sqrt(12)) / 100
month_upper = close + (close * monthly_val)
month_lower = close - (close * monthly_val)
plot(show_M ? month_upper : na, title="Monthly Upper", color=color.new(color_M, 0))
plot(show_M ? month_lower : na, title="Monthly Lower", color=color.new(color_M, 0))
//////////////////////////////////////////////////////////////////// Quarterly Index Range
vix_ltp_3M = request.security(input_vix, "3M", close, barmerge.gaps_on, barmerge.lookahead_on)
quarterly_val = (vix_ltp_3M / math.sqrt(4)) / 100
quarter_upper = close + (close * quarterly_val)
quarter_lower = close - (close * quarterly_val)
plot(show_3M ? quarter_upper : na, title="Quarterly Upper", color=color.new(color_3M, 0))
plot(show_3M ? quarter_lower : na, title="Quarterly Lower", color=color.new(color_3M, 0))
//////////////////////////////////////////////////////////////////// Halfyearly Index Range
vix_ltp_6M = request.security(input_vix, "6M", close, barmerge.gaps_on, barmerge.lookahead_on)
halfyearly_val = (vix_ltp_6M / math.sqrt(2)) / 100
halfyear_upper = close + (close * halfyearly_val)
halfyear_lower = close - (close * halfyearly_val)
plot(show_6M ? halfyear_upper : na, title="Halfyearly Upper", color=color.new(color_6M, 0))
plot(show_6M ? halfyear_lower : na, title="Halfyearly Lower", color=color.new(color_6M, 0))
//////////////////////////////////////////////////////////////////// Yearly Index Range
vix_ltp_Y = request.security(input_vix, "12M", close, barmerge.gaps_on, barmerge.lookahead_on)
year_upper = close + ((close / 100) * vix_ltp_Y)
year_lower = close - ((close / 100) * vix_ltp_Y)
plot(show_1Y ? year_upper : na, title="Yearly Upper", color=color.new(color_1Y, 0))//, style=plot.style_circles, linewidth=2, join=true)
plot(show_1Y ? year_lower : na, title="Yearly Lower", color=color.new(color_1Y, 0))
//////////////////////////////////////////////////////////////////// Live Levels and Labels
year_volt_ln = request.security(input_vix, "D", close)
year_volt_prev_ln = request.security(input_vix, "D", close[1])
min_1_volt_ln = year_volt_ln / math.sqrt(252 * 375)
min_5_volt_ln = year_volt_ln / math.sqrt(252 * 375 / 5)
min_30_volt_ln = year_volt_ln / math.sqrt(252 * 375 / 30)
hour_volt_ln = year_volt_ln / math.sqrt(252 * 375 / 60)
day_volt_ln = year_volt_ln / math.sqrt(252)
week_volt_ln = year_volt_ln / math.sqrt(52)
month_volt_ln = year_volt_ln / math.sqrt(12)
quarter_volt_ln = year_volt_ln / math.sqrt(4)
halfyear_volt_ln = year_volt_ln / math.sqrt(2)
min_1_upper_ln = close * (1 + min_1_volt_ln / 100)
min_1_lower_ln = close * (1 - min_1_volt_ln / 100)
min_5_upper_ln = close * (1 + min_5_volt_ln / 100)
min_5_lower_ln = close * (1 - min_5_volt_ln / 100)
min_30_upper_ln = close * (1 + min_30_volt_ln / 100)
min_30_lower_ln = close * (1 - min_30_volt_ln / 100)
hour_upper_ln = close * (1 + hour_volt_ln / 100)
hour_lower_ln = close * (1 - hour_volt_ln / 100)
day_upper_ln = close * (1 + day_volt_ln / 100)
day_lower_ln = close * (1 - day_volt_ln / 100)
week_upper_ln = close * (1 + week_volt_ln / 100)
week_lower_ln = close * (1 - week_volt_ln / 100)
month_upper_ln = close * (1 + month_volt_ln / 100)
month_lower_ln = close * (1 - month_volt_ln / 100)
year_upper_ln = close * (1 + year_volt_ln / 100)
year_lower_ln = close * (1 - year_volt_ln / 100)
quarter_upper_ln = close * (1 + quarter_volt_ln / 100)
quarter_lower_ln = close * (1 - quarter_volt_ln / 100)
halfyear_upper_ln = close * (1 + halfyear_volt_ln / 100)
halfyear_lower_ln = close * (1 - halfyear_volt_ln / 100)
// Label
chper = time - time[1]
chper := ta.change(chper) > 0 ? chper[1] : chper
if show_1m
var line min_1_upper_ln_line = na
min_1_upper_ln_line := line.new(bar_index[1], min_1_upper_ln, bar_index, min_1_upper_ln, color=color.new(color_1m, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(min_1_upper_ln_line[1])
var line min_1_lower_ln_line = na
min_1_lower_ln_line := line.new(bar_index[1], min_1_lower_ln, bar_index, min_1_lower_ln, color=color.new(color_1m, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(min_1_lower_ln_line[1])
if show_label
var label min_1_upper_ln_label = na
label.delete(min_1_upper_ln_label)
min_1_upper_ln_label := label.new(x = time + chper * 0, y = min_1_upper_ln, text = str.tostring(min_1_upper_ln, "#.##") + " (1m⌃) " + str.tostring(min_1_volt_ln, "#.##") + "%\n", textcolor=color_1m, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label min_1_lower_ln_label = na
label.delete(min_1_lower_ln_label)
min_1_lower_ln_label := label.new(x = time + chper * 0, y = min_1_lower_ln, text = str.tostring(min_1_lower_ln, "#.##") + " (1m⌄) " + str.tostring(min_1_volt_ln, "#.##") + "%\n", textcolor=color_1m, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_5m
var line min_5_upper_ln_line = na
min_5_upper_ln_line := line.new(bar_index[1], min_5_upper_ln, bar_index, min_5_upper_ln, color=color.new(color_5m, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(min_5_upper_ln_line[1])
var line min_5_lower_ln_line = na
min_5_lower_ln_line := line.new(bar_index[1], min_5_lower_ln, bar_index, min_5_lower_ln, color=color.new(color_5m, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(min_5_lower_ln_line[1])
if show_label
var label min_5_upper_ln_label = na
label.delete(min_5_upper_ln_label)
min_5_upper_ln_label := label.new(x = time + chper * 0, y = min_5_upper_ln, text = str.tostring(min_5_upper_ln, "#.##") + " (5m⌃) " + str.tostring(min_5_volt_ln, "#.##") + "%\n", textcolor=color_5m, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label min_5_lower_ln_label = na
label.delete(min_5_lower_ln_label)
min_5_lower_ln_label := label.new(x = time + chper * 0, y = min_5_lower_ln, text = str.tostring(min_5_lower_ln, "#.##") + " (5m⌄) " + str.tostring(min_5_volt_ln, "#.##") + "%\n", textcolor=color_5m, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_30m
var line min_30_upper_ln_line = na
min_30_upper_ln_line := line.new(bar_index[1], min_30_upper_ln, bar_index, min_30_upper_ln, color=color.new(color_30m, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(min_30_upper_ln_line[1])
var line min_30_lower_ln_line = na
min_30_lower_ln_line := line.new(bar_index[1], min_30_lower_ln, bar_index, min_30_lower_ln, color=color.new(color_30m, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(min_30_lower_ln_line[1])
if show_label
var label min_30_upper_ln_label = na
label.delete(min_30_upper_ln_label)
min_30_upper_ln_label := label.new(x = time + chper * 0, y = min_30_upper_ln, text = str.tostring(min_30_upper_ln, "#.##") + " (30m⌃) " + str.tostring(min_30_volt_ln, "#.##") + "%\n", textcolor=color_30m, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label min_30_lower_ln_label = na
label.delete(min_30_lower_ln_label)
min_30_lower_ln_label := label.new(x = time + chper * 0, y = min_30_lower_ln, text = str.tostring(min_30_lower_ln, "#.##") + " (30m⌄) " + str.tostring(min_30_volt_ln, "#.##") + "%\n", textcolor=color_30m, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_1h
var line hour_upper_ln_line = na
hour_upper_ln_line := line.new(bar_index[1], hour_upper_ln, bar_index, hour_upper_ln, color=color.new(color_1h, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(hour_upper_ln_line[1])
var line hour_lower_ln_line = na
hour_lower_ln_line := line.new(bar_index[1], hour_lower_ln, bar_index, hour_lower_ln, color=color.new(color_1h, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(hour_lower_ln_line[1])
if show_label
var label hour_upper_ln_label = na
label.delete(hour_upper_ln_label)
hour_upper_ln_label := label.new(x = time + chper * 0, y = hour_upper_ln, text = str.tostring(hour_upper_ln, "#.##") + " (1h⌃) " + str.tostring(hour_volt_ln, "#.##") + "%\n", textcolor=color_1h, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label hour_lower_ln_label = na
label.delete(hour_lower_ln_label)
hour_lower_ln_label := label.new(x = time + chper * 0, y = hour_lower_ln, text = str.tostring(hour_lower_ln, "#.##") + " (1h⌄) " + str.tostring(hour_volt_ln, "#.##") + "%\n", textcolor=color_1h, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_D
var line day_upper_ln_line = na
day_upper_ln_line := line.new(bar_index[1], day_upper_ln, bar_index, day_upper_ln, color=color.new(color_D, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(day_upper_ln_line[1])
var line day_lower_ln_line = na
day_lower_ln_line := line.new(bar_index[1], day_lower_ln, bar_index, day_lower_ln, color=color.new(color_D, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(day_lower_ln_line[1])
if show_label
var label day_upper_ln_label = na
label.delete(day_upper_ln_label)
day_upper_ln_label := label.new(x = time + chper * 0, y = day_upper_ln, text = str.tostring(day_upper_ln, "#.##") + " (D⌃) " + str.tostring(day_volt_ln, "#.##") + "%\n", textcolor=color_D, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label day_lower_ln_label = na
label.delete(day_lower_ln_label)
day_lower_ln_label := label.new(x = time + chper * 0, y = day_lower_ln, text = str.tostring(day_lower_ln, "#.##") + " (D⌄) " + str.tostring(day_volt_ln, "#.##") + "%\n", textcolor=color_D, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_W
var line week_upper_ln_line = na
week_upper_ln_line := line.new(bar_index[1], week_upper_ln, bar_index, week_upper_ln, color=color.new(color_W, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(week_upper_ln_line[1])
var line week_lower_ln_line = na
week_lower_ln_line := line.new(bar_index[1], week_lower_ln, bar_index, week_lower_ln, color=color.new(color_W, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(week_lower_ln_line[1])
if show_label
var label week_upper_ln_label = na
label.delete(week_upper_ln_label)
week_upper_ln_label := label.new(x = time + chper * 0, y = week_upper_ln, text = str.tostring(week_upper_ln, "#.##") + " (W⌃) " + str.tostring(week_volt_ln, "#.##") + "%\n", textcolor=color_W, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label week_lower_ln_label = na
label.delete(week_lower_ln_label)
week_lower_ln_label := label.new(x = time + chper * 0, y = week_lower_ln, text = str.tostring(week_lower_ln, "#.##") + " (W⌄) " + str.tostring(week_volt_ln, "#.##") + "%\n", textcolor=color_W, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_M
var line month_upper_ln_line = na
month_upper_ln_line := line.new(bar_index[1], month_upper_ln, bar_index, month_upper_ln, color=color.new(color_M, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(month_upper_ln_line[1])
var line month_lower_ln_line = na
month_lower_ln_line := line.new(bar_index[1], month_lower_ln, bar_index, month_lower_ln, color=color.new(color_M, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(month_lower_ln_line[1])
if show_label
var label month_upper_ln_label = na
label.delete(month_upper_ln_label)
month_upper_ln_label := label.new(x = time + chper * 0, y = month_upper_ln, text = str.tostring(month_upper_ln, "#.##") + " (M⌃) " + str.tostring(month_volt_ln, "#.##") + "%\n", textcolor=color_M, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label month_lower_ln_label = na
label.delete(month_lower_ln_label)
month_lower_ln_label := label.new(x = time + chper * 0, y = month_lower_ln, text = str.tostring(month_lower_ln, "#.##") + " (M⌄) " + str.tostring(month_volt_ln, "#.##") + "%\n", textcolor=color_M, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_3M
var line quarter_upper_ln_line = na
quarter_upper_ln_line := line.new(bar_index[1], quarter_upper_ln, bar_index, quarter_upper_ln, color=color.new(color_3M, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(quarter_upper_ln_line[1])
var line quarter_lower_ln_line = na
quarter_lower_ln_line := line.new(bar_index[1], quarter_lower_ln, bar_index, quarter_lower_ln, color=color.new(color_3M, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(quarter_lower_ln_line[1])
if show_label
var label quarter_upper_ln_label = na
label.delete(quarter_upper_ln_label)
quarter_upper_ln_label := label.new(x = time + chper * 0, y = quarter_upper_ln, text = str.tostring(quarter_upper_ln, "#.##") + " (3M⌃) " + str.tostring(quarter_volt_ln, "#.##") + "%\n", textcolor=color_3M, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label quarter_lower_ln_label = na
label.delete(quarter_lower_ln_label)
quarter_lower_ln_label := label.new(x = time + chper * 0, y = quarter_lower_ln, text = str.tostring(quarter_lower_ln, "#.##") + " (3M⌄) " + str.tostring(quarter_volt_ln, "#.##") + "%\n", textcolor=color_3M, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_6M
var line halfyear_upper_ln_line = na
halfyear_upper_ln_line := line.new(bar_index[1], halfyear_upper_ln, bar_index, halfyear_upper_ln, color=color.new(color_6M, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(halfyear_upper_ln_line[1])
var line halfyear_lower_ln_line = na
halfyear_lower_ln_line := line.new(bar_index[1], halfyear_lower_ln, bar_index, halfyear_lower_ln, color=color.new(color_6M, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(halfyear_lower_ln_line[1])
if show_label
var label halfyear_upper_ln_label = na
label.delete(halfyear_upper_ln_label)
halfyear_upper_ln_label := label.new(x = time + chper * 0, y = halfyear_upper_ln, text = str.tostring(halfyear_upper_ln, "#.##") + " (6M⌃) " + str.tostring(halfyear_volt_ln, "#.##") + "%\n", textcolor=color_6M, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label halfyear_lower_ln_label = na
label.delete(halfyear_lower_ln_label)
halfyear_lower_ln_label := label.new(x = time + chper * 0, y = halfyear_lower_ln, text = str.tostring(halfyear_lower_ln, "#.##") + " (6M⌄) " + str.tostring(halfyear_volt_ln, "#.##") + "%\n", textcolor=color_6M, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
if show_1Y
var line year_upper_ln_line = na
year_upper_ln_line := line.new(bar_index[1], year_upper_ln, bar_index, year_upper_ln, color=color.new(color_1Y, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(year_upper_ln_line[1])
var line year_lower_ln_line = na
year_lower_ln_line := line.new(bar_index[1], year_lower_ln, bar_index, year_lower_ln, color=color.new(color_1Y, 0), style=line.style_solid, width=1, extend=extend.right)
line.delete(year_lower_ln_line[1])
if show_label
var label year_upper_ln_label = na
label.delete(year_upper_ln_label)
year_upper_ln_label := label.new(x = time + chper * 0, y = year_upper_ln, text = str.tostring(year_upper_ln, "#.##") + " (Y⌃) " + str.tostring(year_volt_ln, "#.##") + "%\n", textcolor=color_1Y, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
var label year_lower_ln_label = na
label.delete(year_lower_ln_label)
year_lower_ln_label := label.new(x = time + chper * 0, y = year_lower_ln, text = str.tostring(year_lower_ln, "#.##") + " (Y⌄) " + str.tostring(year_volt_ln, "#.##") + "%\n", textcolor=color_1Y, color=color.new(color.white, 100), style=label.style_label_left, size=size.normal, xloc = xloc.bar_time, yloc=yloc.price)
//////////////////////////////////////////////////////////////////// End |
Rob Hoffman's 50/80/90/Price Trailing Stop Loss | https://www.tradingview.com/script/dvWTgOeU-Rob-Hoffman-s-50-80-90-Price-Trailing-Stop-Loss/ | D499 | https://www.tradingview.com/u/D499/ | 120 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © D499
// D D D 4 4
// D D 4 4
// D D 4 4 4 4
// D D 4
// D D D 4
//@version=5
indicator("Hoffman Trailing Stop", overlay = true)
// @ INPUTS ------------------------------
entry = input.price(title = "Entry Price: ", defval = 0.0, confirm = true)
limit = input.price(title = "Take Profit Price: ", defval = 0.0, confirm = true)
stop = input.price(title = "Stop Price: ", defval = 0.0, confirm = true)
border_thickness = input.int(title = "Table Thickness", defval = 3, maxval = 4)
table_color = input.color(title = "Table Background Color", defval = color.new(#FFF1C1, 10))
border_color = input.color(title = "Table Border Color", defval = color.new(#000000, 10))
// @ COLORS ------------------------------
gray = color.new(color.gray, 70)
green = color.new(color.green, 70)
red = color.new(color.red, 70)
// @ CALCULATION --------------------------
// H - ((H - L) * %)
// L + ((H - L) * %)
p50 = (entry + limit)/2
p80 = limit > entry ? (0.8 * (limit - entry) + entry) : math.abs(0.8 * (entry - limit) - entry)
p90 = limit > entry ? (0.9 * (limit - entry) + entry) : math.abs(0.9 * (entry - limit) - entry)
tsl1 = limit > p50 ? math.abs(0.5 * (limit - p50) - p50) : (0.5 * (p50 - limit) + p50)
tsl2 = limit > p80 ? math.abs(0.8 * (limit - p80) - p80) : (0.8 * (p80 - limit) + p80)
tsl3 = limit > p90 ? math.abs(0.9 * (limit - p90) - p90) : (0.9 * (p90 - limit) + p90)
// @ TABLE --------------------------------
t = table.new(position.middle_right, 10, 10, table_color, border_color = border_color, border_width = border_thickness)
table.cell(t, 0, 0, "TSL 1: ")
table.cell(t, 1, 0, str.tostring(math.round_to_mintick(tsl1)))
table.cell(t, 0, 1, "TSL 2: ")
table.cell(t, 1, 1, str.tostring(math.round_to_mintick(tsl2)))
table.cell(t, 0, 2, "TSL 3: ")
table.cell(t, 1, 2, str.tostring(math.round_to_mintick(tsl3)))
table.cell(t, 2, 0, "50% of TP: ")
table.cell(t, 3, 0, str.tostring(math.round_to_mintick(p50)))
table.cell(t, 2, 1, "80% of TP: ")
table.cell(t, 3, 1, str.tostring(math.round_to_mintick(p80)))
table.cell(t, 2, 2, "90% of TP: ")
table.cell(t, 3, 2, str.tostring(math.round_to_mintick(p90)))
t2 = table.new(position.top_right, 10, 10)
table.cell(t2, 0, 0, "Once price reaches 50% of take profit, place your stop loss at TSL 1\nOnce price reaches 80% of take profit, place your stop loss at TSL 2\nOnce price reaches 90% of take profit, place your stop loss at TSL 3")
|
MACD-V | https://www.tradingview.com/script/OR8jM6i7-MACD-V/ | jamiedubauskas | https://www.tradingview.com/u/jamiedubauskas/ | 117 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jamiedubauskas
//@version=5
indicator(title = "MACD-V", shorttitle = "MACD-V", overlay = false)
// asking for inputs for the parameters of the MACD-V indicator
fast_len = input.int(title = "MACD Fast Length", defval = 12, minval = 1, group = "Indicator Settings")
slow_len = input.int(title = "MACD Slow Length", defval = 26, minval = 1, group = "Indicator Settings")
source = input.source(title = "Source", defval = close, group = "Indicator Settings")
signal_len = input.int(title = "Signal Line Smoothing Length", defval = 9, minval = 1, group = "Indicator Settings")
atr_len = input.int(title = "ATR Length", defval = 26, minval = 1, tooltip = "Used to gauge volatility to standardize MACD. Keep at the same value as the MACD Slow Length parameter for best results", group = "Indicator Settings")
overbought_bounds = input.int(title = "Overbought Bounds", defval = 150, minval = 1, tooltip = "Threshold for MACD Line to cross above to be considered overbought. Original author of MACD-V placed it at 150.")
oversold_bounds = input.int(title = "Oversold Bounds", defval = -150, maxval = -1, tooltip = "Threshold for MACD Line to cross below to be considered oversold. Original author of MACD-V placed it at -150.")
// indicator calculation
macd = ((ta.ema(source, fast_len) - ta.ema(source, slow_len)) / ta.atr(atr_len)) * 100
signal = ta.ema(macd, signal_len)
hist = macd - signal
// asking for input for the color of the macd and signal lines
macd_color = input.color(title = "MACD Line", defval = #2962FF, group = "Color Settings")
signal_color = input.color(title = "Signal Line", defval = #FF6D00, group = "Color Settings")
// getting colors for the histogram
col_grow_above = input(#26A69A, "Above Grow", group="Histogram", inline="Above")
col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above")
col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below")
col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below")
macd_plot = plot(title = "MACD Line", series = macd, color = macd_color)
plot(title = "Signal Line", series = signal, color = signal_color)
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below)))
// plotting horizontal lines for overbought and oversold bounds
upper_band = plot(overbought_bounds, title = "Overbought Bounds", color = color.new(color.white,99))
lower_band = plot(oversold_bounds, title = "Oversold Bounds", color = color.new(color.white,99))
// filling between the lines and the bounds if overbought or oversold
overbought_color = macd > overbought_bounds ? color.new(color.red,30) : na
oversold_color = macd < oversold_bounds ? color.new(color.green,30) : na
fill(macd_plot, upper_band, color = overbought_color, title = "Overbought Fill")
fill(lower_band, macd_plot, color = oversold_color, title = "Oversold Fill")
// extending out the boundaries
extended_upper_band = hline(overbought_bounds, title = "Overbought Bounds Extended", color = color.new(color.white,30), linestyle = hline.style_solid)
extended_lower_band = hline(oversold_bounds, title = "Oversold Bounds Extended", color = color.new(color.white,30), linestyle = hline.style_solid)
fill(extended_upper_band, extended_lower_band, color = color.new(color.white, 95), title = "Normal Bounds Background Extended") |
Sequence Distribution Report | https://www.tradingview.com/script/SJ3VjGEK-Sequence-Distribution-Report/ | RicardoSantos | https://www.tradingview.com/u/RicardoSantos/ | 134 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos
//@version=5
indicator("Sequence Distribution Report", max_lines_count=100)
import RicardoSantos/DebugConsole/8 as console
// @function generates a string with xyz spaces.
sp(int em=0, int en=0, int six_per_em=0) => //{
string _s6_ = ' ' // six per em
string _en_ = ' ' // en space
string _em_ = ' ' // em space
string _str = ''
if em > 0
for _i = 1 to em
_str += _em_
if en > 0
for _i = 1 to en
_str += _en_
if six_per_em > 0
for _i = 1 to six_per_em
_str += _s6_
_str
//}
var string _D01_ = 'CUM', var string _D02_ = 'ATR', var string _D03_ = 'STD'
string deviation_method = input.string(defval=_D01_, options=[_D01_, _D02_, _D03_], tooltip='Method to pool average deviation, cumulative, atr or stdev.')
int deviation_length = input.int(defval=100, minval=1, tooltip='atr or stdev function length.')
// unit deviation, uses cumulative deviation average as base deviation unit, to
// measure how many deviations the price changes on a sequence.
int unit_dev =
switch deviation_method
_D01_ => math.round(math.abs(close - open) / (ta.cum(ta.tr) / (bar_index + 1)))
_D02_ => math.round(math.abs(close - open) / ta.atr(deviation_length))
_D03_ => math.round(math.abs(close - open) / ta.stdev(close, deviation_length))
=> math.round(math.abs(close - open) / ta.tr)
// plot(unit_dev)
int max_count = 1 + input.int(defval=20, maxval=50, tooltip='Limit of counted sequences.')
var int nsequences = 0
var array<int> upseq = array.new<int>(max_count, 0)
var array<int>doseq = array.new<int>(max_count, 0)
bool upbar = close > open
bool dobar = close < open
// up sequence counter
var int ucount = 0
if upbar
ucount += unit_dev
else if ucount > 0 and ucount < max_count
array.set(upseq, ucount, array.get(upseq, ucount) + 1)
nsequences += 1
ucount := 0
else
ucount := 0
// down sequence counter
var int dcount = 0
if dobar
dcount += unit_dev
else if dcount > 0 and dcount < max_count
array.set(doseq, dcount, array.get(doseq, dcount) + 1)
nsequences += 1
dcount := 0
else
dcount := 0
var array<line> ulines = array.new<line>(max_count)
var array<line> dlines = array.new<line>(max_count)
if barstate.isfirst
for _i = 0 to max_count - 1
array.set(ulines, _i, line.new(bar_index, 0.0, bar_index, 1.0, xloc.bar_index, extend.none, color.lime, width=2))
array.set(dlines, _i, line.new(bar_index, 0.0, bar_index, 1.0, xloc.bar_index, extend.none, color.red, width=2))
_lvline(idx, uvalue, dvalue) =>
int _idx1 = bar_index + idx * 3, _idx2 = _idx1 + 1
line.set_x1(array.get(ulines, idx), _idx1)
line.set_xy2(array.get(ulines, idx), _idx1, uvalue)
line.set_x1(array.get(dlines, idx), _idx2)
line.set_xy2(array.get(dlines, idx), _idx2, dvalue)
string date = str.format('{0, number, 0000} / {1, number, 00} / {2, number, 00}', year, month, dayofmonth)
var string start_date = date
int utotal = array.sum(upseq)
int dtotal = array.sum(doseq)
str = 'Distribution report:\n' +
str.format('Ticker : {0}, {1}\n', syminfo.tickerid, timeframe.period) +
str.format('Deviation method: {0} {1}\n', deviation_method, deviation_method != _D01_ ? str.tostring(deviation_length) : '') +
str.format('Start date: {0}\n', start_date) +
str.format('End date: {0}\n', date) +
str.format('Totals: {0} sequences in {1} bars\n', nsequences, bar_index) +
str.format('Deviation{0}|{1}UP{2}|{3}DOWN\n', sp(0,1), sp(6), sp(0,1,1), sp(2,1))
for _i = 1 to max_count-1
int _u = array.get(upseq, _i), _d = array.get(doseq, _i)
_lvline(_i, _u, _d)
str += str.format(' {0, number, 00} | {1, number, 000}({2, number, 00.00}%) | {3, number, 000}({4, number, 00.00}%)\n', _i, _u, (_u/utotal)*100, _d, (_d/dtotal)*100)
if barstate.islastconfirmedhistory
console.log(str)
// var _l = label.new(bar_index, 0.0, '', color=color.silver, style=label.style_diamond, tooltip=str)
// label.set_x(_l, bar_index)
// label.set_tooltip(_l, str) |
Leverage and contracts tool | https://www.tradingview.com/script/yHt6Sis3/ | ExpensiveJok | https://www.tradingview.com/u/ExpensiveJok/ | 81 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ExpensiveJok
// This script calculates the necessary leverage to afford any position giving the entry price, the max loss and the whole capital involved.
//@version=5
indicator("Leverage calc", overlay = true, precision = 4)
//--------------------------------------- TIPS ---------------------------
in_lvl_tip = "English: Entry price of the trade. // Spanish: Precio de entrada para la orden."
qty_risk_tip = "English: Capital risk in the operation. It is the capital that you will lose if the price target the SL. // Spanish: Capital que se perderá si el precio alcanza el SL."
qty_tot_tip = "English: Total capital involved in the operation. // Spanish: Capital total que será invertido en la posición."
stop_lvl_tip = "English: Stop loss price // Spanish: Precio de Stop loss."
//--------------------------------------- INPUTS -------------------------
in_lvl = input.float(title = "Entry lvl" , defval = 0, tooltip = in_lvl_tip, group = "POSITION")
qty_risk= input.float(title = "Equity risk" , defval = 10, minval = 1, tooltip = qty_risk_tip, group = "POSITION" )
qty_tot = input.float(title = "Total eqity" , defval = 100, minval = 1, tooltip = qty_tot_tip, group = "POSITION")
stop_lvl = input.float(title ="SL level" , defval = 0, tooltip = stop_lvl_tip, group = "POSITION")
//-- Visual
tab_text_c = input.color(title = "Text color", defval = color.white, group = "VISUAL")
tab_bg_c = input.color(title = "Background color", defval = color.black, group = "VISUAL")
tab_pos = input.string(title= "Table position", defval = "Top right", options = ["Top left", "Top center", "Top right", "Middle left", "Middle center", "Middle right", "Bottom left", "Bottom center", "Bottom right"], group = "VISUAL")
//--------------------------------------- PROCESS ------------------------
// The script determinates if the position side is long or short and select the correct formula.
contracts = (in_lvl - stop_lvl) > 0 ? qty_risk / (in_lvl - stop_lvl) : qty_risk / (stop_lvl - in_lvl)
leverage = (contracts * in_lvl) / qty_tot
contracts_string= str.tostring(contracts)
leverage_string = str.tostring(leverage)
tab_pos_switch = switch tab_pos
"Top left" => position.top_left
"Top center" => position.top_center
"Top right" => position.top_right
"Middle left" => position.middle_left
"Middle center" => position.middle_center
"Middle right" => position.middle_right
"Bottom left" => position.bottom_left
"Bottom center" => position.bottom_center
"Bottom right" => position.bottom_right
//---------------------------------------- PLOTS ------------------------
tab = table.new(position = tab_pos_switch, columns = 2, rows = 2, frame_width = 1, border_width = 1, bgcolor = tab_bg_c)
table.cell(tab, column = 0, row = 0, text = "Leverage:", text_color = tab_text_c, text_halign = text.align_center, text_valign = text.align_center, text_size = size.auto)
table.cell(tab, column = 1, row = 0, text = leverage_string, text_color = tab_text_c, text_halign = text.align_center, text_valign = text.align_center, text_size = size.normal)
table.cell(tab, column = 0, row = 1, text = "Contracts:", text_color = tab_text_c, text_halign = text.align_center, text_valign = text.align_center, text_size = size.normal)
table.cell(tab, column = 1, row = 1, text = contracts_string, text_color = tab_text_c, text_halign = text.align_center, text_valign = text.align_center, text_size = size.normal)
|
'last red low / last green high' exit | https://www.tradingview.com/script/B5MWwWad-last-red-low-last-green-high-exit/ | carlpwilliams2 | https://www.tradingview.com/u/carlpwilliams2/ | 113 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © carlpwilliams2
//@version=5
indicator("'Last red low / Last green high' exit", overlay=true)
/// copy from this point to add to your strat
/// **** 'Last red low / Last green high' exit indicator by @carlpwilliams2 - https://www.tradingview.com/script/B5MWwWad-last-red-low-last-green-high-exit/
stopLossTarget = input.float(0.5,title="Stop loss target %")
reqChangePerc = input.float(0.1,title="Change % required for new high/low")
showGreenHighs = input.bool(true, title="Show long Exit points", group="Exit points")
showRedLows = input.bool(true, title="Show short Exit points", group="Exit points")
var lowOfLastRed =low
var highOfLastGreen = high
var tpLongPrice = close
candleIsRed = open>close
candleIsGreen = not candleIsRed
changeOfLowPerc = lowOfLastRed>low? ((lowOfLastRed - low)/low)*100 : ((low - lowOfLastRed)/lowOfLastRed) *100
changeOfHighPerc = highOfLastGreen>high? ((highOfLastGreen - high)/high) *100 : ((high - highOfLastGreen)/highOfLastGreen) *100
if(candleIsRed and barstate.isconfirmed and (changeOfLowPerc>reqChangePerc or changeOfLowPerc<0))
lowOfLastRed := low
if(candleIsGreen and barstate.isconfirmed and (changeOfHighPerc>reqChangePerc or changeOfHighPerc>0))
highOfLastGreen := high
distanceToHigh = (highOfLastGreen - close)
distanceToLow = (close - lowOfLastRed)
distanceToLongExitPercentage = (distanceToLow/close)*100
distanceToShortExitPercentage = (distanceToHigh/highOfLastGreen) * 100
plot(not ta.change(lowOfLastRed) and showGreenHighs and distanceToLongExitPercentage > stopLossTarget ? lowOfLastRed : na, title = "Low of last red", style = plot.style_stepline_diamond, color = distanceToLongExitPercentage > stopLossTarget ? color.red:color.new(color.red,60), linewidth=2)
plot(not ta.change(highOfLastGreen) and showRedLows and distanceToShortExitPercentage > stopLossTarget ? highOfLastGreen : na, title="High of last green", style=plot.style_stepline_diamond, color = distanceToShortExitPercentage > stopLossTarget ? color.green:color.new(color.green,60), linewidth=2)
// ***** end of last red/green indicator
|
DATE and ATR20 for practice using kojiro_indicators | https://www.tradingview.com/script/mSnsMhII/ | trader_aaa111 | https://www.tradingview.com/u/trader_aaa111/ | 10 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kattsu
//@version=5
indicator('USDJPY 100EMA(ATR20) ATR20 DATE', precision=2, overlay=false)
//a=ATR20
length = input(20, title='length of ATR')
a = ta.ema(ta.tr, length)
plot(a, linewidth=2, color=color.new(color.blue, 0))
//b=100EMA of ATR
long = input(100, title='length of EMA(ATR20)')
b = ta.ema(a, long)
plot(b, linewidth=2, color=color.new(color.red, 0))
//size
si=input(size.normal,title="size(small,normal,large,huge,auto)")
//DATE
D = label.new(bar_index, y=0, text="DATE "+str.tostring(year) + '.' + str.tostring(month) + '.' + str.tostring(dayofmonth), textcolor=color.new(color.black, 0), size=si, style=label.style_none)
label.delete(D[1])
//Space
sp1 = input(20,title="space between DATE and ATR")
sp2 = input(40,title="space between DATE and 100EMA of ATR")
sp3 = input(60,title="space between DATE and USDJPY")
//ATR20
ar=math.round(a,precision=1)
E = label.new(bar_index - sp1, y=0, text="ATR20= "+str.tostring(ar), textcolor=color.new(color.blue, 0), size=si, style=label.style_none)
label.delete(E[1])
//100EMA of ATR
br=math.round(b,precision=1)
F = label.new(bar_index - sp2, y=0, text="100EMA(ATR20)= "+str.tostring(br), textcolor=color.new(color.red, 0), size=si, style=label.style_none)
label.delete(F[1])
U=request.security("USDJPY","D",close)
Ur=math.round(U,precision=2)
G = label.new(bar_index - sp3, y=0, text="USDJPY= "+str.tostring(Ur), textcolor=color.new(color.black, 0), size=si, style=label.style_none)
label.delete(G[1])
|
Wolfe Scanner (Multi - zigzag) [HeWhoMustNotBeNamed] | https://www.tradingview.com/script/fVPGXfB3-Wolfe-Scanner-Multi-zigzag-HeWhoMustNotBeNamed/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 4,262 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
// __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
// / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
// $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
// $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
// $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
// $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
// $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
// $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
// $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
//
//
//
//@version=5
indicator("Wolfe Scanner (Multi - zigzag) [HeWhoMustNotBeNamed]", shorttitle='Wolfe', max_lines_count=500, max_labels_count=500, overlay=true)
import HeWhoMustNotBeNamed/rzigzag/10 as zigzag
import HeWhoMustNotBeNamed/_matrix/5 as ma
theme = input.string('Dark', title='Theme', options=['Light', 'Dark'], group='Generic',
tooltip='Chart theme settings. Line and label colors are generted based on the theme settings. If dark theme is selected, '+
'lighter colors are used and if light theme is selected, darker colors are used.')
avoidOverlap = input.bool(false, 'Suppress Overlap', group='Generic',
tooltip='Avoids plotting wedge if there is an existing wedge at starting point. This does not avoid nesting wedges (Wedge within wedge)')
drawZigzag = input.bool(true, 'Draw Zigzag', group='Generic', tooltip='Draw zigzag lines and mark pivots within wedge')
drawProjection = input.bool(true, 'Draw Projection', group='Generic', tooltip='Draw Wolfe projection')
zigzagLength = input.int(3, step=5, minval=3, title='Length', group='Zigzag')
zigzagDepth = input.int(250, step=5, minval=3, title='Depth', group='Zigzag')
minLevel = input.int(2, "Min Level", group='Zigzag', minval = 1, tooltip = 'Min Level to calculate Wolfe')
var themeColors = theme=="Dark"? array.from(
color.rgb(251, 244, 109),
color.rgb(141, 186, 81),
color.rgb(74, 159, 245),
color.rgb(255, 153, 140),
color.rgb(255, 149, 0),
color.rgb(0, 234, 211),
color.rgb(167, 153, 183),
color.rgb(255, 210, 113),
color.rgb(119, 217, 112),
color.rgb(95, 129, 228),
color.rgb(235, 146, 190),
color.rgb(198, 139, 89),
color.rgb(200, 149, 149),
color.rgb(196, 182, 182),
color.rgb(255, 190, 15),
color.rgb(192, 226, 24),
color.rgb(153, 140, 235),
color.rgb(206, 31, 107),
color.rgb(251, 54, 64),
color.rgb(194, 255, 217),
color.rgb(255, 219, 197),
color.rgb(121, 180, 183)
) : array.from(
color.rgb(61, 86, 178),
color.rgb(57, 163, 136),
color.rgb(250, 30, 14),
color.rgb(169, 51, 58),
color.rgb(225, 87, 138),
color.rgb(62, 124, 23),
color.rgb(244, 164, 66),
color.rgb(134, 72, 121),
color.rgb(113, 159, 176),
color.rgb(170, 46, 230),
color.rgb(161, 37, 104),
color.rgb(189, 32, 0),
color.rgb(16, 86, 82),
color.rgb(200, 92, 92),
color.rgb(63, 51, 81),
color.rgb(114, 106, 149),
color.rgb(171, 109, 35),
color.rgb(247, 136, 18),
color.rgb(51, 71, 86),
color.rgb(12, 123, 147),
color.rgb(195, 43, 173)
)
maxPatternsReference = 10
var pivotBarMatrix = matrix.new<int>()
wedgeLine(l1StartX, l1StartY, l1EndX, l1EndY, l2StartX, l2StartY, l2EndX, l2EndY, zgColor, lastDir)=>
l1t = line.new(l1StartX, l1StartY, l1EndX, l1EndY, color=zgColor, extend=extend.both)
l2t = line.new(l2StartX, l2StartY, l2EndX, l2EndY, color=zgColor, extend=extend.both)
startBar = l1StartX
endBar = l1EndX
l2Start = line.get_price(l2t,startBar)
l2End = line.get_price(l2t, endBar)
line.set_x1(l2t, startBar)
line.set_y1(l2t, l2Start)
line.set_x2(l2t, endBar)
line.set_y2(l2t, l2End)
l1Diff = l1StartY-l1EndY
l2Diff = l2Start-l2End
width = math.abs(endBar-startBar)
closingEndBar = endBar
closingEndPrice = l2End
closingSoon = false
isContracting = math.abs(l1StartY-l2Start) > math.abs(l1EndY-l2End)
isNotTriangle = math.sign(l1StartY-l1EndY) == math.sign(l2Start-l2End)
isWolfeWedge = isContracting and isNotTriangle
if(isWolfeWedge)
for i =endBar to endBar+math.min(500, 2*width)
l1Price = line.get_price(l1t, i)
l2Price = line.get_price(l2t, i)
if(lastDir* (l1Price-l2Price) <= 0)
closingEndBar := i
closingSoon := true
closingEndPrice := (l1Price + l2Price)/2
break
if(closingSoon)
line.set_x2(l2t, closingEndBar)
line.set_y2(l2t, closingEndPrice)
line.set_x2(l1t, closingEndBar)
line.set_y2(l1t, closingEndPrice)
line.set_extend(l1t, extend.none)
line.set_extend(l2t, extend.none)
[l1t, l2t, closingEndBar, closingEndPrice, isWolfeWedge and closingSoon]
find_wedge(zigzagmatrix, startIndex)=>
_5 = matrix.get(zigzagmatrix, startIndex, 0)
_5Bar = int(matrix.get(zigzagmatrix, startIndex, 1))
lastDir = matrix.get(zigzagmatrix, startIndex, 3)
_4 = matrix.get(zigzagmatrix, startIndex+1, 0)
_4Bar = int(matrix.get(zigzagmatrix, startIndex+1, 1))
_3 = matrix.get(zigzagmatrix, startIndex+2, 0)
_3Bar = int(matrix.get(zigzagmatrix, startIndex+2, 1))
_2 = matrix.get(zigzagmatrix, startIndex+3, 0)
_2Bar = int(matrix.get(zigzagmatrix, startIndex+3, 1))
_1 = matrix.get(zigzagmatrix, startIndex+4, 0)
_1Bar = int(matrix.get(zigzagmatrix, startIndex+4, 1))
existingPattern = false
for i=0 to matrix.rows(pivotBarMatrix) > 0? matrix.rows(pivotBarMatrix)-1 : na
commonPivotsCount = (_1Bar == matrix.get(pivotBarMatrix, i, 0) ? 1 : 0) +
(_2Bar == matrix.get(pivotBarMatrix, i, 1) ? 1 : 0) +
(_3Bar == matrix.get(pivotBarMatrix, i, 2) ? 1 : 0) +
(_4Bar == matrix.get(pivotBarMatrix, i, 3) ? 1 : 0) +
(_5Bar == matrix.get(pivotBarMatrix, i, 4) ? 1 : 0)
if ( commonPivotsCount >=3 ) or (avoidOverlap and _1Bar >= matrix.get(pivotBarMatrix, i, 0) and _1Bar <= matrix.get(pivotBarMatrix, i, 4))
existingPattern := true
break
if(not existingPattern)
basicCondition = lastDir > 0? _2 < math.min(_1, _3, _4, _5) and _5 > math.max(_1, _2, _3, _4) and _1 < _3 and _1 > _4 :
_2 > math.max(_1, _3, _4, _5) and _5 < math.min(_1, _2, _3, _4) and _1 > _3 and _1 < _4
if(basicCondition)
zgColor = array.pop(themeColors)
[l1t, l2t, closingEndBar, closingEndPrice, isWolfeWedge] = wedgeLine(_1Bar, _1, _5Bar, _5, _2Bar, _2, _4Bar, _4, zgColor, lastDir)
array.unshift(themeColors, zgColor)
delete = true
if(isWolfeWedge)
ma.unshift(pivotBarMatrix, array.from(_1Bar, _2Bar, _3Bar, _4Bar, _5Bar), maxPatternsReference)
delete := false
if(drawZigzag)
line.new(_1Bar, _1, _2Bar, _2, color=zgColor, extend=extend.none, width=0, style=line.style_dotted)
line.new(_2Bar, _2, _3Bar, _3, color=zgColor, extend=extend.none, width=0, style=line.style_dotted)
line.new(_3Bar, _3, _4Bar, _4, color=zgColor, extend=extend.none, width=0, style=line.style_dotted)
line.new(_4Bar, _4, _5Bar, _5, color=zgColor, extend=extend.none, width=0, style=line.style_dotted)
if(drawProjection)
lproj = line.new(_1Bar, _1, _4Bar, _4, color=zgColor, extend=extend.right, width=0, style=line.style_dashed)
lProjEndPrice = line.get_price(lproj, closingEndBar)
line.set_x2(lproj, closingEndBar)
line.set_y2(lproj, lProjEndPrice)
line.set_extend(lproj, extend.none)
line.new(closingEndBar, lProjEndPrice, closingEndBar, closingEndPrice, color=zgColor, extend=extend.none, width=0, style=line.style_dashed)
if(delete)
line.delete(l1t)
line.delete(l2t)
scan_patterns(startIndex, newPivot, zigzagmatrix)=>
length = matrix.rows(zigzagmatrix)
numberOfPivots=5
if(length >= startIndex+5 and newPivot)
find_wedge(zigzagmatrix, startIndex)
ohlc = array.from(high, low)
setup(zigzagLength, zigzagDepth)=>
[zigzagmatrix, flags] = zigzag.zigzag(zigzagLength, ohlc, numberOfPivots= zigzagDepth)
newPivot = array.get(flags, 1)
doublePivot = array.get(flags, 2)
if(newPivot)
mlzigzag = zigzagmatrix
level = 1
while(matrix.rows(mlzigzag) >= 5)
if(level >= minLevel)
scan_patterns(1, doublePivot, zigzagmatrix)
scan_patterns(0, newPivot,zigzagmatrix)
mlzigzag := zigzag.nextlevel(mlzigzag, zigzagDepth)
level := level+1
setup(zigzagLength, zigzagDepth)
|
Support/Resistant Zone (Simple) | https://www.tradingview.com/script/HBhIkEnk/ | TrendCrypto2022 | https://www.tradingview.com/u/TrendCrypto2022/ | 491 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/Mpivotlow/2.0/
// © TrendCrypto2022
//@version=5
indicator('Support/Resistant Zone (Simple)', overlay=true)
// Input Pivot
number = input.float(15, "Number bars to detect Pivot High/Low", minval=3, maxval=30, step=1, group='Detect Pivot High/Low')
alert1 = input.bool (title="Alert when price test Support Zone", defval=true, group="Set up Alert")
alert2 = input.bool (title="Alert when price test Resistant Zone", defval=true, group="Set up Alert")
//Pivot High/Low and Resistant Zone
// Calculator Pivot High and Resistant Zone
pivothigh = ta.pivothigh(high, number, number)
pivothighv1 = ta.valuewhen(pivothigh, high[number], 0), pivothighb1 = ta.valuewhen(pivothigh, bar_index[number], 0), pivothighv1low = ta.valuewhen(pivothigh, close[number]>open[number] ? close[number] : open[number], 0)
pivothighv2 = ta.valuewhen(pivothigh, high[number], 1), pivothighb2 = ta.valuewhen(pivothigh, bar_index[number], 1), pivothighv2low = ta.valuewhen(pivothigh, close[number]>open[number] ? close[number] : open[number], 1)
pivothighv3 = ta.valuewhen(pivothigh, high[number], 2), pivothighb3 = ta.valuewhen(pivothigh, bar_index[number], 2), pivothighv3low = ta.valuewhen(pivothigh, close[number]>open[number] ? close[number] : open[number], 2)
// Draw Resistant Zone
var line linepivothighv1 = na
line.delete(linepivothighv1)
linepivothighv1 := line.new(pivothighb1, pivothighv1, bar_index, pivothighv1, width = 1, color = close > pivothighv1 ? color.lime : color.red)
var line linepivothighv1low = na
line.delete(linepivothighv1low)
linepivothighv1low := line.new(pivothighb1, pivothighv1low, bar_index, pivothighv1low, width = 1, color = close > pivothighv1low ? color.lime : color.red)
linefill.new(linepivothighv1, linepivothighv1low, color = close > math.max(pivothighv1low, pivothighv1) ? color.new(color.lime, transp =90) : color.new(color.red, transp =90))
var line linepivothighv2 = na
line.delete(linepivothighv2)
linepivothighv2 := line.new(pivothighb2, pivothighv2, bar_index, pivothighv2, width = 1, color = close > pivothighv2 ? color.lime : color.red)
var line linepivothighv2low = na
line.delete(linepivothighv2low)
linepivothighv2low := line.new(pivothighb2, pivothighv2low, bar_index, pivothighv2low, width = 1, color = close > pivothighv2low ? color.lime : color.red)
linefill.new(linepivothighv2, linepivothighv2low, color = close > math.max(pivothighv2low, pivothighv2) ? color.new(color.lime, transp =90) : color.new(color.red, transp =90))
var line linepivothighv3 = na
line.delete(linepivothighv3)
linepivothighv3 := line.new(pivothighb3, pivothighv3, bar_index, pivothighv3, width = 1, color = close > pivothighv3 ? color.lime : color.red)
var line linepivothighv3low = na
line.delete(linepivothighv3low)
linepivothighv3low := line.new(pivothighb3, pivothighv3low, bar_index, pivothighv3low, width = 1, color = close > pivothighv3low ? color.lime : color.red)
linefill.new(linepivothighv3, linepivothighv3low, color = close > math.max(pivothighv3low, pivothighv3) ? color.new(color.lime, transp =90) : color.new(color.red, transp =90))
// Label Resistant Zone
var label Label_pivothighv1 = na
label.delete(Label_pivothighv1)
Label_pivothighv1 := label.new(x=time + 120, y=pivothighv1, text='' + str.tostring(pivothighv1) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivothighv2 = na
label.delete(Label_pivothighv2)
Label_pivothighv2 := label.new(x=time + 120, y=pivothighv2, text='' + str.tostring(pivothighv2) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivothighv3 = na
label.delete(Label_pivothighv3)
Label_pivothighv3 := label.new(x=time + 120, y=pivothighv3, text='' + str.tostring(pivothighv3) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivothighv1low = na
label.delete(Label_pivothighv1low)
Label_pivothighv1low := label.new(x=time + 120, y=pivothighv1low, text='' + str.tostring(pivothighv1low) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivothighv2low = na
label.delete(Label_pivothighv2low)
Label_pivothighv2low := label.new(x=time + 120, y=pivothighv2low, text='' + str.tostring(pivothighv2low) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivothighv3low = na
label.delete(Label_pivothighv3low)
Label_pivothighv3low := label.new(x=time + 120, y=pivothighv3low, text='' + str.tostring(pivothighv3low) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
// Calculator Pivot Low and Support Zone
pivotlow = ta.pivotlow(low, number, number)
pivotlowv1 = ta.valuewhen(pivotlow, low[number], 0), pivotlowb1 = ta.valuewhen(pivotlow, bar_index[number], 0), pivotlowv1high = ta.valuewhen(pivotlow, close[number]>open[number] ? open[number] : close[number], 0)
pivotlowv2 = ta.valuewhen(pivotlow, low[number], 1), pivotlowb2 = ta.valuewhen(pivotlow, bar_index[number], 1), pivotlowv2high = ta.valuewhen(pivotlow, close[number]>open[number] ? open[number] : close[number], 1)
pivotlowv3 = ta.valuewhen(pivotlow, low[number], 2), pivotlowb3 = ta.valuewhen(pivotlow, bar_index[number], 2), pivotlowv3high = ta.valuewhen(pivotlow, close[number]>open[number] ? open[number] : close[number], 2)
// Draw Support Zone
var line linepivotlowv1 = na
line.delete(linepivotlowv1)
linepivotlowv1 := line.new(pivotlowb1, pivotlowv1, bar_index, pivotlowv1, width = 1, color = close > pivotlowv1 ? color.lime : color.red)
var line linepivotlowv1high = na
line.delete(linepivotlowv1high)
linepivotlowv1high := line.new(pivotlowb1, pivotlowv1high, bar_index, pivotlowv1high, width = 1, color = close > pivotlowv1high ? color.lime : color.red)
linefill.new(linepivotlowv1, linepivotlowv1high, color = close > math.max(pivotlowv1high, pivotlowv1) ? color.new(color.lime, transp =90) : color.new(color.red, transp =90))
var line linepivotlowv2 = na
line.delete(linepivotlowv2)
linepivotlowv2 := line.new(pivotlowb2, pivotlowv2, bar_index, pivotlowv2, width = 1, color = close > pivotlowv2 ? color.lime : color.red)
var line linepivotlowv2high = na
line.delete(linepivotlowv2high)
linepivotlowv2high := line.new(pivotlowb2, pivotlowv2high, bar_index, pivotlowv2high, width = 1, color = close > pivotlowv2high ? color.lime : color.red)
linefill.new(linepivotlowv2, linepivotlowv2high, color = close > math.max(pivotlowv2high, pivotlowv2) ? color.new(color.lime, transp =90) : color.new(color.red, transp =90))
var line linepivotlowv3 = na
line.delete(linepivotlowv3)
linepivotlowv3 := line.new(pivotlowb3, pivotlowv3, bar_index, pivotlowv3, width = 1, color = close > pivotlowv3 ? color.lime : color.red)
var line linepivotlowv3high = na
line.delete(linepivotlowv3high)
linepivotlowv3high := line.new(pivotlowb3, pivotlowv3high, bar_index, pivotlowv3high, width = 1, color = close > pivotlowv3high ? color.lime : color.red)
linefill.new(linepivotlowv3, linepivotlowv3high, color = close > math.max(pivotlowv3high, pivotlowv3) ? color.new(color.lime, transp =90) : color.new(color.red, transp =90))
// Label Support Zone
var label Label_pivotlowv1 = na
label.delete(Label_pivotlowv1)
Label_pivotlowv1 := label.new(x=time + 120, y=pivotlowv1, text='' + str.tostring(pivotlowv1) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivotlowv2 = na
label.delete(Label_pivotlowv2)
Label_pivotlowv2 := label.new(x=time + 120, y=pivotlowv2, text='' + str.tostring(pivotlowv2) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivotlowv3 = na
label.delete(Label_pivotlowv3)
Label_pivotlowv3 := label.new(x=time + 120, y=pivotlowv3, text='' + str.tostring(pivotlowv3) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivotlowv1high = na
label.delete(Label_pivotlowv1high)
Label_pivotlowv1high := label.new(x=time + 120, y=pivotlowv1high, text='' + str.tostring(pivotlowv1high) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivotlowv2high = na
label.delete(Label_pivotlowv2high)
Label_pivotlowv2high := label.new(x=time + 120, y=pivotlowv2high, text='' + str.tostring(pivotlowv2high) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
var label Label_pivotlowv3high = na
label.delete(Label_pivotlowv3high)
Label_pivotlowv3high := label.new(x=time + 120, y=pivotlowv3high, text='' + str.tostring(pivotlowv3high) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
// Set up alerts when price test Support/Resistant Zone
price_closebefore1 = close[1]
// Alert price test Support Zone
_testlong(_x, _y) =>
var int trend = na
trend := price_closebefore1 > math.max(_x,_y) ? 1 : price_closebefore1 < math.min(_x,_y) ? -1 : trend[1]
if trend == 1 and alert1 ==true and low < math.max(_x,_y) and close > math.min(_x,_y)
alert (''+ str.tostring(syminfo.ticker) +' test Support Zone. Price: '+ str.tostring(close) +'.', alert.freq_once_per_bar)
_testlong(pivothighv1, pivothighv1low)
_testlong(pivothighv2, pivothighv2low)
_testlong(pivothighv3, pivothighv3low)
_testlong(pivotlowv1, pivotlowv1high)
_testlong(pivotlowv2, pivotlowv2high)
_testlong(pivotlowv3, pivotlowv3high)
// Alert price test Resistant Zone
_testshort(_c, _d) =>
var int trendshort = na
trendshort := price_closebefore1 < math.min(_c,_d) ? -1 : price_closebefore1 > math.max(_c,_d) ? 1 : trendshort[1]
if trendshort == -1 and alert1 ==true and high > math.min(_c,_d) and close < math.max(_c,_d)
alert (''+ str.tostring(syminfo.ticker) +' test Resistant Zone. Price: '+ str.tostring(close) +'.', alert.freq_once_per_bar)
_testshort(pivothighv1, pivothighv1low)
_testshort(pivothighv2, pivothighv2low)
_testshort(pivothighv3, pivothighv3low)
_testshort(pivotlowv1, pivotlowv1high)
_testshort(pivotlowv2, pivotlowv2high)
_testshort(pivotlowv3, pivotlowv3high)
|
HammerCandleIndicator | https://www.tradingview.com/script/3VZawSbI/ | Wpkenpachi | https://www.tradingview.com/u/Wpkenpachi/ | 9 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Wpkenpachi
// @description A hammer candle indicator having the possibility to configure parameters
// @version=5
indicator("HammerCandleIndicator", overlay=true)
float max_candle_body = input.float(30, 'Max Candle Body Heigh Percent', minval=1, maxval=100)
float max_lowest_shadow = input.float(35, 'Max Loewst Shadow Heigh Percent', minval=1, maxval=100)
// @function Get how many percent of the first passed value is the second passed value
// @param hundred_percent float the hundred percent value
// @param value float the value to discover how many percent is of the first argument
// @returns return a float with the percentagem
getIsHowManyPercentOf(float hundred_percent_value, float value) =>
float result = (value * 100) / hundred_percent_value
math.round(result, 2)
// @function Get the candle body range
// @param _open series float open
// @param _close series float close
// @returns return the range in points
getCandleBodyRange(series float _open = open, series float _close = close) =>
math.round(math.abs(open - close), 2)
// @function Get the candle max range
// @param _high series float _high
// @param _low series float _low
// @returns return the range in points
getCandleMaxRange(series float _high = high, series float _low = low) =>
math.round(_high - _low, 2)
// @function Get the candle type (Bullish or bearish)
// @param _open series float open
// @param _close series float close
// @returns return 1 for Bullish and -1 for Bearish
CandleType(series float _open = open, series float _close = close) =>
_close > _open ? 1 : -1
// @function This function will say if the hammer is a valid hammer. A hammer cannot have the same height to the shadow at both sides (up and down)
// @param _open series float open
// @param _close series float close
// @param _high series float _high
// @param _low series float _low
// @returns return true if is a valid hammer and false if its not
isValidHammer(series float _open = open, series float _close = close, series float _high = high, series float _low = low) =>
float shadow_true_height = getCandleMaxRange(_high, _low) - getCandleBodyRange(_open, _close)
float bullish_up_shadow = _high - _close
float bullish_down_shadow = _close - _low
bool is_bullish_up_percent = getIsHowManyPercentOf(shadow_true_height, bullish_up_shadow) <= max_lowest_shadow
bool is_bullish_down_percent = getIsHowManyPercentOf(shadow_true_height, bullish_down_shadow) <= max_lowest_shadow
float bearish_up_shadow = _high - _open
float bearish_down_shadow = _open - _low
bool is_bearish_up_percent = getIsHowManyPercentOf(shadow_true_height, bearish_up_shadow) <= max_lowest_shadow
bool is_bearish_down_percent = getIsHowManyPercentOf(shadow_true_height, bearish_down_shadow) <= max_lowest_shadow
(is_bullish_up_percent or is_bullish_down_percent) or (is_bearish_up_percent or is_bearish_down_percent) ? true : false
// Getting current candle body height
body_range = getCandleBodyRange()
// getting candle total range
candle_total_range = getCandleMaxRange()
// Check if the candle is a valid hammer in body range and in shadow ranges
is_valid_hammer = isValidHammer() and (getIsHowManyPercentOf(candle_total_range, body_range) <= max_candle_body)
if is_valid_hammer
label.new(bar_index, high)
|
CANDLE FILTER | https://www.tradingview.com/script/ZGh6HCvu-CANDLE-FILTER/ | LuxTradeVenture | https://www.tradingview.com/u/LuxTradeVenture/ | 647 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MINTYFRESH97
//@version=5
indicator("CANDLE FIlTER" ,overlay=true )
//user input
var g_ema = "EMA Filter"
emaLength = input.int(title="EMA Length For Pullback ", defval=100, tooltip="Length of the EMA filter for Pullback", group=g_ema)
useEmaFilterPBD = input.bool(title="Use EMA Filter Pullback D?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)
emaLengthPullback6H= input.int(title="EMA Length for Pullback 4h", defval=100, tooltip="Length of the EMA filter for Pullback 6h", group=g_ema)
useEmaFilterPB6H = input.bool(title="Use EMA Filter for Pullback?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)
emaLengthPullback1H = input.int(title="EMA Length for Pullback1H", defval=200, tooltip="Length of the EMA filter for Pullback 1h", group=g_ema)
useEmaFilterPB1H = input.bool(title="Use EMA Filter for Pullback1H?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)
emaLengthRallyD = input.int(title="EMA Length for Rally D", defval=100, tooltip="Length of the EMA filter for Rally D", group=g_ema)
useEmaFilterD = input.bool(title="Use EMA Filter for Rally?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)
emaLengthRally6H = input.int(title="EMA Length for Rally 4H", defval=100, tooltip="Length of the EMA filter for Rally D", group=g_ema)
useEmaFilterRally6H = input.bool(title="Use EMA Filter for Rally 6H?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)
emaLengthRally1H = input.int(title="EMA Length for Rally 1H", defval=100, tooltip="Length of the EMA filter for Rally D", group=g_ema)
useEmaFilterRally1H = input.bool(title="Use EMA Filter for Rally 1H?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema)
movingAverage = input.bool(title="Moving Averages", defval=true, tooltip="Turns on/off the EMA filter", group=g_ema)
emaLength9 = input.int(title="9ema Candle Layouth", defval=9, tooltip="9ema Candle Layout", group=g_ema)
useEmaFilter = input.bool(title="9ema Candle Layout?", defval=false, tooltip="Turns on/off the 9EMA Candle filter", group=g_ema)
///////////////////////////////
ema = ta.ema(close, emaLength)
///////PULLBACK DAILY //////////////////////////////////////////////
// Get EMA filter
emaPBD = ta.ema(close, emaLength)
emaFilterLongPBD = not useEmaFilterPBD or close > ema
//swing high/low filter
swingLowX = low == ta.lowest(low,4) or low[1] ==ta.lowest(low,4)
//Candle
pullBack1= (close[3] < close[4]) and (close[2] < close[3])
and (close[1] < close[2]) and (close > close[1]) and emaLength and swingLowX and timeframe.isdaily
//////RallycandleDAILY
emashortD = ta.ema(close, emaLengthRallyD)
emaFilterShortD = not useEmaFilterD or close < emashortD
//swing high/low filter
swingHigh = high == ta.highest(high,5) or high[1] == ta.highest(high,5)
///candle
RallieCandle = (close[2] > close[3]) and (close[1] > close[2]) and
(close < close[1]) and emaFilterShortD and swingHigh and timeframe.isdaily
///////////////////////////////////////////////////////////////
////PULLBACK6H
emaPB6H = ta.ema(close, emaLength)
emaFilterLongPB6H = not useEmaFilterPB6H or close > emaPB6H
//swing high/low filter
swingLow = low == ta.lowest(low,9) or low[1] ==ta.lowest(low,9)
////candle
pullBack = (close[3] < close[4]) and (close[2] < close[3])
and (close[1] < close[2]) and (close > close[1]) and emaFilterLongPB6H and swingLow
////RALLYCANDLE6H
emashort = ta.ema(close, emaLengthRally6H)
swingHighx = high == ta.highest(high,8) or high[1] == ta.highest(high,8)
//swing high/low filter
emaFilterShort6H = not useEmaFilterRally6H or close < emashort
///Candle
RallieCandle6h = (close[3] > close[4]) and (close[2] > close[23]) and
(close < close[1]) and swingHighx and emaFilterShort6H
/////////////////////////////////////////////////////////////
////PULLBACK1H
emaPB1H = ta.ema(close, emaLength)
emaFilterLongPB1H = not useEmaFilterPB1H or close > emaPB1H
//swing high/low filter
swingLowY = low == ta.lowest(low,22) or low[1] ==ta.lowest(low,22)
//candle
pullBack1H = (close[3] < close[4]) and (close[2] < close[3])
and (close[1] < close[2]) and (close > close[1]) and swingLowY and emaFilterLongPB1H and timeframe.isintraday
///RALLYCANDLE1H
emaRally1H = ta.ema(close, emaLengthRally1H)
emaFilterShortRally1H = not useEmaFilterRally1H or close > emaRally1H
swingHighZ = high == ta.highest(high,22) or high[1] == ta.highest(high,22)
RallieCandle1h = (close[3] > close[4]) and (close[2] > close[3]) and
(close < close[1]) and emaFilterShortRally1H and swingHighZ
//////Hammers
// Get user input
fibLevel = input.float(title="Fib Level", defval=0.5)
colorFilter = input.bool(title="Color Filter", defval=false)
//swing high/low filter
swingLowH = low == ta.lowest(low,6) or low[1] ==ta.lowest(low,6)
// Calculate fibonacci level for current candle
bullFib = (low - high) * fibLevel + high
// Determine which price source closes or opens highest/lowest
lowestBody = close < open ? close : open
// Determine if we have a valid hammer or shooting star candle
hammerCandle = lowestBody >= bullFib and not colorFilter and (close > open)
and (close[1] < close[2]) and (close > close[1]) and swingLowH and close
////////INDECISION
// Get user input
maxWickSize = input.float(title="Max Wick Size", defval=2)
maxBodySize = input.float(title="Max Body Size", defval=0.25)
// Get candle data
topWickSize = high - (close > open ? close : open)
bottomWickSize = (close < open ? close : open) - low
bodyPercent = math.abs(open - close) / (high - low)
//swing high
swingHigh1 = high == ta.highest(high,15) or high[1] == ta.highest(high,15)
// Get our filters
swingLow1 = low == ta.lowest(low,15) or low[1] ==ta.lowest(low,15)
// Determine if the current bar is a valid doji candle
doji = bottomWickSize <= topWickSize * maxWickSize and bodyPercent <= maxBodySize
dojiBear = doji and swingHigh1
doji1 = bottomWickSize <= topWickSize * maxWickSize and bodyPercent <= maxBodySize
dojiBull1 = doji and swingLow1
//////////////////////////////////////////////////////////////RALLY CANDLE
// Plot our Rally D Pattern
plotshape(RallieCandle, title='Rally Candle Daily' , style=shape.xcross,size=size.tiny, color=color.red, text="Rally/D" ,location=location.abovebar)
barcolor (RallieCandle ? color.red :na)
alertcondition(RallieCandle, "RallieCandle", "RallieCandle detected for {{ticker}}")
// Plot our Rally 6h Pattern
plotshape(RallieCandle6h, title='Rally Candle 4H' , style=shape.xcross,size=size.tiny, color=color.red, text="Rally/LTF",location=location.abovebar)
alertcondition(RallieCandle6h, "RallieCandle 4H", "RallieCandle detected for {{ticker}}")
// Plot our Rally 1H Pattern
barcolor(RallieCandle1h ? color.red :na)
plotshape(RallieCandle1h, title='Rally Candle 1H' , style=shape.diamond,size=size.tiny, text="Rally/LTF", color=color.red,location=location.abovebar)
alertcondition(RallieCandle1h, "RallieCandle", "RallieCandle detected for {{ticker}}")
//////////////////////////////////////////////////////////////PULLBACKS
// Plot our Pullback D pattern
plotshape(pullBack1, title='Pullback Candle D' , style=shape.xcross,size=size.tiny, color=color.green,text="PB/D",location=location.belowbar)
alertcondition(pullBack1, "Pullback Candle D ", "Pullback Candle DAILY detected for {{ticker}}")
barcolor(pullBack1 ? color.green :na)
// Plot our Pullback 6H pattern
plotshape(pullBack, title='Pullback Candle 4H' ,style=shape.xcross,size=size.tiny, color=color.green, text="PB4H",location=location.belowbar)
alertcondition(pullBack, "Pullback Candle 4H ", "Pullback Candle 4H detected for {{ticker}}")
barcolor(pullBack ? color.green :na)
// Plot our Pullback 1H pattern
plotshape(pullBack1H, title='Pullback Candle 1H' , style=shape.xcross,size=size.tiny, text = "PB1H", color=color.green,location=location.belowbar)
alertcondition(pullBack1H, "Pullback Candle 1H ", "Pullback Candle 1H detected for {{ticker}}")
barcolor(pullBack1H ? color.green :na)
///////////////////////////////////////////////HAMMERS
// Plot our candle patterns
plotshape(hammerCandle, style=shape.triangleup, size=size.tiny, title="Hammers" , text="H",color=color.green, location=location.belowbar, color=color.green)
alertcondition(hammerCandle, "Hammer", "hammerCandle detected for {{ticker}}")
barcolor(hammerCandle ? color.green:na)
/////////////////////////////////////////////INDECISION
// Draw dojis onto the chartcolor.green
alertcondition(dojiBear, "Bearish Doji", "Bearish Doji detected for {{ticker}}")
plotshape(dojiBear, style=shape.cross,title="Bearish Doji", color=color.purple, text="I", location=location.abovebar)
barcolor(dojiBear ? color.purple :na)
plotshape(dojiBull1, style=shape.cross,title="Bullish Doji", color=color.purple, text="I", location=location.abovebar)
barcolor(dojiBull1 ? color.purple :na)
alertcondition(dojiBull1, "Bullish Doji", "Bullish Doji detected for {{ticker}}")
////EMA
shortlen = input.int(50, "Short MA Length", minval=1)
longlen = input.int(200, "Long MA Length", minval=1)
short = ta.ema(close, shortlen)
long = ta.ema(close, longlen)
plot(short, title="Short ema", color = #FF6D00)
plot(long, title="Long ema", color = #43A047)
plot(ta.cross(short, long) ? short : na, color=#2962FF, style = plot.style_circles, linewidth = 4)
bgcolor(ta.cross(short, long) ? color.new(color.purple, 85) : na)
|
Support/Resistance With Breaks & Bounces [JacobMagleby] | https://www.tradingview.com/script/eN34i35T-Support-Resistance-With-Breaks-Bounces-JacobMagleby/ | JacobMagleby | https://www.tradingview.com/u/JacobMagleby/ | 437 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ExoMaven
//@version=5
indicator("Support/Resistance With Breaks & Bounces[ExoMaven]", shorttitle = "Support/Resistance With Breaks & Bounces [V1]", overlay = true, max_lines_count = 500)
//user input
point_method = input.string(title = "Pivot Method", defval = "Candle Wicks", options = ["Candle Wicks", "Candle Body"], group = "Main Settings")
left_bars = input.int(title = "Sensitivity", defval = 5, minval = 2, inline = "Pivot Length", group = "Main Settings")
right_bars = left_bars//input.int(title = "Rightbars", defval = 5, minval = 2, inline = "Pivot Length", group = "Main Settings")
line_width = input.int(title = "Line Width", defval = 3, group = "Style Settings")
//global variables/arrays
high_source = point_method == "Candle Body" ? (close > open ? close : open) : high
low_source = point_method == "Candle Body" ? (close < open ? close : open) : low
fixed_pivot_high = fixnan(ta.pivothigh(high_source, left_bars, right_bars))
fixed_pivot_low = fixnan(ta.pivotlow(low_source, left_bars, right_bars))
green_candle = close > open
red_candle = close < open
green_engulf = green_candle and red_candle[1] and close > open[1]
red_engulf = red_candle and green_candle[1] and close < open[1]
var red_lines = array.new_line()
var red_breakout = array.new_int()
var red_bounce = array.new_int()
var green_lines = array.new_line()
var green_breakout = array.new_int()
var green_bounce = array.new_int()
green_breakout_trigger = false
green_rejection_trigger = false
red_breakout_trigger = false
red_rejection_trigger = false
//main operation
if barstate.isconfirmed
if array.size(red_lines) > 0
for i = array.size(red_lines) - 1 to 0
line.set_x2(array.get(red_lines, i), bar_index)
if close > line.get_y1(array.get(red_lines, i)) and close[1] < line.get_y1(array.get(red_lines, i)) and array.get(red_breakout, i) == 0
red_breakout_trigger := true
array.set(red_breakout, i, 1)
else
if high >= line.get_y1(array.get(red_lines, i)) and close < line.get_y1(array.get(red_lines, i)) and red_engulf and array.get(red_bounce, i) == 0 and array.get(red_breakout, i) == 0
red_rejection_trigger := true
array.set(red_bounce, i, 1)
if array.size(green_lines) > 0
for i = array.size(green_lines) - 1 to 0
line.set_x2(array.get(green_lines, i), bar_index)
if close < line.get_y1(array.get(green_lines, i)) and close[1] > line.get_y1(array.get(green_lines, i)) and array.get(green_breakout, i) == 0
green_breakout_trigger := true
array.set(green_breakout, i, 1)
else
if low <= line.get_y1(array.get(green_lines, i)) and close > line.get_y1(array.get(green_lines, i)) and green_engulf and array.get(green_bounce, i) == 0 and array.get(green_breakout, i) == 0
green_rejection_trigger := true
array.set(green_bounce, i, 1)
if fixed_pivot_high != fixed_pivot_high[1]
if array.size(red_lines) > 0
line.set_x2(array.get(red_lines, 0), bar_index - right_bars)
array.clear(red_lines)
array.clear(red_breakout)
array.clear(red_bounce)
array.unshift(red_lines, line.new(x1 = bar_index - right_bars, y1 = fixed_pivot_high, x2 = bar_index, y2 = fixed_pivot_high, xloc = xloc.bar_index, color = color.red, width = line_width))
array.unshift(red_breakout, 0)
array.unshift(red_bounce, 0)
if fixed_pivot_low != fixed_pivot_low[1]
if array.size(green_lines) > 0
line.set_x2(array.get(green_lines, 0), bar_index - right_bars)
array.clear(green_lines)
array.clear(green_breakout)
array.clear(green_bounce)
array.unshift(green_lines, line.new(x1 = bar_index - right_bars, y1 = fixed_pivot_low, x2 = bar_index, y2 = fixed_pivot_low, xloc = xloc.bar_index, color = color.green, width = line_width))
array.unshift(green_breakout, 0)
array.unshift(green_bounce, 0)
//shapes
plotshape(series = red_breakout_trigger, title = "Red Breakout", style = shape.xcross, location = location.belowbar, color = color.blue, text = "Break", textcolor = color.red, size = size.tiny, show_last = 20000)
plotshape(series = red_rejection_trigger, title = "Red Rejection", style = shape.xcross, location = location.abovebar, color = color.blue, text = "Bounce", textcolor = color.red, size = size.tiny, show_last = 20000)
plotshape(series = green_breakout_trigger, title = "Green Breakout", style = shape.xcross, location = location.abovebar, color = color.blue, text = "Break", textcolor = color.green, size = size.tiny, show_last = 20000)
plotshape(series = green_rejection_trigger, title = "Green Rejection", style = shape.xcross, location = location.belowbar, color = color.blue, text = "Bounce", textcolor = color.green, size = size.tiny, show_last = 20000)
//alertconditions
alertcondition(condition = red_breakout_trigger, title = "Red Breakout")
alertcondition(condition = red_rejection_trigger, title = "Red Rejection/Bounce")
alertcondition(condition = green_breakout_trigger, title = "Green Breakout")
alertcondition(condition = green_rejection_trigger, title = "Green Rejection/Bounce")
|
Automated Anchored VWAP | https://www.tradingview.com/script/YfOOrHrC-Automated-Anchored-VWAP/ | kurtsmock | https://www.tradingview.com/u/kurtsmock/ | 537 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kurtsmock
//@version=5
indicator("Automated Anchored VWAP", shorttitle="aaVWAP", overlay=true)
vw_g1 = "Pivots Settings"
vw_g2 = "Tracking Settings"
s_piv = input(true, "Show Pivots", group=vw_g1)
_lb = input.int(10, "Left Bars Lookback", group=vw_g1)
_rb = input.int(10, "Right Bars Lookahead", group=vw_g1)
brks = input(true, "Break Early", group=vw_g2, tooltip = "Stops plotting the Pivot Low when price falls beneath.\nStops plotting the Pivot High when price breaks above.")
c_ph = ta.pivothigh(_lb, _rb)
c_pl = ta.pivotlow(_lb, _rb)
_lh = ta.valuewhen(c_ph, c_ph, 0) < ta.valuewhen(c_ph[1], c_ph[1], 0)
_hh = ta.valuewhen(c_ph, c_ph, 0) > ta.valuewhen(c_ph[1], c_ph[1], 0)
_ll = ta.valuewhen(c_pl[1], c_pl[1], 0) > ta.valuewhen(c_pl, c_pl, 0)
_hl = ta.valuewhen(c_pl[1], c_pl[1], 0) < ta.valuewhen(c_pl, c_pl, 0)
var h_vol = 0.0
var h_src = 0.0
if _hh or _lh
h_vol := 0
h_src := 0
for i=0 to _rb
h_vol := h_vol + volume[i]
h_src := h_src + (hlc3[i] * volume[i])
h_sumSrc = hlc3 * volume
h_sumVol = volume
h_sumSrc := _hh or _lh ? h_src : h_sumSrc + h_sumSrc[1]
h_sumVol := _hh or _lh ? h_vol : h_sumVol + h_sumVol[1]
h_aVWAP = h_sumSrc / h_sumVol
var l_vol = 0.0
var l_src = 0.0
if _ll or _hl
l_vol := 0
l_src := 0
for i=0 to _rb
l_vol := l_vol + volume[i]
l_src := l_src + (hlc3[i] * volume[i])
l_sumSrc = hlc3 * volume
l_sumVol = volume
l_sumSrc := _ll or _hl ? l_src : l_sumSrc + l_sumSrc[1]
l_sumVol := _ll or _hl ? l_vol : l_sumVol + l_sumVol[1]
l_aVWAP = l_sumSrc / l_sumVol
h_breaks = brks ? low >h_aVWAP : false
l_breaks = brks ? high<l_aVWAP : false
plot(_hh or _lh or h_breaks ? na : h_aVWAP, color=color.new(color.green,0), style=plot.style_linebr)
plot(_ll or _hl or l_breaks ? na : l_aVWAP, color=color.new(color.red,0), style=plot.style_linebr)
// Pivot Plotshapes
plotshape(s_piv ? _hh : na, 'Higher High', style=shape.square, location=location.abovebar, color=color.new(color.green, 50), text='[HH]', offset=-_rb, size=size.auto)
plotshape(s_piv ? _lh : na, 'Higher Low', style=shape.square, location=location.abovebar, color=color.new(color.red, 50), text='[LH]', offset=-_rb, size=size.auto)
plotshape(s_piv ? _ll : na, 'Lower Low', style=shape.square, location=location.belowbar, color=color.new(color.red, 50), text='[LL]', offset=-_rb, size=size.auto)
plotshape(s_piv ? _hl : na, 'Lower High', style=shape.square, location=location.belowbar, color=color.new(color.green, 50), text='[HL]', offset=-_rb, size=size.auto)
|
Resistance/Support Indicator - Fontiramisu | https://www.tradingview.com/script/Guo8wsr8-Resistance-Support-Indicator-Fontiramisu/ | Fontiramisu | https://www.tradingview.com/u/Fontiramisu/ | 218 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Author : @Fontiramisu
// Indicator based on pivots to find resistances and support.
// @version=5
indicator("Resistance/Support Indicator", overlay=true)
// import Fontiramisu/fontLib/80 as fontilab
import Fontiramisu/fontilab/6 as fontilab
// ------------------------------------- Find dev pivots------------------------------------------------------------------------------------------ [
// -- Var user input --
var devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot."
var depthTooltip = "The minimum number of bars that will be taken into account when analyzing pivots."
thresholdMultiplier = input.float(title="Deviation", defval=2.5, minval=0, tooltip=devTooltip, group="Pivot")
depth = input.int(title="Depth", defval=10, minval=1, tooltip=depthTooltip, group="Pivot")
// Prepare pivot variables
var line lineLast = na
var int iLast = 0 // Index last
var int iPrev = 0 // Index previous
var float pLast = 0 // Price last
var float pLastHigh = 0 // Price last
var float pLastLow = 0 // Price last
var isHighLast = false // If false then the last pivot was a pivot low
isPivotUpdate = false
// Get pivot information from dev pivot finding function
[dupLineLast, dupIsHighLast, dupIPrev, dupILast, dupPLast, dupPLastHigh, dupPLastLow] =
fontilab.getDeviationPivots(thresholdMultiplier, depth, lineLast, isHighLast, iLast, pLast, true, close, high, low)
if not na(dupIsHighLast)
lineLast := dupLineLast
isHighLast := dupIsHighLast
iPrev := dupIPrev
iLast := dupILast
pLast := dupPLast
pLastHigh := dupPLastHigh
pLastLow := dupPLastLow
isPivotUpdate := true
// ] ------------------------------------- Resistance Script ------------------------------------------------------------------------------------------ [
// Inputs
int maxResis = input.int(title="Nb Max res/sup", defval=10, minval=5, tooltip="Number max res/sup to keep in our res/sup history array. The greater it is the older bar index will be taken", group="Resistance/Support")
int nbShowRes = input.int(title="Nb show res/sup", defval=10, minval=1, tooltip="Number of res/sup to be shown", group="Resistance/Support")
int minTopWeight = input.int(title="Min weight shown", defval=15, tooltip="Define min res/sup weight to be shown. Weight is used to measure strengh of res/sup.", group="Resistance/Support")
float rangePercentResis = input.float(title="% range stack", defval=0.015, tooltip="Define price percentage change required to stack a pivot into an existing res/sup. Default is 0.03 = 3%", group="Resistance/Support")
// Vars
var float[] resPrices = array.new_float(1, 0)
var int[] resWeights = array.new_int(1, 0)
var int[] resBarIndexes = array.new_int(1, 0)
var int[] resNbLows = array.new_int(1, 0)
var int[] resNbHighs = array.new_int(1, 0)
if isPivotUpdate
[dupResPrices, dupResWeights, dupResBarIndexes, dupResNbLows, dupResNbHighs] = fontilab.getResistances(resPrices, resBarIndexes, resWeights, resNbLows, resNbHighs, maxResis, rangePercentResis, pLast, iLast, isHighLast)
if not na(dupResPrices)
resPrices := dupResPrices
resWeights := dupResWeights
resBarIndexes := dupResBarIndexes
resNbHighs := dupResNbHighs
resNbLows := dupResNbLows
// -- Show Resis --
var float[] topResPrices = array.new_float(1, 0)
var int[] topBarIndexes = array.new_int(1, 0)
var int[] topResWeights = array.new_int(1, 0)
// Update lines every pivot update
if isPivotUpdate
[dupTopResPrices, dupTopResWeights, dupTopBarIndexes] = fontilab.getTopRes(nbShowRes, minTopWeight, resWeights, resPrices, resBarIndexes)
topResPrices := dupTopResPrices
topBarIndexes := dupTopBarIndexes
topResWeights := dupTopResWeights
// ] ------------------------------------- Do Some Drawings------------------------------------------------------------------------------------------ [
if isPivotUpdate
// DrawLines
fontilab.drawResLines(topResPrices, topBarIndexes)
// ] DEBUG -- Show Table -- [
show_table = input(true, "Show table with stats", group = "Drawings")
// Helping vars
index = 0
// textresPrices = array.size(resPrices) > index ? str.tostring(resPrices[index]) : "na"
// textresWeights = array.size(resWeights) > index ? str.tostring(resWeights[index]) : "na"
// textresBarIndexes = array.size(resBarIndexes) > index ? str.tostring(resBarIndexes[index]) : "na"
// textresNbHighs = array.size(resNbHighs) > index ? str.tostring(resNbHighs[index]) : "na"
// textresNbLows = array.size(resNbLows) > index ? str.tostring(resNbLows[index]) : "na"
textTopResPrices = array.size(topResPrices) > index ? str.tostring(topResPrices[index]) : "na"
textTopResWeights = array.size(topResWeights) > index ? str.tostring(topResWeights[index]) : "na"
if show_table
var table ATHtable = table.new(position.bottom_right, 10, 10, frame_color = color.gray, bgcolor = color.gray, border_width = 1, frame_width = 1, border_color = color.white)
// table.cell(ATHtable, 0, 0, text="resPrices", bgcolor=color.silver, tooltip="")
// // table.cell(ATHtable, 1, 0, text="na", bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 1, 0, text=textresPrices, bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 0, 1, text="resWeights", bgcolor=color.silver, tooltip="")
// table.cell(ATHtable, 1, 1, text=textresWeights, bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 0, 2, text="resBarIndexes", bgcolor=color.silver, tooltip="")
// table.cell(ATHtable, 1, 2, text=textresBarIndexes, bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 0, 3, text="resNbHighs", bgcolor=color.silver, tooltip="")
// table.cell(ATHtable, 1, 3, text=textresNbHighs, bgcolor=color.green, tooltip="")
// table.cell(ATHtable, 0, 4, text="resNbLows", bgcolor=color.silver, tooltip="")
// table.cell(ATHtable, 1, 4, text=textresNbLows, bgcolor=color.green, tooltip="")
table.cell(ATHtable, 0, 5, text="Prices", bgcolor=color.silver, tooltip="")
table.cell(ATHtable, 1, 5, text=str.tostring(textTopResPrices), bgcolor=color.green, tooltip="")
table.cell(ATHtable, 0, 6, text="Weights", bgcolor=color.silver, tooltip="")
table.cell(ATHtable, 1, 6, text=str.tostring(textTopResWeights), bgcolor=color.green, tooltip="")
// ] |
Trend & Momentum V2 | https://www.tradingview.com/script/gr2dFE93-Trend-Momentum-V2/ | pvrcharts | https://www.tradingview.com/u/pvrcharts/ | 225 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pvrcharts
// Simple indicator combining trend and momentum using Moving Average and RSI.
//@version=5
indicator(title="Profitable Trader Pro V2", shorttitle="Profitable Trader Pro V2",overlay=true)
//input
src = input(close, title="Price Source")
string maType = input.string("EMA", "MA type", options = ["EMA", "SMA", "RMA", "WMA"])
malen = input.int(9, minval=1, title="Trend Lookback Period (MA Length)")
rsilen=input.int(5, minval=1, title="Momentum Lookback Period (RSI Length)")
signal = input.bool(true, title="Display long/short signals on the chart.")
tradingzone = input.bool(false, title="You can now filter out price action noise with custom bar colors. Green for bullish bias, red for bearish bias and white for neutral.")
//Trend
mavalue = switch maType
"EMA" => ta.ema(src, malen)
"SMA" => ta.sma(src, malen)
"RMA" => ta.rma(src, malen)
"WMA" => ta.wma(src, malen)
bullish_trend= close > mavalue
bearish_trend= close < mavalue
//Momentum
rsi=ta.rsi(close, rsilen)
bullish_mom = rsi>50
bearish_mom = rsi<50
longbias = bullish_mom ? bullish_trend : false
shortbias = bearish_mom ? bearish_trend : false
switchlong=longbias[1]==false and longbias
switchshort=shortbias[1]==false and shortbias
golongtrigger= (close > high[1]) and longbias
goshorttrigger= (close < low[1]) and shortbias
alertcondition(golongtrigger,title='Long Signal (Set Once Per Bar)',message='Long trade signal for {{ticker}} at alert price {{close}} | T&M Trader Pro V2')
alertcondition(goshorttrigger,title='Short Signal (Set Once Per Bar)',message='Short trade signal for {{ticker}} at alert price {{close}} | T&M Trader Pro V2')
plot(mavalue,"MA_VAL", color=(longbias ? color.green : shortbias ? color.red : color.gray),linewidth=2)
barcolor(tradingzone ? (longbias ? color.green : shortbias ? color.red : color.gray) : na)
plotshape(signal and switchlong,style=shape.labelup,text='🐂',location=location.belowbar, color=color.green)
plotshape(signal and switchshort,style=shape.labeldown,text='🐻',location=location.abovebar, color=color.red) |
Open Interest Delta with MAs[Binance Perpetuals] | https://www.tradingview.com/script/RQP3oEJW-Open-Interest-Delta-with-MAs-Binance-Perpetuals/ | LordOfTheBlockchains | https://www.tradingview.com/u/LordOfTheBlockchains/ | 227 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LordOfTheBlockchains
//@version=5
//Open Interest Delta
//ZLEMA, Tillson, VAR MAs codes are coming from @KivancOzbilgic => https://www.tradingview.com/script/sfV6H5h5-SuperTrended-Moving-Averages/
//KAMA code is coming from @HPOTTER => Kaufman Moving Average Adaptive (KAMA) => https://www.tradingview.com/script/RsdQHpdq-Kaufman-Moving-Average-Adaptive-KAMA/
// This indicator only shows Binance Perpetuals Open Interest Delta
indicator("Open Interest Delta with MAs[Binance Perpetuals]", "OI-Delta", format = format.volume)
bool overwriteSymbolInput = input.bool(false, "Override symbol", inline = "Override symbol")
string tickerInput = input.symbol("", "", inline = "Override symbol")
showInfoTable = input(true, title='Show Info Table')
string symbolOnly = str.substring(tickerInput, str.pos(tickerInput, ":") + 1)
string userSymbol = overwriteSymbolInput ? symbolOnly : syminfo.prefix + ":" + syminfo.ticker
//
// Tickers changed. Old version ends with tickerPERP. Now it ends with ticker.P
// strPerp = 'PERP'
// isPerp = str.endswith(userSymbol, strPerp)
// string openInterestTicker = isPerp ? str.format("{0}_OI", userSymbol) : str.format("{0}PERP_OI", userSymbol)
//
//###############################################
// Change for new version:
//###############################################
strPerp = '.P'
isPerp = str.endswith(userSymbol, strPerp)
string openInterestTicker = isPerp ? str.format("{0}_OI", userSymbol) : str.format("{0}.P_OI", userSymbol)
//###############################################
// Change for new version:
//###############################################
//
//
string timeframe = syminfo.type == "futures" and timeframe.isintraday ? "1D" : timeframe.period
[oiOpen, oiHigh, oiLow, oiClose, oiColorCond] = request.security(openInterestTicker, timeframe, [open, high, low, close, close > close[1]], ignore_invalid_symbol = true)
oiOpen := oiOpen ? oiOpen : na
oiHigh := oiHigh ? oiHigh : na
oiLow := oiLow ? oiLow : na
oiDelta = oiClose - oiOpen
showHighDiff = input(true, title='Show Delta Upper Shadow', group="----------Bar Edge----------")
showLowDiff = input(true, title='Show Delta Lower Shadow', group="----------Bar Edge----------")
oiDelta003= oiHigh - oiOpen
plot(showHighDiff ? oiDelta003 : na, title="OI Upper Shadow", color=color.new(color.aqua,0) , style= plot.style_histogram, linewidth=4)
oiDelta002= oiLow - oiOpen
plot(showLowDiff ? oiDelta002 : na, title="OI Lower Shadow", color=color.new(color.yellow, 0), style= plot.style_histogram, linewidth=4)
oiDelta001= oiClose - oiOpen
oiDeltaColor= oiDelta001>=0 ? color.new(color.green, 15) : color.new(color.red, 15)
plot(oiDelta001, title="Delta", color=oiDeltaColor, style= plot.style_columns)
if barstate.islastconfirmedhistory and na(oiClose)
runtime.error(str.format("No Open Interest data found for the `{0}` symbol.", userSymbol))
if barstate.isfirst and isPerp and showInfoTable
var table symbolTable = table.new(position.bottom_left, 1, 1, bgcolor = color.new(color.gray, 0))
table.cell(symbolTable, 0, 0, text ="open interest Delta data: " + openInterestTicker, text_color = color.white, text_size = size.small)
if barstate.isfirst and not isPerp and showInfoTable
var table symbolTable = table.new(position.bottom_left, 1, 1, bgcolor = color.new(color.gray, 0))
table.cell(symbolTable, 0, 0, text = "open interest Delta data: " + openInterestTicker + " !!!!! NOT " + syminfo.tickerid + " SPOT !!!!!", text_color = color.white, text_size = size.small)
//=======================================================================================================================
//=======================================================================================================================
showMa001_001 = input(false, title='Show OI Delta MA', group="----------MA----------", tooltip='MAs default values \n SMA=9 \n EMA=9 \n HMA=9 \n WMA=9 \n VWMA=20 \n DEMA=9 \n TEMA=9 \n RMA=15 \n SWMA=No Length \n TMA=10 \n LSMA=25 \n ZLEMA=8 \n Tillson=8 \n VAR=9')
string deltaSrcInput_001 = input.string("Delta", "MA source", options = ["Delta", "Delta (H+L)/2"], group="----------MA----------")
string maType_001 = input.string("NONE", "MA type", options = ["NONE", "EMA", "SMA","HMA", "ALMA", "WMA", "VWMA", "VWAP", "DEMA", "TEMA", "KAMA", "LSMA", "RMA", "SWMA", "TMA", "WWMA", "ZLEMA", "Tillson", "VAR"], group="----------MA----------")
int maLength_001 = input.int(10, "MA length", minval = 2, group="----------MA----------", tooltip='AMs default values \n SMA=9 \n EMA=9 \n HMA=9 \n WMA=9 \n VWMA=20 \n DEMA=9 \n TEMA=9 \n RMA=15 \n SWMA=No Length \n TMA=10 \n LSMA=25 \n ZLEMA=8 \n Tillson=8 \n VAR=9')
maWindowSizeALMA_001 = input(title="ALMA Window Size", defval=9, tooltip="It is functional when ALMA selected", group="----------MA----------")
maALMAoffset_001 = input(0.85, "ALMA Offset", tooltip="It is functional when ALMA selected", group="----------MA----------")
maALMAsigma_001 = input(6, "ALMA Sigma", tooltip="It is functional when ALMA selected", group="----------MA----------")
T3a1_001 = input.float(0.7, 'TILLSON T3 Volume Factor', tooltip="It is functional when Tillson selected", step=0.1, group="----------MA----------")
float maSrc_001 = switch deltaSrcInput_001
"Delta" => oiDelta
"Delta (H+L)/2"=>((oiDelta002 + oiDelta003)/2)
=>
runtime.error("No matching MA type found.")
float(na)
maType_001check = (maType_001 == "ZLEMA") or (maType_001 == "Tillson") or (maType_001 == "VAR") or (maType_001 == "WWMA") or (maType_001 == "KAMA")
//VAR : Variable Index Dynamic Moving Average a.k.a. VIDYA
nAMA_001 = 0.0
WWMA_001 = 0.0
ZLEMA_001 = 0.0
TILLSONT3_001out = 0.0
VAR_001 = 0.0
Var_Func_001(src_001, length_001) =>
valpha_001 = 2 / (length_001 + 1)
vud1_001 = src_001 > src_001[1] ? src_001 - src_001[1] : 0
vdd1_001 = src_001 < src_001[1] ? src_001[1] - src_001 : 0
vUD_001 = math.sum(vud1_001, 9)
vDD_001 = math.sum(vdd1_001, 9)
vCMO_001 = nz((vUD_001 - vDD_001) / (vUD_001 + vDD_001))
VAR_001func = 0.0
VAR_001func := nz(valpha_001 * math.abs(vCMO_001) * src_001) + (1 - valpha_001 * math.abs(vCMO_001)) * nz(VAR_001func[1])
VAR_001func
if maType_001check
//ZLEMA : Zero Lag Exponential Moving Average
ZLEMA_001 := if maType_001=="ZLEMA"
zxLag_001 = maLength_001 / 2 == math.round(maLength_001 / 2) ? maLength_001 / 2 : (maLength_001 - 1) / 2
zxEMAData_001 = maSrc_001 + maSrc_001 - maSrc_001[zxLag_001]
ZLEMA_001calc = ta.ema(zxEMAData_001, maLength_001)
ZLEMA_001calc
//TILL : Tillson T3 Moving Average
TILLSONT3_001out := if maType_001=="Tillson"
T3e1_001 = ta.ema(maSrc_001, maLength_001)
T3e2_001 = ta.ema(T3e1_001, maLength_001)
T3e3_001 = ta.ema(T3e2_001, maLength_001)
T3e4_001 = ta.ema(T3e3_001, maLength_001)
T3e5_001 = ta.ema(T3e4_001, maLength_001)
T3e6_001 = ta.ema(T3e5_001, maLength_001)
T3c1_001 = -T3a1_001 * T3a1_001 * T3a1_001
T3c2_001 = 3 * T3a1_001 * T3a1_001 + 3 * T3a1_001 * T3a1_001 * T3a1_001
T3c3_001 = -6 * T3a1_001 * T3a1_001 - 3 * T3a1_001 - 3 * T3a1_001 * T3a1_001 * T3a1_001
T3c4_001 = 1 + 3 * T3a1_001 + T3a1_001 * T3a1_001 * T3a1_001 + 3 * T3a1_001 * T3a1_001
TILLSONT3_001 = T3c1_001 * T3e6_001 + T3c2_001 * T3e5_001 + T3c3_001 * T3e4_001 + T3c4_001 * T3e3_001
TILLSONT3_001
VAR_001 := if maType_001=="VAR"
Var_Func_001(maSrc_001, maLength_001)
//WWMA : Welles Wilder's Moving Average
WWMA_001 := if maType_001=="WWMA"
wwalpha_001 = 1 / maLength_001
WWMA_001calc = 0.0
WWMA_001calc := wwalpha_001 * maSrc_001 + (1 - wwalpha_001) * nz(WWMA_001calc[1])
WWMA_001calc
//Koufman MA Adaptive
nAMA_001 := if maType_001=="KAMA"
xPrice_001 = maSrc_001
xvnoise_001 = math.abs(xPrice_001 - xPrice_001[1])
nAMAcalc_001 = 0.0
nfastend_001 = 0.666
nslowend_001 = 0.0645
nsignal_001 = math.abs(xPrice_001 - xPrice_001[maLength_001])
nnoise_001 = math.sum(xvnoise_001, maLength_001)
nefratio_001 = nnoise_001 != 0 ? nsignal_001 / nnoise_001 : 0
nsmooth_001 = math.pow(nefratio_001 * (nfastend_001 - nslowend_001) + nslowend_001, 2)
nAMAcalc_001 := nz(nAMAcalc_001[1]) + nsmooth_001 * (xPrice_001 - nz(nAMAcalc_001[1]))
nAMAcalc_001
float ma001_001 = if not maType_001check
switch maType_001
"NONE" => na
"EMA" => ta.ema(maSrc_001, maLength_001)
"SMA" => ta.sma(maSrc_001, maLength_001)
"HMA" => ta.hma(maSrc_001, maLength_001)
"ALMA"=> ta.alma(maSrc_001, maWindowSizeALMA_001, maALMAoffset_001, maALMAsigma_001)
"WMA" => ta.wma(maSrc_001, maLength_001)
"VWMA" => ta.vwma(maSrc_001, maLength_001)
"VWAP" => ta.vwap(maSrc_001)
"DEMA" => 2 * (ta.ema(maSrc_001, maLength_001)) - ta.ema(ta.ema(maSrc_001, maLength_001), maLength_001)
"TEMA" => (3 * (ta.ema(maSrc_001, maLength_001) - ta.ema(ta.ema(maSrc_001, maLength_001), maLength_001))) + ta.ema(ta.ema(ta.ema(maSrc_001, maLength_001), maLength_001), maLength_001)
"KAMA"=> nAMA_001
"LSMA"=> ta.linreg(maSrc_001, maLength_001, 0)
"RMA" => ta.rma(maSrc_001, maLength_001)
"SWMA" => ta.swma(maSrc_001)
"TMA" => ta.sma(ta.sma(maSrc_001, math.ceil(maLength_001 / 2)), math.floor(maLength_001 / 2) + 1)
"WWMA" => WWMA_001
"ZLEMA" => ZLEMA_001
"Tillson" => TILLSONT3_001out
"VAR" => VAR_001
=>
runtime.error("No matching MA type found.")
float(na)
ma_001style = (maType_001=="VWMA") ? plot.style_cross : (maType_001=="VWAP") ? plot.style_circles : plot.style_line
ma001_001color = ma001_001>=0 ? color.blue : color.yellow
plot(showMa001_001 == true ? ma001_001 : na, color=ma001_001color, linewidth=2, title="OI Delta MA", style= ma_001style)
//=======================================================================================================================
//=======================================================================================================================
|
speed pump | https://www.tradingview.com/script/pjosqykO/ | ilyassamialp | https://www.tradingview.com/u/ilyassamialp/ | 34 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ilyassamialp
// amaç= hacim ve fiyat hareketliliklerini tespit ederek al sinyali oluşturmak. açıklam; hacim ve fiyatta geçmiş mum ortalamalarını tespit ederek aktif mumda hedef yüzdeye ulaşınca sinyal vermeli
//@version=5
indicator(title="speed pump",overlay=true)
// girdiler
hacimcarpani= input.int(2,minval=1,step=1,title="hacim x")
fiyatyuzdesi= input.float(1.05,minval=1.001,step=0.001,title="fiyat %")
ortalamafiyatsapmasi= input.float(1.02,minval=1.001,step=0.001,title="ort fiyat sapması %")
rsi7= input.int(30,minval=30,step=1,title="rsi 7")
rsi14= input.int(30,minval=30,step=1,title="rsi 14")
cmf20= input.float(0.01,minval=0.01,step=0.01,title="cmf 20")
// değerler
oh= math.avg(volume[1],volume[2],volume[3],volume[4],volume[5],volume[6],volume[7],volume[8],volume[9],volume[10])//,volume[11],volume[12],volume[13],volume[14],volume[15],volume[16],volume[17],volume[18],volume[19],volume[20],volume[21],volume[22])
of= math.avg(close[1],close[2],close[3],close[4],close[5],close[6],close[7],close[8],close[9],close[10])//,close[11],close[12],close[13],close[14],close[15],close[16],close[17],close[18],close[19],close[20],close[21],close[22],close[23],close[24],close[25],close[26])
// sonuçlar
hacimx = oh * hacimcarpani
fiyatx = of * fiyatyuzdesi
ofs= of * ortalamafiyatsapmasi
//////////////////////////////////////
//Chaikin Money Flow (CMF) indikatörü
var cumVol = 0.
cumVol += nz(volume)
if barstate.islast and cumVol == 0
runtime.error("No volume is provided by the data vendor.")
ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume
mf = math.sum(ad,20) / math.sum(volume,20)
/////////////////////////////////////
// koşul
ivmeleme = volume >= hacimx and close >= fiyatx and ta.rsi(close,7) >= rsi7 and ta.rsi(close,14) >= rsi14 and mf >= cmf20 and open <= ofs
// gösterge
plotshape(ivmeleme,title="BUY - AL",text="ivme",textcolor=color.white,style=shape.labelup,size=size.normal,location=location.belowbar,color=color.green)
// alarm
alertcondition(ivmeleme, title='BUY - AL', message='')
//plot(oh,color=color.purple)
plot(of,color=color.silver)
|
Financials Info by zdmre | https://www.tradingview.com/script/RIiBJb14-Financials-Info-by-zdmre/ | zdmre | https://www.tradingview.com/u/zdmre/ | 82 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zdmre
//@version=5
indicator('Financials Info by zdmre', overlay = true, format=format.volume)
period = input.string('FY', 'Period', options=['FQ', 'FY'], tooltip='FQ: Financial Quarter\nFY: Financial Year')
opt_textsize = input.string(size.small, 'Text Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group='table')
opt_textcolor = input(color.white, "Text Color", tooltip='Title')
opt_datatextcolor = input(color.black, "Text Color", tooltip='Data')
opt_panelbgcolor = input(color.gray, "Background Color", tooltip='Panel')
is_opt_pos = input.string(position.top_right, 'Table \nPosition\n #1', options= [position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right], group='table')
is_info = input(true, "Show Status Column")
//Filtering
colorGroup = 'Filtering Data by Color'
opval = input.float(10, title = 'Operating Margin %', group=colorGroup, tooltip='Operating Margin value & EPS Estimated - Income Statement - Table 1.\n\nIIf Opmar > value, cell to green; else cell to red\ndefval=10')
epsval = input.float(0, title = 'EPS', group=colorGroup, tooltip='Earning per Share value & EPS Estimated - Income Statement - Table 1.\n\nIIf EPS > value, cell to green; else cell to red\ndefval=0')
peval = input.float(15, title = 'P/E', group=colorGroup, tooltip='Price to Earnings Ratio value (FY) - Income Statement - Table 1.\n\nIIf 0 < P/E < value, cell to green; else cell to red \ndefval=15')
deval = input.float(0.5, title = 'D/E', group=colorGroup, tooltip='Debt/Equity Ratio value - Balance Sheet - Table 2.\n\nIIf D/E < value, cell to green; else cell to red \ndefval=0.5')
pbval = input.float(3, title = 'P/B', group=colorGroup, tooltip='Price to Book Value - Balance Sheet -Table 2.\n\nIIf 0 < P/B < value, cell to green; else cell to red \ndefval=3 ')
roeval = input.float(10, title = 'ROE', group=colorGroup, tooltip='Return on Equity value - Statistics - Table 3.\n\nIIf ROE > value, cell to green; else cell to red \ndefval=10 ')
roepbval = input.float(3, title = 'ROE/PB', group=colorGroup, tooltip='Return on Equity / Price to Book Ratio - Balance Sheet -Table 2.\n\nIIf ROE/PB > value, cell to green; else cell to red \ndefval=3 ')
roaval = input.float(5, title = 'ROA', group=colorGroup, tooltip='Return on Asset value - Statistics - Table 3.\n\nIIf ROA > value, cell to green; else cell to red \ndefval=5')
roicval = input.float(7, title = 'ROIC', group=colorGroup, tooltip='Return on Investment Capital value - Statistics - Table 3.\n\nIIf ROIC > value, cell to green; else cell to red \ndefval=7')
dyieldval = input.float(2, title = 'Dividend Yield', group=colorGroup, tooltip='Dividend Yield - Statistics - Table 4.\n\nIf Dividend Yield < value, cell to red; else cell to green\ndefval=2')
dpayoutval = input.float(70, title = 'Dividend Payout', group=colorGroup, tooltip='Dividend Payout - Statistics - Table 4.\n\nIf Dividend Payout < value, cell to red; else cell to green\ndefval=70')
// Financial Data
opmar = request.financial(syminfo.tickerid, 'OPERATING_MARGIN', period)
eps = request.financial(syminfo.tickerid, "EARNINGS_PER_SHARE_BASIC", period)
pear = close/request.financial(syminfo.tickerid,'EARNINGS_PER_SHARE_BASIC', "TTM")
epsest = request.financial(syminfo.tickerid,'EARNINGS_ESTIMATE', period)
pb = close / request.financial(syminfo.tickerid,'BOOK_VALUE_PER_SHARE', period) // bs05
de = request.financial(syminfo.tickerid,'DEBT_TO_EQUITY', period)
roe = request.financial(syminfo.tickerid,'RETURN_ON_EQUITY', period)
roepb = request.financial(syminfo.tickerid,'RETURN_ON_EQUITY_ADJUST_TO_BOOK', period)
roa = request.financial(syminfo.tickerid,'RETURN_ON_ASSETS', period)
qr = request.financial(syminfo.tickerid,'QUICK_RATIO', period)
roic = request.financial(syminfo.tickerid,'RETURN_ON_INVESTED_CAPITAL', period)
dpayout = request.financial(syminfo.tickerid,'DIVIDEND_PAYOUT_RATIO', period)
dyield = request.financial(syminfo.tickerid,'DIVIDENDS_YIELD', period)
fscore = request.financial(syminfo.tickerid,'PIOTROSKI_F_SCORE',period)
// Specials
specrate = 0.8 // Special Calc Rate
discount = 0.09 // Discount Rate
n_year = 5 // Discount Year
DPS = request.financial(syminfo.tickerid, "DPS_COMMON_STOCK_PRIM_ISSUE", "FY")
BVPS = request.financial(syminfo.tickerid, "BOOK_VALUE_PER_SHARE", "FY")
EPS = request.financial(syminfo.tickerid, 'EARNINGS_PER_SHARE', 'FY')
PE = close/request.financial(syminfo.tickerid, 'EARNINGS_PER_SHARE', 'TTM')
AVG_PE = request.security(syminfo.tickerid, '3M', ta.sma(PE, 4))
SGR = request.financial(syminfo.tickerid, 'SUSTAINABLE_GROWTH_RATE', "FY")
M0 = request.security("USM0", "M", close)
M2 = request.security("USM2", "M", close)
//Calculations
rate = 1 + (math.abs(SGR) / 100)
eps_mult = EPS * specrate
MS = (M2/M0)*1
value_in_n_years = eps_mult * math.pow(specrate, n_year) * AVG_PE
valueh = value_in_n_years / math.pow(1 + discount, n_year)
iv = valueh < 0 ? (math.abs(value_in_n_years) + valueh) * MS : valueh * MS
bdip = iv[1] / rate
ivrate = close/iv[1] -1
ivstatus = close < bdip ? "Very Undervalued" : close < iv[1] ? "Undervalued" : iv[1] < close and iv[1]*1.5 > close ? "Neutral" : iv[1]*1.5 < close and iv[1]*2 > close ? "Overvalued" : "Very Overvalued"
// Table
var tbis = table.new(is_opt_pos, 3, 21, frame_color=color.black, frame_width=0, border_width=0, border_color=color.black)
if barstate.islast
// Title
table.cell(tbis, 0, 0, 'FINANCIAL', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 1, 0, '', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 1, 'Operating\nMargin %', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 2, 'EPS', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 3, 'EPS Estimate', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 4, 'P/E', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 5, '', bgcolor = color.new(color.black,100))
table.cell(tbis, 0, 6, 'BALANCE SHEET', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 1, 6, '', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 7, 'P/B', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 8, 'D/E', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 9, '', bgcolor = color.new(color.black,100))
table.cell(tbis, 0, 10, 'STATISTICS', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 1, 10, '', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 11, 'ROE', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 12, 'ROE/PB', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 13, 'ROA', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 14, 'ROIC', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 15, 'Div Yield', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 16, 'Div Payout', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 17, 'F-Score', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 18, 'SGR', bgcolor = opt_panelbgcolor, text_size=opt_textsize, text_color=opt_textcolor)
table.cell(tbis, 0, 19, '', bgcolor = color.new(color.black,100))
table.cell(tbis, 0, 20, 'INTRINSIC VALUE', bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor)
// Data
table.cell(tbis, 1, 1, str.tostring(opmar, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=opmar <= opval or opmar < 0 ? #FF6961 : color.lime) // Operating Margin
table.cell(tbis, 1, 2, str.tostring(eps, '#,##0.00'), text_size=opt_textsize, text_color=color.black, bgcolor=eps <= epsval or eps < 0 ? #FF6961 : color.lime) // EPS
table.cell(tbis, 1, 3, str.tostring(epsest, '#,##0.00'), text_size=opt_textsize, text_color=color.black, bgcolor=epsest <= epsval or epsest < 0 ? #FF6961 : epsest >= 0 ? color.lime : color.white) // EPS
table.cell(tbis, 1, 4, str.tostring(pear, '#,##0.00'), text_size=opt_textsize, text_color=color.black, bgcolor=math.abs(pear) >= peval ? #FF6961 : color.lime) // P/E
table.cell(tbis, 1, 7, str.tostring(pb, '#,##0.00'), text_size=opt_textsize, text_color=color.black, bgcolor=pb >= pbval or pb < 0 ? #FF6961 : color.lime) // P/B
table.cell(tbis, 1, 8, str.tostring(de, '#,##0.00'), text_size=opt_textsize, text_color=color.black, bgcolor=de >= deval or de < 0 ? #FF6961 : color.lime) // D/E
table.cell(tbis, 1, 11, str.tostring(roe, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=roe <= roeval ? #FF6961 : color.lime) // ROE
table.cell(tbis, 1, 12, str.tostring(roepb, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=roe <= roepbval ? #FF6961 : color.lime) // ROEPB
table.cell(tbis, 1, 13, str.tostring(roa, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=roa <= roaval ? #FF6961 : color.lime) // ROA
table.cell(tbis, 1, 14, str.tostring(roic, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=roic <= roicval ? #FF6961 : color.lime) // ROIC
table.cell(tbis, 1, 15, str.tostring(dyield, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=dyield == 0 ? color.white : dyield <= dyieldval ? #FF6961 : color.lime) // DYield
table.cell(tbis, 1, 16, str.tostring(dpayout, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor=dpayout == 0 ? color.white : dpayout >= dpayoutval ? #FF6961 : color.lime) // DPayout
table.cell(tbis, 1, 17, str.tostring(fscore, '#,##0'), text_size=opt_textsize, text_color=color.black, bgcolor=fscore <= 0 ? #c0392b : fscore <= 1 ? #ec7063 : fscore <= 2 ? #e67e22 : fscore <= 3 ? #fad7a0 : fscore <= 4 ? #85c1e9 : fscore <= 5 ? #a9cce3 : fscore <= 6 ? #a9dfbf : fscore <= 7 ? #7dcea0 : fscore <= 8 ? #52be80 : color.lime) // DPayout
table.cell(tbis, 1, 18, str.tostring(SGR, '#,##0.00')+'%', text_size=opt_textsize, text_color=color.black, bgcolor= SGR > 30 ? #52be80 : SGR > 10 ? color.orange : color.lime) // SGR
table.cell(tbis, 1, 19, '', bgcolor = color.new(color.black,100))
table.cell(tbis, 1, 20, str.tostring(iv[1],'$#,##0.00'), text_size=opt_textsize, text_color=color.black, bgcolor=ivrate >= 0.3 ? #FF6961 : color.lime ) // PB
if is_info
c1 = #009d0c
c2 = color.lime
c3 = color.gray
c4 = #f9aeae
c5 = #f60000
c6 = color.white
opcolor = opmar >= 30 ? c1 : opmar >= 10 ? c2 : opmar > 0 ? c3 : c4
epscolor = eps >= 10 ? c1 : eps >= 3 ? c2 : eps >= 3 ? c3 : eps >= -1 ? c4 : c5
epsestcolor = epsest >= 10 ? c1 : epsest >= 3 ? c2 : epsest >= 0 ? c3 : epsest >= -1 ? c4 : epsest < -1 ? c5 : c6
pearcolor = math.abs(pear) <= 5 ? c1 : math.abs(pear) <= 10 ? c2: math.abs(pear) <= 15 ? c3 : math.abs(pear) <= 25 ? c4 :c5
pbcolor = math.abs(pb) <= 2 ? c1 : math.abs(pb) <= 3 ? c2 : math.abs(pb) <= 7 ? c3 : math.abs(pb) <= 10 ? c4 :c5
decolor = math.abs(de) <= 0.1 ? c1 : math.abs(de) <= 0.5 ? c2 : math.abs(de) <= 1 ? c3 : math.abs(de) <= 2 ? c4 :c5
roecolor = roe >= 30 ? c1 : roe >= 15 ? c2 : roe >= 0 ? c3 : roe >= -3 ? c4 :c5
roepbcolor = roepb >= 15 ? c1 : roepb >= 5 ? c2 : roepb >= 0 ? c3 : roepb >= -10 ? c4 :c5
roacolor = roa >= 20 ? c1 : roa >= 10 ? c2 : roa >= 0 ? c3 : roa >= -7 ? c4 :c5
roiccolor = roic >= 25 ? c1 : roic >= 12 ? c2 : roic >= 0 ? c3 : roic >= - 5 ? c4 :c5
dyieldcolor = dyield == 0 ? c6 : dyield >= 0.5 ? c4 : dyield >= 2 ? c3 : dyield >= 4 ? c2 : dyield >= 8 ? c1 : c5
dpayoutcolor = dpayout <= 10 and dpayout > 0 ? c1 : dpayout > 10 and dpayout <= 30 ? c2 : dpayout > 30 and dpayout <= 50 ? c3 : dpayout > 50 and dpayout <= 70 ? c4 : dpayout == 0 ? c6 : c5
fscorecolor = fscore <= 0 ? #c0392b : fscore <= 1 ? #ec7063 : fscore <= 2 ? #e67e22 : fscore <= 3 ? #fad7a0 : fscore <= 4 ? #85c1e9 : fscore <= 5 ? #a9cce3 : fscore <= 6 ? #a9dfbf : fscore <= 7 ? #7dcea0 : fscore <= 8 ? #52be80 : color.lime
sgrcolor = SGR >= 70 ? c1 : SGR >= 40 ? c2 : SGR >= 25 ? c3 : SGR >= 5 ? c4 :c5
ivcolor = close < bdip ? c1 : close < iv[1] ? c2 : iv[1] < close and iv[1] < close and iv[1]*1.5 > close ? c3 : iv[1]*1.5 < close and iv[1]*2 > close ? c4 : c5
table.cell(tbis, 2, 0, str.tostring("STATUS"), bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor) //
table.cell(tbis, 2, 6, str.tostring("STATUS"), bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor) //
table.cell(tbis, 2, 10, str.tostring("STATUS"), bgcolor = color.blue, text_size=opt_textsize, text_color=opt_textcolor) //
table.cell(tbis, 2, 1, str.tostring(opmar >= 30 ? "Very Strong" : opmar >= 10 ? "Strong" : opmar >= 0 ? "Neutral" : "Weak"), text_size=opt_textsize, text_color=color.black, bgcolor=opcolor)
table.cell(tbis, 2, 2, str.tostring(eps >= 10 ? "Very Strong" : eps >= 3 ? "Strong" : eps >= 0 ? "Neutral" : eps >= -1 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=epscolor) //
table.cell(tbis, 2, 3, str.tostring(epsest >= 10 ? "Very Strong" : epsest >= 3 ? "Strong" : epsest >= 0 ? "Neutral" : epsest >= -1 ? "Weak" : epsest < -1 ? "Terrible" : "None"), text_size=opt_textsize, text_color=color.black, bgcolor=epsestcolor) //
table.cell(tbis, 2, 4, str.tostring(math.abs(pear) <= 5 ? "Very Undervalued" : math.abs(pear) <= 10 ? "Undervalued" : math.abs(pear) <= 15 ? "Neutral" : math.abs(pear) <= 25 ? "Overvalued" : "Very Overvalued"), text_size=opt_textsize, text_color=color.black, bgcolor=pearcolor) // P/E
table.cell(tbis, 2, 7, str.tostring(pb < 0 ? "Very Overvalued" : math.abs(pb) <= 2 ? "Very Undervalued" : math.abs(pb) <= 3 ? "Undervalued" : math.abs(pb) <= 7 ? "Neutral" : math.abs(pb) <= 10 ? "Overvalued" : "Very Overvalued"), text_size=opt_textsize, text_color=color.black, bgcolor=pbcolor) // PB
table.cell(tbis, 2, 8, str.tostring(de < 0 ? "Terrible" : math.abs(de) <= 0.1 ? "Very Strong" : math.abs(de) <= 0.5 ? "Strong" : math.abs(de) <= 1 ? "Neutral" : math.abs(de) <= 2 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=decolor ) //
table.cell(tbis, 2, 11, str.tostring(roe >= 30 ? "Very Strong" : roe >= 15 ? "Strong" : roe >= 0 ? "Neutral" : roe >= -3 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=roecolor ) //
table.cell(tbis, 2, 12, str.tostring(roepb >= 15 ? "Very Strong" : roepb >= 5 ? "Strong" : roepb >= 0 ? "Neutral" : roepb >= -10 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=roepbcolor ) //
table.cell(tbis, 2, 13, str.tostring(roa >= 20 ? "Very Strong" : roa >= 10 ? "Strong" : roa >= 0 ? "Neutral" : roa >= -7 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=roacolor ) //
table.cell(tbis, 2, 14, str.tostring(roic >= 25 ? "Very Strong" : roic >= 12 ? "Strong" : roic >= 0 ? "Neutral" : roic >= - 5 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=roiccolor ) //
table.cell(tbis, 2, 15, str.tostring(dyield >= 8 ? "Very High" : dyield >= 4 ? "High" : dyield >= 2 ? "Neutral" : dyield >= 0.5 ? "Low" : dyield == 0 ? "None" : "Very Low"), text_size=opt_textsize, text_color=color.black, bgcolor=dyieldcolor ) //
table.cell(tbis, 2, 16, str.tostring(dpayout <= 10 and dpayout > 0 ? "Very High Int" : dpayout > 10 and dpayout <= 30 ? "High Int" : dpayout > 30 and dpayout <= 50 ? "Neutral" : dpayout > 50 and dpayout <= 70 ? "Weak Int" : dpayout == 0 ? "None" : "Terrible Int"), text_size=opt_textsize, text_color=color.black, bgcolor=dpayoutcolor ) //
table.cell(tbis, 2, 17, str.tostring(fscore >= 9 ? "Very Strong" : fscore >= 7 ? "Strong" : fscore >= 5 ? "Neutral" : fscore >= 3 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=fscorecolor ) //
table.cell(tbis, 2, 18, str.tostring(SGR >= 50 ? "Very High" : SGR >= 30 ? "High" : SGR >= 10 ? "Neutral" : SGR >= 5 ? "Weak" : "Terrible"), text_size=opt_textsize, text_color=color.black, bgcolor=sgrcolor ) //
table.cell(tbis, 2, 19, '', bgcolor = color.new(color.black,100))
table.cell(tbis, 2, 20, str.tostring(ivstatus), text_size=opt_textsize, text_color=color.black, bgcolor=ivcolor) // IV
|
DW-MTF-Close Price(1W/3D) as Support Line | https://www.tradingview.com/script/a2KcxO6F-DW-MTF-Close-Price-1W-3D-as-Support-Line/ | techno_junkie | https://www.tradingview.com/u/techno_junkie/ | 19 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © techno_junkie
//@version=5
indicator("DW-MTF-Close Price as Support", overlay=true)
//TIMEFRAMES
//Specials
res_1 = input.timeframe(title='---- Time Frame 1 CLOSE -----', inline="Res 1 Active", defval='3D')
res_1_yn = input(title='Active', defval=true, inline="Res 1 Active")
res_2 = input.timeframe(title='---- Time Frame 2 CLOSE ----', defval='1W',inline="Res 2 Active")
res_2_yn = input(title='Active', defval=false, inline="Res 2 Active")
//plotting and avoid repaint
NoRepaintingSecurity(sym, tf, src) =>
request.security(sym, tf, src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]
res_1_close = NoRepaintingSecurity(syminfo.tickerid, res_1, close)
//plot(nonRepaintingClose, "Non-repainting close", color.fuchsia, 3)
res_2_close = NoRepaintingSecurity(syminfo.tickerid, res_2, close)
plot(res_1_yn ? res_1_close : na, title='Res 1 Close', color=color.new(color.black, 0), style=plot.style_stepline)
plot(res_2_yn ? res_2_close : na, title='Res 2 Close', color=color.new(color.red, 0), style=plot.style_stepline)
|
Highlight Deduction | https://www.tradingview.com/script/dxvXGe8x-Highlight-Deduction/ | EddisonShyi | https://www.tradingview.com/u/EddisonShyi/ | 9 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EddisonShyi
// Highlight deduction OHLC bar(and adjacent bars), and draw price line of it. This will make us easier to observe SMA direction.
//@version=5
indicator("Highlight Deduction", overlay=true)
int fast_ma = input(title="Fast SMA", defval=24)
int slow_ma = input(title="Slow SMA", defval=60)
int deduction_highlight_width = input(title="Highlight Width", defval=5)
string chart_period = timeframe.period
int next_fast_ma = switch chart_period
// Edit below area if you need
"1" => 5*fast_ma
"5" => 6*fast_ma
"30" => 4*fast_ma
"120" => 12*fast_ma
"D" => 5*fast_ma
"W" => 5*fast_ma
=>
runtime.error("Undefined Period")
int(na)
// Edit above area if you need
fast_deduction_from = last_bar_index - fast_ma + 1
fast_deduction_to = last_bar_index - fast_ma + deduction_highlight_width + 1
slow_deduction_from = last_bar_index - slow_ma + 1
slow_deduction_to = last_bar_index - slow_ma + deduction_highlight_width + 1
next_fast_deduction_from = last_bar_index - next_fast_ma + 1
next_fast_deduction_to = last_bar_index - next_fast_ma + deduction_highlight_width + 1
var fast_ma_deduction = line.new(fast_deduction_from, close[fast_ma], last_bar_index, close[fast_ma], extend=extend.right, style=line.style_dotted, color=color.rgb(82, 252, 108, 25))
if bar_index > fast_deduction_from
line.set_xy1(fast_ma_deduction, fast_deduction_from, close[fast_ma])
line.set_xy2(fast_ma_deduction, last_bar_index, close[fast_ma])
var slow_ma_deduction = line.new(slow_deduction_from, close[slow_ma], last_bar_index, close[slow_ma], extend=extend.right, style=line.style_dotted, color=color.rgb(252, 252, 82, 25))
if bar_index > slow_deduction_from
line.set_xy1(slow_ma_deduction, slow_deduction_from, close[slow_ma])
line.set_xy2(slow_ma_deduction, last_bar_index, close[slow_ma])
var next_fast_ma_deduction = line.new(next_fast_deduction_from, close[next_fast_ma], last_bar_index, close[next_fast_ma], extend=extend.right, style=line.style_dotted, color=color.rgb(236, 80, 80, 25))
if bar_index > next_fast_deduction_from
line.set_xy1(next_fast_ma_deduction, next_fast_deduction_from, close[next_fast_ma])
line.set_xy2(next_fast_ma_deduction, last_bar_index, close[next_fast_ma])
plot(ta.sma(close, fast_ma), title="FastMA", color=color.lime)
plot(ta.sma(close, slow_ma), title="SlowMA", color=color.yellow)
plot(ta.sma(close, next_fast_ma), title="NFastMA", color=color.red)
bgcolor(bar_index >= fast_deduction_from and bar_index < fast_deduction_to ? color.rgb(82, 252, 108, 80): na, title="FastMADeduction")
bgcolor(bar_index >= slow_deduction_from and bar_index < slow_deduction_to ? color.rgb(252, 252, 82, 80): na, title="SlowMADeduction")
bgcolor(bar_index >= next_fast_deduction_from and bar_index < next_fast_deduction_to ? color.rgb(255, 65, 65, 80): na, title="NextFastMADeduction") |
Simple Bollinger Band Width Percentile | https://www.tradingview.com/script/Rmw1hl3z-Simple-Bollinger-Band-Width-Percentile/ | EltAlt | https://www.tradingview.com/u/EltAlt/ | 75 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EltAlt
//@version=5
// I'm a big fan of The_Caretaker's BBWP and wanted to add it as a volatility indicator to some of my scripts, but since it is over
// 100 lines of code (plus spacing and comments) I wanted to find if there was a simpler way to get comparable results. SBBWP uses Pine 5
// built in functions that I don't believe were available when The_Caretaker wrote BBPW. The main limitations compared to The_Caretaker's
// version is that it can only use SMA as its Basis Type and the colors are also not as pretty. I have not included alerts or scale lines
// since I'm not trying to replace BBWP, just give a simple example that you can easily build in to your scripts.
// Full credit and respect to The_Caretaker!
indicator('Simple Bollinger Band Width Percentile', 'SBBWP', overlay=false, format=format.percent, precision=2, max_bars_back = 1000)
i_priceSrc = input.source ( close, 'Price Source', inline='1', group='BBWP Properties')
i_bbwpLen = input.int ( 13, 'Length', minval=1, inline='2', group='BBWP Properties')
i_bbwpLkbk = input.int ( 252, ' Lookback', minval=1, inline='2', group='BBWP Properties')
i_ma1On = input.bool ( true, '', inline='3', group='BBWP Properties')
i_ma1Type = input.string ( 'SMA', 'BBWP MA Type', options=['SMA', 'EMA', 'VWMA'], inline='3', group='BBWP Properties')
i_ma1Len = input.int ( 5, 'Length', minval=1, inline='3', group='BBWP Properties')
bbwp = ta.percentrank(ta.bbw(i_priceSrc, i_bbwpLen, 1), i_bbwpLkbk)
c_bbwp = bbwp >= 50 ? color.from_gradient(bbwp, 50, 100, #0AFF00, #FF2900): color.from_gradient(bbwp, 0, 49, #0000FF, #0AFF00)
bbwpMA1 = i_ma1On ? i_ma1Type == 'VWMA' ? ta.vwma ( bbwp, i_ma1Len ) : i_ma1Type == 'EMA' ? ta.ema ( bbwp, i_ma1Len ) : ta.sma ( bbwp, i_ma1Len ) : na
p_bbwp = plot ( bbwp, 'BBWP', c_bbwp, 2, plot.style_line, editable=false )
p_ma1 = plot ( bbwpMA1, 'BBWP MA', #FFFFFF, 1, plot.style_line, 0 ) |
Multiple RSI Strategies [MoonKoder] | https://www.tradingview.com/script/RA001COe-Multiple-RSI-Strategies-MoonKoder/ | MoonKoder | https://www.tradingview.com/u/MoonKoder/ | 17 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MoonKoder
//@version=5
indicator("Multiple RSI Strategies [MoonKoder]", overlay = false)
// ==============================================
// == GET USER GENERAL SETTINGS ==
// ==============================================
// {
// ToolTips Strings to Help User
ToolTip0_Str = "Choose The Strategy to Detect Signals \n\n"
ToolTip1_Str = "01 - Traditional: \nActivates signal when crosses the Strat5_OverBought or the Strat5_OverSold limits \n\n"
ToolTip2_Str = "02 - MidLevel Cross: \nActivates signal when crosses the 50 line \n"
ToolTip3_Str = "03 - Histogram: \nActivates signal when histogram crosses the 0 line \n\n"
ToolTip4_Str = "04 - Moving Average Cross: \nActivates signal when crosses the Moving Average \n\n"
ToolTip5_Str = "05 - Divergence: \nActivates signal when a divergence is found between Price Action and Rsi\n\n"
ToolTip6_Str = "06 - Multi Rsi: \nActivates signal when there's a cross from both Rsi's"
ToolTip_Str = ToolTip0_Str + ToolTip1_Str + ToolTip2_Str + ToolTip3_Str + ToolTip4_Str + ToolTip5_Str
ToolTip_Alert = "Check if you want Alerts Activated"
// Title of Window
gr_General_Str = "GENERAL SETTINGS"
// Get General User Inputs
StrategyChoose = input.string(title = "Strategy to Use", defval = "01 - Traditional",
options = ["01 - Traditional", "02 - MidLevel Cross", "03 - Histogram", "04 - Moving Average Cross", "05 - Divergence", "06 - Multi Rsi"],
group = gr_General_Str, tooltip = ToolTip_Str)
UseAlerts = input.bool(title = "Use Alerts", defval = true, group = gr_General_Str, tooltip = ToolTip_Alert)
// }
// ==============================================
// == IMPORTANT CALCS ==
// ==============================================
// {
// Function to Determine Rsi Value
Function_Rsi(_Source, _Period) =>
Rsi = ta.rsi(_Source, _Period)
// Get Heikin-Ashi Values
HeikinAshi_Open = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
HeikinAshi_High = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
HeikinAshi_Low = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
HeikinAshi_Close = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
// Function to Determine Source
Function_SourceChange(_Source) =>
SourceType = _Source == "01 - Standard Open" ? open :
_Source == "02 - Standard High" ? high :
_Source == "03 - Standard Low" ? low :
_Source == "04 - Standard Close" ? close :
_Source == "05 - Standard HLC3" ? hlc3 :
_Source == "06 - Standard HL2" ? hl2 :
_Source == "07 - Heikin Ashi Open" ? HeikinAshi_Open :
_Source == "08 - Heikin Ashi High" ? HeikinAshi_High :
_Source == "09 - Heikin Ashi Low" ? HeikinAshi_Low :
_Source == "10 - Heikin Ashi Close" ? HeikinAshi_Close : na
// Define Bullish and Bearish Signals for Alerts
bool BuySignal = na
bool SellSignal = na
// General Function to Calculate Moving Average
Function_MovAvg(_Source, _Period, _Smoothing) =>
MovAvg = switch _Smoothing
"EMA" =>
ta.ema(_Source, _Period)
"RMA" =>
ta.rma(_Source, _Period)
"SMA" =>
ta.sma(_Source, _Period)
"WMA" =>
ta.wma(_Source, _Period)
"HMA" =>
ta.hma(_Source, _Period)
// }
// ==============================================
// == OPTION 1 ==
// ==============================================
// {
// ToolTips Strings to Help User
ToolTip_Op1_Period = "Period: \nPeriod Value to Rsi Study \n\n"
ToolTip_Op1_Source = "Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op1_OS = "Strat5_OverSold Level: \nChoose the Level for Strat5_OverSold Position \n\n"
ToolTip_Op1_OB = "Strat5_OverBought Level: \nChoose the Level for Strat5_OverBought Position \n\n"
ToolTip_Op1_TimeFrame = "TimeFrame: \nChoose the TimeFrame you want to study\n\n"
ToolTip_Op1_ClrChange = "Color Change: \nCheck if you want to change to change the colour on limit Over areas"
// Title of Window
gr_Option1 = "01 - TRADITIONAL"
// Get General User Inputs
Strat1_Period = input.int(title = "Period", defval = 14, minval = 0, step = 1, group = gr_Option1, tooltip = ToolTip_Op1_Period)
Strat1_Source = input.string(title = "Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], group = gr_Option1, tooltip = ToolTip_Op1_Source)
Strat1_OverS = input.float(title = "Strat5_OverSold Level", defval = 30, minval = 0, maxval = 50, step = 1, group = gr_Option1, tooltip = ToolTip_Op1_OS)
Strat1_OverB = input.float(title = "Strat5_OverBought Level", defval = 70, minval = 50, maxval = 100, step = 1, group = gr_Option1, tooltip = ToolTip_Op1_OB)
Strat1_TimeF = input.timeframe(title = "TimeFrame", defval = "15", group = gr_Option1, tooltip = ToolTip_Op1_TimeFrame)
Strat1_ClrTrd = input.bool(title = "Color Change", defval = true, group = gr_Option1, tooltip = ToolTip_Op1_ClrChange)
// Calculate [Option 1] RSI
Strat1_Rsi = request.security(syminfo.tickerid, Strat1_TimeF, Function_Rsi(Function_SourceChange(Strat1_Source), Strat1_Period))
Strat1_Color = ((Strat1_Rsi < Strat1_OverS) and Strat1_ClrTrd) ? color.teal : ((Strat1_Rsi > Strat1_OverB) and Strat1_ClrTrd) ? color.red : color.yellow
// Preparing Plot for [Option 1]
Strat1_PrePlot_Rsi = StrategyChoose == "01 - Traditional" ? Strat1_Rsi : na
Strat1_PrePlot_OS = StrategyChoose == "01 - Traditional" ? Strat1_OverS : na
Strat1_PrePlot_OB = StrategyChoose == "01 - Traditional" ? Strat1_OverB : na
Strat1_PrePlot_Clr = StrategyChoose == "01 - Traditional" ? Strat1_Color : na
// Plot [Option 1] Results
Plot_Strat1Rsi = plot(Strat1_PrePlot_Rsi, color = Strat1_PrePlot_Clr, linewidth = 2)
Plot_StratOS = plot(Strat1_PrePlot_OS, color = color.black, linewidth = 1)
Plot_StratOB = plot(Strat1_PrePlot_OB, color = color.black, linewidth = 1)
// Set [Option 1] Signals for Alerts
BuySignal := ta.crossover(Strat1_Rsi, Strat1_OverS) and StrategyChoose == "01 - Traditional"
SellSignal := ta.crossunder(Strat1_Rsi, Strat1_OverB) and StrategyChoose == "01 - Traditional"
// }
// ==============================================
// == OPTION 2 ==
// ==============================================
// {
// ToolTips Strings to Help User
ToolTip_Op2_Period = "Period: \nPeriod Value to Rsi Study \n\n"
ToolTip_Op2_Source = "Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op2_TimeFrame = "TimeFrame: \nChoose the TimeFrame you want to study \n\n"
ToolTip_Op2_ClrChange = "Color Change: \nCheck if you want to change to change the colour on limit Over areas"
// Title of Window
gr_Option2 = "02 - MIDLEVEL CROSS"
// Get General User Inputs
Strat2_Period = input.int(title = "Period", defval = 14, minval = 0, step = 1, group = gr_Option2, tooltip = ToolTip_Op2_Period)
Strat2_Source = input.string(title = "Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], group = gr_Option2, tooltip = ToolTip_Op2_Source)
Strat2_TimeF = input.timeframe(title = "TimeFrame", defval = "15", group = gr_Option2, tooltip = ToolTip_Op2_TimeFrame)
Strat2_ClrTrd = input.bool(title = "Color Change", defval = true, group = gr_Option2, tooltip = ToolTip_Op2_ClrChange)
// Calculate [Option 2] RSI
Strat2_Rsi = request.security(syminfo.tickerid, Strat2_TimeF, Function_Rsi(Function_SourceChange(Strat2_Source), Strat2_Period))
Strat2_Color = ((Strat2_Rsi > 50) and Strat2_ClrTrd) ? color.teal : color.red
// Preparing Plot for [Option 2]
Strat2_PrePlot_Rsi = StrategyChoose == "02 - MidLevel Cross" ? Strat2_Rsi : na
Strat2_PrePlot_Clr = StrategyChoose == "02 - MidLevel Cross" ? Strat2_Color : na
Strat2_PrePlot_Mid = StrategyChoose == "02 - MidLevel Cross" ? 50 : na
// Plot [Option 2] Results
Plot_Strat2Rsi = plot(Strat2_PrePlot_Rsi, color = Strat2_PrePlot_Clr, linewidth = 2)
Plot_Strat2MidPoint = plot(Strat2_PrePlot_Mid, color = color.black, linewidth = 1)
// Set [Option 2] Signals for Alerts
BuySignal := ta.crossover(Strat2_Rsi, 50) and StrategyChoose == "02 - MidLevel Cross"
SellSignal := ta.crossunder(Strat2_Rsi, 50) and StrategyChoose == "02 - MidLevel Cross"
// }
// ==============================================
// == OPTION 3 ==
// ==============================================
// {
// ToolTips Strings to Help User
ToolTip_Op3_RsiPeriod = "RSI Period: \nRSI Period Value to Rsi Study \n\n"
ToolTip_Op3_FastPeriod = "Fast Period: \nFast Period Value to Rsi Study \n\n"
ToolTip_Op3_SlowPeriod = "Slow Period: \nSlow Period Value to Rsi Study \n\n"
ToolTip_Op3_SignPeriod = "Signal Period: \nSignal Period Value to Rsi Study \n\n"
ToolTip_Op3_Smooth = "Smooth: \nChoose the smooth value to the histogram calculation \n\n"
ToolTip_Op3_Source = "Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op3_TimeFrame = "TimeFrame: \nChoose the TimeFrame you want to study"
// Title of Window
gr_Option3 = "03 - HISTOGRAM"
// Get General User Inputs
Strat3_RsiPeriod = input.int(title = "RSI Period", defval = 14, minval = 0, step = 1, group = gr_Option3, tooltip = ToolTip_Op3_RsiPeriod)
Strat3_FastPeriod = input.int(title = "Fast Period", defval = 9, minval = 0, step = 1, group = gr_Option3, tooltip = ToolTip_Op3_FastPeriod)
Strat3_SlowPeriod = input.int(title = "Slow Period", defval = 14, minval = 0, step = 1, group = gr_Option3, tooltip = ToolTip_Op3_SlowPeriod)
Strat3_SignalPeriod = input.int(title = "Signal Period", defval = 9, minval = 0, step = 1, group = gr_Option3, tooltip = ToolTip_Op3_SignPeriod)
Strat3_Source = input.string(title = "Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], group = gr_Option3, tooltip = ToolTip_Op3_Source)
Strat3_Smooth = input.string(title = "Smoothing", defval = "EMA", options = ["EMA", "RMA", "SMA", "WMA", "HMA"], group = gr_Option3, tooltip = ToolTip_Op3_Smooth)
Strat3_TimeF = input.timeframe(title = "TimeFrame", defval = "15", group = gr_Option3, tooltip = ToolTip_Op3_TimeFrame)
// Calculate [Option 3] Moving Average Convergence Divergence
Strat3_Rsi = request.security(syminfo.tickerid, Strat3_TimeF, Function_Rsi(Function_SourceChange(Strat3_Source), Strat3_RsiPeriod))
Strat3_FastMovAvg = request.security(syminfo.tickerid, Strat3_TimeF, Function_MovAvg(Strat3_Rsi, Strat3_FastPeriod, Strat3_Smooth))
Strat3_SlowMovAvg = request.security(syminfo.tickerid, Strat3_TimeF, Function_MovAvg(Strat3_Rsi, Strat3_SlowPeriod, Strat3_Smooth))
Strat3_RsiMacd = Strat3_FastMovAvg - Strat3_SlowMovAvg
Strat3_Signal = request.security(syminfo.tickerid, Strat3_TimeF, Function_MovAvg(Strat3_RsiMacd, Strat3_SignalPeriod, Strat3_Smooth))
Strat3_Histogram = Strat3_RsiMacd - Strat3_Signal
Strat3_MacdColor = color.aqua
Strat3_SignalColor = color.orange
Strat3_HistoColor = (Strat3_Histogram > 0 and Strat3_Histogram > Strat3_Histogram[1]) ? color.teal :
(Strat3_Histogram > 0 and Strat3_Histogram < Strat3_Histogram[1]) ? color.lime :
(Strat3_Histogram < 0 and Strat3_Histogram < Strat3_Histogram[1]) ? color.red :
(Strat3_Histogram < 0 and Strat3_Histogram > Strat3_Histogram[1]) ? color.maroon : na
// Preparing Plot for [Option 3]
Strat3_PrePlot_Macd = StrategyChoose == "03 - Histogram" ? Strat3_RsiMacd : na
Strat3_PrePlot_Sign = StrategyChoose == "03 - Histogram" ? Strat3_Signal : na
Strat3_PrePlot_Hist = StrategyChoose == "03 - Histogram" ? Strat3_Histogram : na
Strat3_PrePlot_Mid = StrategyChoose == "03 - Histogram" ? 0 : na
// Plot [Option 3] Results
Plot_Strat3Macd = plot(Strat3_PrePlot_Macd, color = Strat3_MacdColor, linewidth = 2, title = "Option 3 - Macd Rsi")
Plot_Strat3Signal = plot(Strat3_PrePlot_Sign, color = Strat3_SignalColor, linewidth = 2, title = "Option 3 - Signal")
Plot_Strat3MidPoint = plot(Strat3_PrePlot_Mid, color = color.black, linewidth = 1, title = "Option 3 - Middle Line")
Plot_Strat3Histo = plot(Strat3_PrePlot_Hist, style = plot.style_columns, color = Strat3_HistoColor, title = "Option 3 - Histogram")
// Set [Option 3] Signals for Alerts
BuySignal := ta.crossover(Strat3_Histogram, 0) and (Strat3_RsiMacd < 0) and (Strat3_Signal < 0) and StrategyChoose == "03 - Histogram"
SellSignal := ta.crossunder(Strat3_Histogram, 0) and (Strat3_RsiMacd < 0) and (Strat3_Signal < 0) and StrategyChoose == "03 - Histogram"
// }
// ==============================================
// == OPTION 4 ==
// ==============================================
// {
// ToolTips Strings to Help User
ToolTip_Op4_Period = "RSI Period: \nPeriod Value to Rsi Study \n\n"
ToolTip_Op4_AvgPeriod = "Moving Average Period: \nPeriod Value to the Moving Average Study \n\n"
ToolTip_Op4_Smooth = "Smooth: \nChoose the smooth value to the Moving Average calculation \n\n"
ToolTip_Op4_Source = "Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op4_TimeFrame = "TimeFrame: \nChoose the TimeFrame you want to study"
// Title of Window
gr_Option4 = "04 - MOVING AVERAGE CROSS"
// Get General User Inputs
Strat4_RsiPeriod = input.int(title = "RSI Period", defval = 14, minval = 0, step = 1, group = gr_Option4, tooltip = ToolTip_Op4_Period)
Strat4_AvgPeriod = input.int(title = "Moving Average Period", defval = 14, minval = 0, step = 1, group = gr_Option3, tooltip = ToolTip_Op4_AvgPeriod)
Strat4_Source = input.string(title = "Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], group = gr_Option4, tooltip = ToolTip_Op4_Source)
Strat4_Smooth = input.string(title = "Smoothing", defval = "EMA", options = ["EMA", "RMA", "SMA", "WMA", "HMA"], group = gr_Option4, tooltip = ToolTip_Op4_Smooth)
Strat4_TimeF = input.timeframe(title = "TimeFrame", defval = "15", group = gr_Option4, tooltip = ToolTip_Op4_TimeFrame)
// Calculate [Option 4] RSI and Respective Moving Average
Strat4_Rsi = request.security(syminfo.tickerid, Strat4_TimeF, Function_Rsi(Function_SourceChange(Strat4_Source), Strat4_RsiPeriod))
Strat4_MovAvg = request.security(syminfo.tickerid, Strat4_TimeF, Function_MovAvg(Strat4_Rsi, Strat4_AvgPeriod, Strat4_Smooth))
// Preparing Plot for [Option 4]
Strat4_PrePlot_Rsi = StrategyChoose == "04 - Moving Average Cross" ? Strat4_Rsi : na
Strat4_PrePlot_Avg = StrategyChoose == "04 - Moving Average Cross" ? Strat4_MovAvg : na
Strat4_PrePlot_Mid = StrategyChoose == "04 - Moving Average Cross" ? 50 : na
// Plot [Option 4] Results
Plot_Strat4_Rsi = plot(Strat4_PrePlot_Rsi, color = color.purple, linewidth = 2, title = "Option 4 - Rsi")
Plot_Strat4_Avg = plot(Strat4_PrePlot_Avg, color = color.orange, linewidth = 2, title = "Option 4 - Moving Average")
Plot_Strat4MidPoint = plot(Strat4_PrePlot_Mid, color = color.black, linewidth = 1, title = "Option 4 - Middle Line")
// Set [Option 4] Signals for Alerts
BuySignal := ta.crossover(Strat4_Rsi, Strat4_MovAvg) and StrategyChoose == "04 - Moving Average Cross"
SellSignal := ta.crossunder(Strat4_Rsi, Strat4_MovAvg) and StrategyChoose == "04 - Moving Average Cross"
// }
// ==============================================
// == OPTION 5 ==
// ==============================================
// {
// ToolTips Strings to Help User
ToolTip_Op5_Period = "Period: \nPeriod Value to Rsi Study \n\n"
ToolTip_Op5_Source = "Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op5_LookRight = "Pivot Lookback Right: \nNumber of candles that must exist on right to detect pivot \n\n"
ToolTip_Op5_LookLeft = "Pivot Lookback Left: \nNumber of candles that must exist on left to detect pivot \n\n"
ToolTip_Op5_MaxRange = "Max of Lookback Range: \nMaximum number of candles to lookback to detect a divergence"
ToolTip_Op5_MinRange = "Min of Lookback Range: \nMinimum number of candles to lookback to detect a divergence"
ToolTip_Op5_BullDiv = "Plot Bullish Divergence: \nShow Standard Bullish Divergence"
ToolTip_Op5_MediumBullDiv = "Plot Middle Bullish Divergence: \nShow Medium Point Bullish Divergence"
ToolTip_Op5_BearDiv = "Plot Bearish Divergence: \nShow Standard Bearish Divergence"
ToolTip_Op5_MediumBearDiv = "Plot Middle Bearish Divergence: \nShow Medium Point Bearish Divergence"
ToolTip_Op5_OS = "Strat5_OverSold Level: \nChoose the Level for Strat5_OverSold Position \n\n"
ToolTip_Op5_OB = "Strat5_OverBought Level: \nChoose the Level for Strat5_OverBought Position \n\n"
ToolTip_Op5_BearColour = "Bearish Color: \nColor from the Bearish Labels \n\n"
ToolTip_Op5_BullColour = "Bullish Color: \nColor from the Bullish Labels \n\n"
ToolTip_Op5_LabelTextColour = "Text Label Color: \nColor from the labl's text \n\n"
// Title of Window
gr_Option5 = "05 - DIVERGENCE"
// Get General User Inputs
Strat5_RsiPeriod = input.int(title = "Period", minval = 1, defval = 5, tooltip = ToolTip_Op5_Period, group = gr_Option5)
Strat5_RsiSource = input.string(title = "Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], tooltip = ToolTip_Op5_Source, group = gr_Option5)
Strat5_LookBackRight = input.int(title = "Pivot Lookback Right", defval = 3, tooltip = ToolTip_Op5_LookRight, group = gr_Option5)
Strat5_LookBackLeft = input.int(title = "Pivot Lookback Left", defval = 1, tooltip = ToolTip_Op5_LookLeft, group = gr_Option5)
Strat5_MaxLookBackRange = input.int(title = "Max of Lookback Range", defval = 60, tooltip = ToolTip_Op5_MaxRange, group = gr_Option5)
Strat5_MinLookBackRange = input.int(title = "Min of Lookback Range", defval = 5, tooltip = ToolTip_Op5_MinRange, group = gr_Option5)
Strat5_ShowBullDiv = input.bool(title = "Plot Bullish Divergence", defval = true, tooltip = ToolTip_Op5_BullDiv, group = gr_Option5)
Strat5_ShowHiddenBullDiv = input.bool(title = "Plot Hidden Bullish", defval = true, tooltip = ToolTip_Op5_MediumBullDiv, group = gr_Option5)
Strat5_ShowBearDiv = input.bool(title = "Plot Bearish", defval = true, tooltip = ToolTip_Op5_BearDiv, group = gr_Option5)
Strat5_ShowHiddenBear = input.bool(title = "Plot Hidden Bearish", defval = false, tooltip = ToolTip_Op5_MediumBearDiv, group = gr_Option5)
Strat5_OverSold = input.float(title = "Strat5_OverSold Level", defval = 30, minval = 0, maxval = 100, tooltip = ToolTip_Op5_OS, group = gr_Option5)
Strat5_OverBought = input.float(title = "Strat5_OverBought Level", defval = 70, minval = 50, maxval = 100, tooltip = ToolTip_Op5_OB, group = gr_Option5)
Strat5_BearishColour = input.color(title = "Bearish Color", defval = color.red, tooltip = ToolTip_Op5_BearColour, group = gr_Option5)
Strat5_BullishColour = input.color(title = "Bullish Color", defval = color.teal, tooltip = ToolTip_Op5_BullColour, group = gr_Option5)
Strat5_TextLabelColour = input.color(title = "Text Label Color", defval = color.white, tooltip = ToolTip_Op5_LabelTextColour, group = gr_Option5)
// Function to Check if Study Candles Are In The Range
FunctionRangeChecker(RangeChecker) =>
RangeBars = ta.barssince(RangeChecker == true)
IsInRange = Strat5_MinLookBackRange <= RangeBars and RangeBars <= Strat5_MaxLookBackRange
// Calculate Rsi
Strat5_Rsi = request.security(syminfo.tickerid, timeframe.period, Function_Rsi(Function_SourceChange(Strat5_RsiSource), Strat5_RsiPeriod))
// Check For Pivots On Rsi
IsPivotLow = na(ta.pivotlow(Strat5_Rsi, Strat5_LookBackLeft, Strat5_LookBackRight)) ? false : true
IsPivotHigh = na(ta.pivothigh(Strat5_Rsi, Strat5_LookBackLeft, Strat5_LookBackRight)) ? false : true
// Calculate Standard Bullish Divergence (Rsi Higher Low + Price Lower Low)
Rsi_HigherLow = Strat5_Rsi[Strat5_LookBackRight] > ta.valuewhen(IsPivotLow, Strat5_Rsi[Strat5_LookBackRight], 1) and FunctionRangeChecker(IsPivotLow[1])
Price_LowerLow = low[Strat5_LookBackRight] < ta.valuewhen(IsPivotLow, low[Strat5_LookBackRight], 1)
IsBullDiv = Strat5_ShowBullDiv and Price_LowerLow and Rsi_HigherLow and IsPivotLow and StrategyChoose == "05 - Divergence"
// Calculate Medium Bullish Divergence (Rsi Lower Low + Price Higher Low)
Rsi_LowerLow = Strat5_Rsi[Strat5_LookBackRight] < ta.valuewhen(IsPivotLow, Strat5_Rsi[Strat5_LookBackRight], 1) and FunctionRangeChecker(IsPivotLow[1])
Price_HigherLow = low[Strat5_LookBackRight] > ta.valuewhen(IsPivotLow, low[Strat5_LookBackRight], 1)
IsMediumBullDiv = Strat5_ShowHiddenBullDiv and Price_HigherLow and Rsi_LowerLow and IsPivotLow and StrategyChoose == "05 - Divergence"
// Calculate Standard Bearish Divergence (Rsi Lower High + Price Higher High)
Rsi_LowerHigh = Strat5_Rsi[Strat5_LookBackRight] < ta.valuewhen(IsPivotHigh, Strat5_Rsi[Strat5_LookBackRight], 1) and FunctionRangeChecker(IsPivotHigh[1])
Price_HigherHigh = high[Strat5_LookBackRight] > ta.valuewhen(IsPivotHigh, high[Strat5_LookBackRight], 1)
IsBearDiv = Strat5_ShowBearDiv and Price_HigherHigh and Rsi_LowerHigh and IsPivotHigh and StrategyChoose == "05 - Divergence"
// Calculate Medium Bearish Divergence (Rsi Higher High + Price Lower High)
Rsi_HigherHigh = Strat5_Rsi[Strat5_LookBackRight] > ta.valuewhen(IsPivotHigh, Strat5_Rsi[Strat5_LookBackRight], 1) and FunctionRangeChecker(IsPivotHigh[1])
Price_LowerHigh = high[Strat5_LookBackRight] < ta.valuewhen(IsPivotHigh, high[Strat5_LookBackRight], 1)
IsMediumBearDiv = Strat5_ShowHiddenBear and Price_LowerHigh and Rsi_HigherHigh and IsPivotHigh and StrategyChoose == "05 - Divergence"
// Plot Default Indicator Buffers
Strat5_PrePlot_Rsi = StrategyChoose == "05 - Divergence" ? Strat5_Rsi : na
Strat5_PrePlot_Mid = StrategyChoose == "05 - Divergence" ? 50 : na
Strat5_PrePlot_OS = StrategyChoose == "05 - Divergence" ? Strat5_OverSold : na
Strat5_PrePlot_OB = StrategyChoose == "05 - Divergence" ? Strat5_OverBought : na
Stra5_Rsi_Plot = plot(Strat5_PrePlot_Rsi, title = "Option 5 - Rsi", linewidth = 2, color = color.purple)
Stra5_MidPoint_Plot = plot(Strat5_PrePlot_Mid, title = "Option 5 - MidPoint Line", linewidth = 1, color = color.black)
Stra5_OverS_Plot = plot(Strat5_PrePlot_OS, title = "Option 5 - OverSold Line", linewidth = 1, color = color.black)
Stra5_OverB_Plot = plot(Strat5_PrePlot_OB, title = "Option 5 - OverBought Line", linewidth = 1, color = color.black)
// Plot Standard Bullish Divergence
plot(IsPivotLow and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Standard Bullish Divergence", offset = -Strat5_LookBackRight,
linewidth = 2, color = (IsBullDiv ? Strat5_BullishColour : color.new(color.white, 100)))
plotshape(IsBullDiv and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Standard Bullish Divergence Label", offset = -Strat5_LookBackRight,
text = " Bull \n Div ", style = shape.labelup, location = location.absolute, color = Strat5_BullishColour, textcolor = Strat5_TextLabelColour)
// Plot Medium Bullish Divergence
plot(IsPivotLow and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Medium Bullish Divergence", offset = -Strat5_LookBackRight,
linewidth=2, color=(IsMediumBullDiv ? Strat5_BullishColour : color.new(color.white, 100)))
plotshape(IsMediumBullDiv and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Medium Bullish Divergence Label", offset = -Strat5_LookBackRight,
text =" M Bull \n Div", style = shape.labelup, location = location.absolute, color = Strat5_BullishColour, textcolor = Strat5_TextLabelColour)
// Plot Standard Bearish Divergence
plot(IsPivotHigh and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Standard Bearish Divergence", offset = -Strat5_LookBackRight,
linewidth = 2, color = (IsBearDiv ? Strat5_BearishColour : color.new(color.white, 100)))
plotshape(IsBearDiv and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Standard Bearish Divergence Label", offset = -Strat5_LookBackRight,
text =" Bear \n Div ", style = shape.labeldown, location = location.absolute, color = Strat5_BearishColour, textcolor = Strat5_TextLabelColour)
// Plot Medium Bearish Divergence
plot(IsPivotHigh and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Medium Bearish Divergence", offset = -Strat5_LookBackRight,
linewidth = 2, color = (IsMediumBearDiv ? Strat5_BearishColour : color.new(color.white, 100)))
plotshape(IsMediumBearDiv and StrategyChoose == "05 - Divergence" ? Strat5_Rsi[Strat5_LookBackRight] : na, title = "Medium Bearish Divergence Label", offset = -Strat5_LookBackRight,
text = " M Bear \n Div", style = shape.labeldown, location = location.absolute, color = Strat5_BearishColour, textcolor = Strat5_TextLabelColour)
// Set [Option 4] Signals for Alerts
BuySignal := StrategyChoose == "05 - Divergence" and (IsBullDiv or IsMediumBullDiv) ? Strat5_Rsi[Strat5_LookBackRight] : na
SellSignal := StrategyChoose == "05 - Divergence" and (IsBearDiv or IsMediumBearDiv) ? Strat5_Rsi[Strat5_LookBackRight] : na
// }
// ==============================================
// == OPTION 6 ==
// ==============================================
// {
// Title of Window
gr_Option6 = "06 - MULTI RSI"
// ToolTips Strings to Help User
ToolTip_Op6_FastPeriod = "Fast Period: \nPeriod Value to Rsi Study \n\n"
ToolTip_Op6_FastSource = "Fast Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op6_FastTimeFrame = "Fast TimeFrame: \nChoose the TimeFrame you want to study \n\n"
ToolTip_Op6_SlowPeriod = "Slow Period: \nPeriod Value to Rsi Study \n\n"
ToolTip_Op6_SlowSource = "Slow Source: \nSource Value to Rsi Study \n\n"
ToolTip_Op6_SlowTimeFrame = "Slow TimeFrame: \nChoose the TimeFrame you want to study \n\n"
// Get General User Inputs
Strat6_FastPeriod = input.int(title = "Fast Period", defval = 9, minval = 0, step = 1, group = gr_Option6, tooltip = ToolTip_Op6_FastPeriod)
Strat6_FastSource = input.string(title = "Fast Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], group = gr_Option6, tooltip = ToolTip_Op6_FastSource)
Strat6_FastTimeF = input.timeframe(title = "TimeFrame", defval = "15", group = gr_Option6, tooltip = ToolTip_Op6_FastTimeFrame)
Strat6_SlowPeriod = input.int(title = "Slow Period", defval = 9, minval = 0, step = 1, group = gr_Option6, tooltip = ToolTip_Op6_SlowPeriod)
Strat6_SlowSource = input.string(title = "Slow Source", defval = "04 - Standard Close",
options = ["01 - Standard Open", "02 - Standard High", "03 - Standard Low", "04 - Standard Close", "05 - Standard HLC3", "06 - Standard HL2",
"07 - Heikin Ashi Open", "08 - Heikin Ashi High", "09 - Heikin Ashi Low", "10 - Heikin Ashi Close"], group = gr_Option6, tooltip = ToolTip_Op6_SlowSource)
Strat6_SlowTimeF = input.timeframe(title = "TimeFrame", defval = "120", group = gr_Option6, tooltip = ToolTip_Op6_SlowTimeFrame)
// Calculate [Option 6] RSI
Strat6_FastRsi = request.security(syminfo.tickerid, Strat6_FastTimeF, Function_Rsi(Function_SourceChange(Strat6_FastSource), Strat6_FastPeriod))
Strat6_SlowRsi = request.security(syminfo.tickerid, Strat6_SlowTimeF, Function_Rsi(Function_SourceChange(Strat6_SlowSource), Strat6_SlowPeriod))
// Preparing Plot for [Option 6]
Strat6_PrePlot_FastRsi = StrategyChoose == "06 - Multi Rsi" ? Strat6_FastRsi : na
Strat6_PrePlot_SlowRsi = StrategyChoose == "06 - Multi Rsi" ? Strat6_SlowRsi : na
Strat6_PrePlot_Mid = StrategyChoose == "06 - Multi Rsi" ? 50 : na
// Plot [Option 2] Results
Plot_Strat6FastRsi = plot(Strat6_PrePlot_FastRsi, color = color.green, linewidth = 2)
Plot_Strat6SlowRsi = plot(Strat6_PrePlot_SlowRsi, color = color.red, linewidth = 2)
Plot_Strat6MidPoint = plot(Strat6_PrePlot_Mid, color = color.black, linewidth = 1)
// Set [Option 2] Signals for Alerts
BuySignal := ta.crossover(Strat6_FastRsi, Strat6_SlowRsi) and (Strat6_SlowRsi > 50) and StrategyChoose == "06 - Multi Rsi"
SellSignal := ta.crossunder(Strat6_FastRsi, Strat6_SlowRsi) and (Strat6_SlowRsi < 50) and StrategyChoose == "06 - Multi Rsi"
// ==============================================
// == ALERT GENERATOR ==
// ==============================================
// {
StringMessageAlert = BuySignal ? "A Long Signal has been generated" : SellSignal ? "A Short Signal has been generated" : na
if ((BuySignal or SellSignal) and barstate.isconfirmed)
alert(StringMessageAlert, alert.freq_once_per_bar_close)
// } |
MACD-V Volatility Normalized Momentum | https://www.tradingview.com/script/CE4EqZ1A-MACD-V-Volatility-Normalized-Momentum/ | Mik3Christ3ns3n | https://www.tradingview.com/u/Mik3Christ3ns3n/ | 106 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mik3Christ3ns3n
//@version=5
indicator(title="MACD-V Volatility Normalized Momentum", shorttitle="MACD-V", timeframe="", timeframe_gaps=true)
// Getting inputs
fast_length = input(title="Fast Length", defval=12)
slow_length = input(title="Slow Length", defval=26)
atr_length = input(title="ATR Length", defval=26)
src = input(title="Source", defval=close)
// Plot colors
col_macd = input(#FF6D00, "MACD-V Line ", group="Color Settings", inline="MACD-V")
// [( 12 bar EMA - 26 bar EMA) / ATR(26) ] * 100
fast_ma = ta.ema(src, fast_length)
slow_ma = ta.ema(src, slow_length)
atr = ta.atr(atr_length)
macd = fast_ma - slow_ma
macdv = (macd / atr) * 100
plot(macdv, title="MACD-V", color=col_macd)
band1 = hline(150, "Upper Band", color=#787B86)
bandm = hline(0, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(-150, "Lower Band", color=#787B86)
fill(band1, band0, color=color.rgb(120, 123, 134, 90), title="Background")
|
Adaptive Envelope | https://www.tradingview.com/script/DEESiYUv-Adaptive-Envelope/ | CapitalizatorUA | https://www.tradingview.com/u/CapitalizatorUA/ | 69 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CapitalizatorUA
//@version=5
indicator("Adaptive Envelope", overlay=true)
int len = input.int(21, "Envelope Period", minval = 2)
string maType = input.string("EMA", "MA type", options = ["EMA", "SMA", "RMA", "WMA"])
float offset = input.float(2, "Envelope Deviation")
int count = input.int(2, "Moving Count", minval = 1, maxval = 5)
float centr = switch maType
"EMA" => ta.ema(close, len)
"SMA" => ta.sma(close, len)
"RMA" => ta.rma(close, len)
"WMA" => ta.wma(close, len)
=>
runtime.error("No matching MA type found.")
float(na)
line1=centr+offset*ta.atr(len)
line2=centr-offset*ta.atr(len)
plot(centr,color=color.blue)
plot(line1,color=color.green)
plot(line2,color=color.red)
line3=centr+2*offset*ta.atr(len)
line4=centr-2*offset*ta.atr(len)
plot(count>1 ? line3 : na, color=color.green)
plot(count>1 ? line4 : na, color=color.red)
line5=centr+3*offset*ta.atr(len)
line6=centr-3*offset*ta.atr(len)
plot(count>2 ? line5 : na, color=color.green)
plot(count>2 ? line6 : na, color=color.red)
line7=centr+4*offset*ta.atr(len)
line8=centr-4*offset*ta.atr(len)
plot(count>3 ? line7 : na, color=color.green)
plot(count>3 ? line8 : na, color=color.red)
line9=centr+5*offset*ta.atr(len)
line10=centr-5*offset*ta.atr(len)
plot(count>4 ? line9 : na, color=color.green)
plot(count>4 ? line10 : na, color=color.red)
|
No Climactic Bars | https://www.tradingview.com/script/iYab3pgr/ | kegesch | https://www.tradingview.com/u/kegesch/ | 2 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kegesch
//@version=5
indicator("No Climactic Bars")
varianceThreshold = input.float(title = "Threshold", defval = 0.003, step = 0.0005)
windowSize = input.int(title = "Number of candles in window", defval = 3, minval = 1)
varToLast(i) =>
math.pow(close[i+1] - close[i], 2)
lastNVars(cnt) =>
window = array.new<float>(cnt)
for i = 0 to cnt-1
array.set(window, i, varToLast(i))
array.max(window)
variance = lastNVars(windowSize)
plot(variance, color = variance < varianceThreshold ? color.gray : color.lime)
plateuReached = ta.barssince(variance >= varianceThreshold) > windowSize
plotshape(plateuReached)
|
Contract Move Track | https://www.tradingview.com/script/e9Ehdz4d-Contract-Move-Track/ | knoxbide | https://www.tradingview.com/u/knoxbide/ | 9 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © knoxbide
//@version=4
study(title = "Viince", overlay=true)
strike_price = input(defval = 500 , title = "Strike Price", type=input.float)
entry_price = input(defval = 50, title = "Entry Price", type=input.float)
strike_line_color = input(defval = color.lime, title = "Strike Line", type = input.color)
verticale_color = input(defval = color.lime, title = "End Line", type = input.color)
box_colox = input(defval = color.navy, title = "Box Color", type = input.color)
startDate = input(defval=timestamp("20 May 2022 02:00"), type=input.time, title="Start Location")
endDate = input(defval=timestamp("25 May 2022 02:00"), type=input.time, title="End Location")
sp_max = strike_price + entry_price
sp_min = strike_price - entry_price
box.new(startDate, sp_max, endDate, sp_min, color.blue, 3, line.style_solid, extend.none, xloc.bar_time, box_colox)
barre_horizontale = line.new(startDate, strike_price, endDate, strike_price, xloc.bar_time, extend.none, strike_line_color)
barre_verticale = line.new(endDate, low * .9999, endDate, high * 1.0001, xloc.bar_time, extend.both, verticale_color, line.style_solid, 3)
|
Crab Range Finder | https://www.tradingview.com/script/AE1djieP-Crab-Range-Finder/ | LMJ0011trader | https://www.tradingview.com/u/LMJ0011trader/ | 57 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LMJ0011trader
//@version=5
indicator("Crab Range Finder", overlay=true)
prev_bars_cnt = input(5, "include the last X bars for this range")
high_vals = array.new_float(prev_bars_cnt)
for i = 0 to prev_bars_cnt
array.push(high_vals, high[i])
low_vals = array.new_float(prev_bars_cnt)
for i = 0 to prev_bars_cnt
array.push(low_vals, low[i])
high_avg = math.round(array.avg(high_vals), 2)
low_avg = math.round(array.avg(low_vals), 2)
median = math.round((high_avg + low_avg) / 2, 2)
var label highlabel = na
var label medianlabel = na
var label lowlabel = na
// so labels don't duplicated when new bar shows
// ref: https://stackoverflow.com/a/58703622/2445763
label.delete(highlabel)
label.delete(medianlabel)
label.delete(lowlabel)
plot(barstate.islast ? high_avg : na, title='top', color=color.green, style=plot.style_line, trackprice=true, linewidth=2)
plot(barstate.islast ? median : na, title='median', color=color.orange, style=plot.style_line, trackprice=true, linewidth=2)
plot(barstate.islast ? low_avg : na, title='bottom', color=color.yellow, style=plot.style_line, trackprice=true, linewidth=2)
if barstate.islast
highlabel := label.new(bar_index + 5, high_avg, text=str.tostring(high_avg), color = color.green, textcolor = color.white, style=label.style_label_down)
medianlabel := label.new(bar_index + 5, median, text=str.tostring(median), color = color.orange, textcolor = color.white, style=label.style_label_up)
lowlabel := label.new(bar_index + 5, low_avg, text=str.tostring(low_avg), color = color.yellow, textcolor = color.black, style=label.style_label_up)
|
EMA Slope Histogram | https://www.tradingview.com/script/5bBmOn2G-EMA-Slope-Histogram/ | chasm9a | https://www.tradingview.com/u/chasm9a/ | 69 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chasm9a
//@version=5
indicator("EMA Slope Histogram", overlay = false)
emaPeriod = input.int(defval = 50, title="EMA Period" ,minval = 0, maxval = 999, step = 1)
changePeriod = input.int(defval = 5, title="Change Period" ,minval = 0, maxval = 999, step = 1)
changeinDirection = input.bool(defval = true, title="Show Change in Direction")
ema = ta.ema(close ,emaPeriod)
histo = (ema[0] - ema[changePeriod]) / changePeriod
histoColor = histo[0] < 0 ? color.red : color.green
histoAlpha = histo[0] > histo[1] ? 50 : 0
histoBeta = histo[0] < histo[1] ? 50 : 0
emaMinus = (histo[0] > 0 and histo[1] <0) ? 1 : na
emaPlus = (histo[0] < 0 and histo[1] >0)? 1 : na
plotchar(changeinDirection == true ? emaPlus : na, char = "*", size= size.tiny, location = location.top, color= color.red)
plotchar(changeinDirection == true ? emaMinus : na, char = "*", size= size.tiny, location = location.top, color=color.green)
plot(histo, style=plot.style_columns, color= color.new(histoColor, histoColor == color.red?histoAlpha:histoBeta)) |
Impulse & Security | https://www.tradingview.com/script/g9AfERWH-impulse-security/ | Tears-Of-Broker | https://www.tradingview.com/u/Tears-Of-Broker/ | 19 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Tears-Of-Broker
//@version=5
indicator(("Impulse & Security"),overlay=true)
//☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣
c=high-low
h=high
l=low
diap=input(2, title='Допустимый диапазон погрешности')
BigCand=c>c[1] and c>c[2] and c>c[3] and c>c[4] and c>c[5] and c>c[6] and c>c[7] and c>c[8] and c>c[9] and c>c[10] and c>c[11] and c>c[12]
//☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣
V= h[1]>=h and h>=(h[1]-syminfo.mintick*diap)
V2=h[2]>=h and h>=(h[2]-syminfo.mintick*diap) and h>h[1]
V3=h[3]>=h and h>=(h[3]-syminfo.mintick*diap) and h>h[1] and h>h[2]
V4=h[4]>=h and h>=(h[4]-syminfo.mintick*diap) and h>h[1] and h>h[2] and h>h[3]
V5=h[5]>=h and h>=(h[5]-syminfo.mintick*diap) and h>h[1] and h>h[2] and h>h[3] and h>h[4]
V6=h[6]>=h and h>=(h[6]-syminfo.mintick*diap) and h>h[1] and h>h[2] and h>h[3] and h>h[4] and h>h[5]
V7=h[7]>=h and h>=(h[7]-syminfo.mintick*diap) and h>h[1] and h>h[2] and h>h[3] and h>h[4] and h>h[5] and h>h[6]
V_= h[1]<=h and h<=(h[1]+syminfo.mintick*diap)
V_2=h[2]<=h and h<=(h[2]+syminfo.mintick*diap) and h>=h[1]
V_3=h[3]<=h and h<=(h[3]+syminfo.mintick*diap) and h>=h[1] and h>=h[2]
V_4=h[4]<=h and h<=(h[4]+syminfo.mintick*diap) and h>=h[1] and h>=h[2] and h>=h[3]
V_5=h[5]<=h and h<=(h[5]+syminfo.mintick*diap) and h>=h[1] and h>=h[2] and h>=h[3] and h>=h[4]
V_6=h[6]<=h and h<=(h[6]+syminfo.mintick*diap) and h>=h[1] and h>=h[2] and h>=h[3] and h>=h[4] and h>=h[5]
V_7=h[7]<=h and h<=(h[7]+syminfo.mintick*diap) and h>=h[1] and h>=h[2] and h>=h[3] and h>=h[4] and h>=h[5] and h>=h[6]
Vall=V or V2 or V3 or V4 or V5 or V6 or V7 or V_ or V_2 or V_3 or V_4 or V_5 or V_6 or V_7
VV= (Vall[1] and V or Vall[1] and V_)
A= l[1]>=l and l>=(l[1]-syminfo.mintick*diap)
A2=l[2]>=l and l>=(l[2]-syminfo.mintick*diap) and l<l[1]
A3=l[3]>=l and l>=(l[3]-syminfo.mintick*diap) and l<l[1] and l<l[2]
A4=l[4]>=l and l>=(l[4]-syminfo.mintick*diap) and l<l[1] and l<l[2] and l<l[3]
A5=l[5]>=l and l>=(l[5]-syminfo.mintick*diap) and l<l[1] and l<l[2] and l<l[3] and l<l[4]
A6=l[6]>=l and l>=(l[6]-syminfo.mintick*diap) and l<l[1] and l<l[2] and l<l[3] and l<l[4] and l<l[5]
A7=l[7]>=l and l>=(l[7]-syminfo.mintick*diap) and l<l[1] and l<l[2] and l<l[3] and l<l[4] and l<l[5] and l<l[6]
A_= l[1]<=l and l<=(l[1]+syminfo.mintick*diap)
A_2=l[2]<=l and l<=(l[2]+syminfo.mintick*diap) and l<=l[1]
A_3=l[3]<=l and l<=(l[3]+syminfo.mintick*diap) and l<=l[1] and l<=l[2]
A_4=l[4]<=l and l<=(l[4]+syminfo.mintick*diap) and l<=l[1] and l<=l[2] and l<=l[3]
A_5=l[5]<=l and l<=(l[5]+syminfo.mintick*diap) and l<=l[1] and l<=l[2] and l<=l[3] and l<=l[4]
A_6=l[6]<=l and l<=(l[6]+syminfo.mintick*diap) and l<=l[1] and l<=l[2] and l<=l[3] and l<=l[4] and l<=l[5]
A_7=l[7]<=l and l<=(l[7]+syminfo.mintick*diap) and l<=l[1] and l<=l[2] and l<=l[3] and l<=l[4] and l<=l[5] and l<=l[6]
Aall=A or A2 or A3 or A4 or A5 or A6 or A7 or A_ or A_2 or A_3 or A_4 or A_5 or A_6 or A_7
AA= (Aall[1] and A or Aall[1] and A_)
//plotshape(Vall, title='Vbar', style=shape.triangledown, location= location.abovebar, size=size.tiny, color=color.new(color.orange, 0))
plotshape(VV, title='VVbar', style=shape.diamond, location= location.abovebar, size=size.tiny, color=color.new(color.red, 50))
//plotshape(Aall, title='Abar', style=shape.triangleup, location= location.belowbar, size=size.tiny, color=color.new(color.blue, 0))
plotshape(AA, title='AAbar', style=shape.diamond, location= location.belowbar, size=size.tiny, color=color.new(color.green, 50))
//●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●
plot(ta.ema(close, 100),color=color.new(color.white, 10))
plot(ta.ema(close, 40),color=color.new(color.white, 10))
//Breakout ☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣
Breakout_A = close>ta.ema(close, 40) and BigCand and open<close
Breakout_V = close<ta.ema(close, 40) and BigCand and open>close
candleColor = color.gray
if Breakout_A
candleColor := color.green
candleColor
if Breakout_V
candleColor := color.red
candleColor
barcolor(candleColor)
//☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣
VVV=Breakout_V[1] and h<h[1] and Vall and close < ta.ema(close, 40)
or Breakout_V[2] and h<h[2] and Vall and close < ta.ema(close, 40) and h[1]<h[2]
or Breakout_V[3] and h<h[3] and Vall and close < ta.ema(close, 40) and h[2]<h[3] and h[1]<h[3]
or Breakout_V[4] and h<h[4] and Vall and close < ta.ema(close, 40) and h[3]<h[4] and h[2]<h[4] and h[1]<h[4]
or Breakout_V[5] and h<h[5] and Vall and close < ta.ema(close, 40) and h[4]<h[5] and h[3]<h[5] and h[2]<h[5] and h[1]<h[5]
or Breakout_V[6] and h<h[6] and Vall and close < ta.ema(close, 40) and h[5]<h[6] and h[4]<h[6] and h[3]<h[6] and h[2]<h[6] and h[1]<h[6]
or Breakout_V[7] and h<h[7] and Vall and close < ta.ema(close, 40) and h[6]<h[7] and h[5]<h[7] and h[4]<h[7] and h[3]<h[7] and h[2]<h[7] and h[1]<h[7]
or Breakout_V[8] and h<h[8] and Vall and close < ta.ema(close, 40) and h[7]<h[8] and h[6]<h[8] and h[5]<h[8] and h[4]<h[8] and h[3]<h[8] and h[2]<h[8] and h[1]<h[8]
or Breakout_V[9] and h<h[9] and Vall and close < ta.ema(close, 40) and h[8]<h[9] and h[7]<h[9] and h[6]<h[9] and h[5]<h[9] and h[4]<h[9] and h[3]<h[9] and h[2]<h[9] and h[1]<h[9]
or Breakout_V[10] and h<h[10] and Vall and close < ta.ema(close, 40) and h[9]<h[10] and h[8]<h[10] and h[7]<h[10] and h[6]<h[10] and h[5]<h[10] and h[4]<h[10] and h[3]<h[10] and h[2]<h[10] and h[1]<h[10]
AAA=Breakout_A[1] and l>l[1] and Aall and close > ta.ema(close, 40)
or Breakout_A[2] and l>l[2] and Aall and close > ta.ema(close, 40) and l[1]>l[2]
or Breakout_A[3] and l>l[3] and Aall and close > ta.ema(close, 40) and l[2]>l[3] and l[1]>l[3]
or Breakout_A[4] and l>l[4] and Aall and close > ta.ema(close, 40) and l[3]>l[4] and l[2]>l[4] and l[1]>l[4]
or Breakout_A[5] and l>l[5] and Aall and close > ta.ema(close, 40) and l[4]>l[5] and l[3]>l[5] and l[2]>l[5] and l[1]>l[5]
or Breakout_A[6] and l>l[6] and Aall and close > ta.ema(close, 40) and l[5]>l[6] and l[4]>l[6] and l[3]>l[6] and l[2]>l[6] and l[1]>l[6]
or Breakout_A[7] and l>l[7] and Aall and close > ta.ema(close, 40) and l[6]>l[7] and l[5]>l[7] and l[4]>l[7] and l[3]>l[7] and l[2]>l[7] and l[1]>l[7]
or Breakout_A[8] and l>l[8] and Aall and close > ta.ema(close, 40) and l[7]>l[8] and l[6]>l[8] and l[5]>l[8] and l[4]>l[8] and l[3]>l[8] and l[2]>l[8] and l[1]>l[8]
or Breakout_A[9] and l>l[9] and Aall and close > ta.ema(close, 40) and l[8]>l[9] and l[7]>l[9] and l[6]>l[9] and l[5]>l[9] and l[4]>l[9] and l[3]>l[9] and l[2]>l[9] and l[1]>l[9]
or Breakout_A[10] and l>l[10] and Aall and close > ta.ema(close, 40) and l[9]>l[10] and l[8]>l[10] and l[7]>l[10] and l[6]>l[10] and l[5]>l[10] and l[4]>l[10] and l[3]>l[10] and l[2]>l[10] and l[1]>l[10]
//☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣
bgcolor(VVV ? color.new(color.red,90) : na)
bgcolor(AAA ? color.new(color.green,90) : na)
if (Breakout_A )
line.new(bar_index, low[0], bar_index+5, low, style= line.style_dotted, color=color.new(color.red, 50), width = 2)
// line.new(bar_index, high[0], bar_index+5, high, style= line.style_dotted, color=color.new(color.green, 50), width = 2)
if (Breakout_V)
// line.new(bar_index-1, low[0], bar_index+5, low, style= line.style_dotted, color=color.new(color.green, 50), width = 2)
line.new(bar_index, high[0], bar_index+5, high, style= line.style_dotted, color=color.new(color.red, 50), width = 2)
//☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣☣
|
OST - Overlapped Super Trend | https://www.tradingview.com/script/LiZeXm74-OST-Overlapped-Super-Trend/ | yosimadsu | https://www.tradingview.com/u/yosimadsu/ | 242 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © yosimadsu
// Modified original code of KivancOzbilgic's Supertrend
//@version=5
indicator("OST - Overlapped Super Trend", "OST", overlay=true, timeframe="", timeframe_gaps=true)
useHA = input.bool(false, "Use Heiken Ashi")
CLOSE = close
OPEN = open
HIGH = high
LOW = low
CLOSE := useHA ? (OPEN + CLOSE + HIGH + LOW) / 4 : CLOSE
OPEN := useHA ? na(OPEN[1]) ? (OPEN + CLOSE) / 2: (OPEN[1] + CLOSE[1]) / 2 : OPEN
HIGH := useHA ? math.max(HIGH, math.max(OPEN, CLOSE)) : HIGH
LOW := useHA ? math.min(LOW, math.min(OPEN, CLOSE)) : LOW
A_Periods = input(2, 'ATR Period')
A_Multiplier = input.float(2, 'ATR Multiplier', step=0.1)
A_atr = ta.atr(A_Periods)
// BUY
A_Bup = LOW - A_Multiplier * A_atr
A_Bup1 = nz(A_Bup[1], A_Bup)
A_Bup := CLOSE[1] > A_Bup1 ? math.max(A_Bup, A_Bup1) : A_Bup
A_Bdn = LOW + A_Multiplier * A_atr
A_Bdn1 = nz(A_Bdn[1], A_Bdn)
A_Bdn := CLOSE[1] < A_Bdn1 ? math.min(A_Bdn, A_Bdn1) : A_Bdn
A_trendBuy = 1
A_trendBuy := nz(A_trendBuy[1], A_trendBuy)
A_trendBuy := A_trendBuy == -1 and CLOSE > A_Bdn1 ? 1 : A_trendBuy == 1 and CLOSE < A_Bup1 ? -1 : A_trendBuy
A_upPlot = plot(A_trendBuy == 1 ? A_Bup : na, title='Up Trend', style=plot.style_linebr, linewidth=1, color=color.new(color.green, 0))
A_buySignal = A_trendBuy == 1 and A_trendBuy[1] == -1
plotshape(A_buySignal ? A_Bup : na, title='UpTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.aqua, 0))
// SEL
A_Sup = HIGH - A_Multiplier * A_atr
A_Sup1 = nz(A_Sup[1], A_Sup)
A_Sup := CLOSE[1] > A_Sup1 ? math.max(A_Sup, A_Sup1) : A_Sup
A_Sdn = HIGH + A_Multiplier * A_atr
A_Sdn1 = nz(A_Sdn[1], A_Sdn)
A_Sdn := CLOSE[1] < A_Sdn1 ? math.min(A_Sdn, A_Sdn1) : A_Sdn
A_trendSel = 1
A_trendSel := nz(A_trendSel[1], A_trendSel)
A_trendSel := A_trendSel == -1 and CLOSE > A_Sdn1 ? 1 : A_trendSel == 1 and CLOSE < A_Sup1 ? -1 : A_trendSel
A_dnPlot = plot(A_trendSel == 1 ? na : A_Sdn, title='Down Trend', style=plot.style_linebr, linewidth=1, color=color.new(color.red, 0))
A_sellSignal = A_trendSel == -1 and A_trendSel[1] == 1
plotshape(A_sellSignal ? A_Sdn : na, title='DownTrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.fuchsia, 0)) |
Weighted Relative Strength Index | https://www.tradingview.com/script/PVSpytyp-Weighted-Relative-Strength-Index/ | Lazylady | https://www.tradingview.com/u/Lazylady/ | 46 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lazylady
//@version=5
indicator(title="Weighted Relative Strength Index", shorttitle="WRSI", format=format.price, precision=2, timeframe="", timeframe_gaps=false)
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
rsiLengthInput = input.int(27, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
rsiMAInput = input.int(28, minval=1, title="RSI SMA Length", group="RSI MA Settings")
up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
///////////////
//TimeFrame Inputs
tf1 = input.timeframe(title="Time Frame 1", defval="5", group="RSI TimeFrame")
tf2 = input.timeframe(title="Time Frame 2", defval="15", group="RSI TimeFrame")
tf3 = input.timeframe(title="Time Frame 3", defval="60", group="RSI TimeFrame")
tfw1 = input(9, title="Time Frame 1 Weight", group="RSI TimeFrame")
tfw2 = input(4, title="Time Frame 2 Weight", group="RSI TimeFrame")
tfw3 = input(1, title="Time Frame 3 Weight", group="RSI TimeFrame")
total = tfw1 + tfw2 + tfw3
//pre-plot
rsi1 = request.security(syminfo.tickerid, tf1, rsi)
rsi2 = request.security(syminfo.tickerid, tf2, rsi)
rsi3 = request.security(syminfo.tickerid, tf3, rsi)
rsif = rsi1*(tfw1/total) + rsi2*(tfw2/total) + rsi3*(tfw3/total)
rsifma = ta.sma(rsif,rsiMAInput)
///////////////
plot(rsif, "RSI", color=#7E57C2)
rsiUpperBand = hline(60, "RSI Upper Band", color=#787B86)
hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(40, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
plot(rsifma, title = "RSI MA",color=color.red) |
Risk assistant - A simple risk caluclator | https://www.tradingview.com/script/ny106KGU-Risk-assistant-A-simple-risk-caluclator/ | Ziloan | https://www.tradingview.com/u/Ziloan/ | 13 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Ziloan
//@version=5
indicator("Risk assistant",overlay=true)
grp1 = "General settings"
p_size = input(10000,"Portfolio size",group=grp1)
risk = input.float(0.5,title="Portfolio percentage risked per trade",step=0.1,group=grp1,minval=0)
risk_size = p_size/100*risk
grp2 = "User input"
risk_measured = input.float(0,title="Measured risk in USD",tooltip="Or whatatever Portfolio size's denominator is",step=1,minval=0,group=grp2)
risk_usd = risk_size/risk_measured
var label lbl = na
label.delete(lbl)
if barstate.islast
lbl := label.new(bar_index+10,close+close*0.005,str.tostring(risk_usd))
|
Risk Management & Position Size Dashboard | https://www.tradingview.com/script/hICY2Hfh-Risk-Management-Position-Size-Dashboard/ | elScipio | https://www.tradingview.com/u/elScipio/ | 379 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aj7919
//@version=5
indicator("3 Moving Averages", overlay = true, timeframe = "60")
timeframe = input.string("H12", title = "HTF Timeframe", options = ["H1", "H4", "H12", "D", "W"])
maType = input.string("EMA", title = "Type", options = ["EMA", "SMA", "VWMA"])
ma1 = input.int(13, title = "Moving Average 1")
ma2 = input.int(21, title = "Moving Average 2")
ma3 = input.int(24, title = "Moving Average 3")
timeFrame1 = timeframe == "H1" ? ma1 : timeframe == "H4" ? ma1 * 4 : timeframe == "H12" ? ma1 * 12 : timeframe == "D" ? ma1 * 24 : timeframe == "W" ? ma1 * 168 : na
timeFrame2 = timeframe == "H1" ? ma2 : timeframe == "H4" ? ma2 * 4 : timeframe == "H12" ? ma2 * 12 : timeframe == "D" ? ma2 * 24 : timeframe == "W" ? ma2 * 168 : na
timeFrame3 = timeframe == "H1" ? ma3 : timeframe == "H4" ? ma3 * 4 : timeframe == "H12" ? ma3 * 12 : timeframe == "D" ? ma3 * 24 : timeframe == "W" ? ma3 * 168 : na
mA1 = maType == "EMA" ? ta.ema(close,timeFrame1) : maType == "SMA" ? ta.sma (close, timeFrame1): maType == "VWMA" ? ta.vwma(close, timeFrame1) : na
mA2 = maType == "EMA" ? ta.ema(close,timeFrame2) : maType == "SMA" ? ta.sma (close, timeFrame2): maType == "VWMA" ? ta.vwma(close, timeFrame2) : na
mA3 = maType == "EMA" ? ta.ema(close,timeFrame3) : maType == "SMA" ? ta.sma (close, timeFrame3): maType == "VWMA" ? ta.vwma(close, timeFrame3) : na
plot(mA1,color = color.new(#f43636, 80))
plot(mA2,color = color.new(#52f3ff, 80))
plot(mA3,color = color.new(#c6eb3e, 80)) |
5 Symbol screener with triple MA and RSI | https://www.tradingview.com/script/gSjDRlMS-5-Symbol-screener-with-triple-MA-and-RSI/ | Lenny_Kiruthu | https://www.tradingview.com/u/Lenny_Kiruthu/ | 47 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Lenny_Kiruthu
//@version=5
indicator(title="5 Symbol Forex with triple MA and RSI", shorttitle=" Triple MA and RSI Screener", overlay=true)
// USER INPUTS.
MA1Length = input.int(defval=21, title="MA1 Length", group="Moving Average Settings")
MA2Length = input.int(defval=50, title="MA2 Length", group="Moving Average Settings")
MA3Length = input.int(defval=200, title="MA3 Length", group="Moving Average Settings")
MA1Type = input.string(title="MA1 Type", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group="Moving Average Settings")
MA2Type = input.string(title="MA2 Type", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group="Moving Average Settings")
MA3Type = input.string(title="MA3 Type", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], group="Moving Average Settings")
MA1Source =input.source(title="MA1 Source", defval=close, group="Moving Average Settings")
MA2Source =input.source(title="MA1 Source", defval=close, group="Moving Average Settings")
MA3Source =input.source(title="MA1 Source", defval=close, group="Moving Average Settings")
MA1Timeframe = input.timeframe(title="MA1 Timeframe", defval="D", group="Moving Average Settings")
MA2Timeframe = input.timeframe(title="MA2 Timeframe", defval="D", group="Moving Average Settings")
MA3Timeframe = input.timeframe(title="MA3 Timeframe", defval="D", group="Moving Average Settings")
RSILength = input.int(defval=14, title="RSI Length", group="RSI Settings")
RSISource = input.source(defval=close, title="RSI Source", group="RSI Settings")
RSIOB = input.int(defval=70, title="RSI Overbought", group="RSI Settings")
RSIOS = input.int(defval=30, title="RSI Oversold", group="RSI Settings")
RSITimeframe = input.timeframe(defval="D", title="RSI Timeframe", group="RSI Settings")
s01 = input.symbol("AUDUSD", group="Symbols")
s02 = input.symbol("AUDJPY", group="Symbols")
s03 = input.symbol("GBPUSD", group="Symbols")
s04 = input.symbol("GBPJPY", group="Symbols")
s05 = input.symbol("USDCAD", group="Symbols")
// ma# is a variable used to store the actual moving average, once a user chooses a specific MA this code is run
ma1 = switch MA1Type
"RMA" => ta.rma(MA1Source,MA1Length)
"SMA" => ta.sma(MA1Source,MA1Length)
"EMA" => ta.ema(MA1Source,MA1Length)
"WMA" => ta.wma(MA1Source,MA1Length)
ma2 = switch MA2Type
"RMA" => ta.rma(MA2Source,MA2Length)
"SMA" => ta.sma(MA2Source,MA2Length)
"EMA" => ta.ema(MA2Source,MA2Length)
"WMA" => ta.wma(MA2Source,MA2Length)
ma3 = switch MA3Type
"RMA" => ta.rma(MA3Source,MA3Length)
"SMA" => ta.sma(MA3Source,MA3Length)
"EMA" => ta.ema(MA3Source,MA3Length)
"WMA" => ta.wma(MA3Source,MA3Length)
// Creating the function that calls from the daily timeframe and reads the first MA.
myScreener1(forex) =>
Close = request.security(forex, MA1Timeframe, close[0])
sma = ta.sma(MA1Source, MA1Length)
sma_htf = request.security(forex, MA1Timeframe, sma[0])
Close > sma_htf ? "Yes" : "No"
// Creating the function that calls from the daily timeframe and reads the second MA.
myScreener2(forex) =>
Close = request.security(forex, MA2Timeframe, close[0])
sma = ta.sma(MA2Source, MA2Length)
sma_htf = request.security(forex, MA2Timeframe, sma[0])
Close > sma_htf ? "Yes" : "No"
// Creating the function that calls from the daily timeframe and reads the third MA.
myScreener3(forex) =>
Close = request.security(forex, MA3Timeframe, close[0])
sma = ta.sma(MA3Source, MA3Length)
sma_htf = request.security(forex, MA3Timeframe, sma[0])
Close > sma_htf ? "Yes" : "No"
// Creating the function that calls from the daily timeframe and reads the RSI.
myScreener4(forex) =>
Close = request.security(forex, RSITimeframe, close[0])
rsi = ta.rsi(RSISource, RSILength)
rsi_htf = request.security(forex, RSITimeframe, rsi[0])
math.round(rsi_htf)
// Definig the back ground colors for the cells in the table
myBackground1(forex) =>
Close = request.security(forex, MA1Timeframe, close[0])
sma = ta.sma(MA1Source, MA1Length)
sma_htf = request.security(forex, MA1Timeframe, sma[0])
MA1Color = Close > sma_htf ? color.green : color.red
myBackground2(forex) =>
Close = request.security(forex, MA2Timeframe, close[0])
sma = ta.sma(MA2Source, MA2Length)
sma_htf = request.security(forex, MA2Timeframe, sma[0])
MA2Color = Close > sma_htf ? color.green : color.red
myBackground3(forex) =>
Close = request.security(forex, MA3Timeframe, close[0])
sma = ta.sma(MA3Source, MA3Length)
sma_htf = request.security(forex, MA3Timeframe, sma[0])
MA3Color = Close > sma_htf ? color.green : color.red
myBackground4(forex) =>
Close = request.security(forex, MA3Timeframe, close[0])
rsi = ta.rsi(RSISource, RSILength)
rsi_htf = request.security(forex, RSITimeframe, rsi[0])
rsi_htf > RSIOB ? color.red : rsi_htf < RSIOS ? color.green : color.gray
// Creating the table where all the indicators created in the functions will display the outcomes.
var myTable = table.new(position=position.top_right, columns=5, rows=11, bgcolor=color.black, border_width=1, frame_color=color.white, frame_width=4, border_color=color.white)
table.cell(table_id=myTable, column=0, row=0, text="FOREX", text_color=color.white, bgcolor=color.gray)
table.cell(table_id=myTable, column=0, row=1, text=s01, text_color=color.white, bgcolor=color.gray)
table.cell(table_id=myTable, column=0, row=2, text=s02, text_color=color.white, bgcolor=color.gray)
table.cell(table_id=myTable, column=0, row=3, text=s03, text_color=color.white, bgcolor=color.gray)
table.cell(table_id=myTable, column=0, row=4, text=s04, text_color=color.white, bgcolor=color.gray)
table.cell(table_id=myTable, column=0, row=5, text=s05, text_color=color.white, bgcolor=color.gray)
table.cell(table_id=myTable, column=1, row=0, text="Currency pair above the " +str.tostring(MA1Length)+ " \nperiod " +str.tostring(MA1Type), text_color=color.white, text_halign=text.align_left)
table.cell(table_id=myTable, column=1, row=1, text=str.tostring((myScreener1(s01))), text_color=color.white, bgcolor=myBackground1(s01))
table.cell(table_id=myTable, column=1, row=2, text=str.tostring((myScreener1(s02))), text_color=color.white, bgcolor=myBackground1(s02))
table.cell(table_id=myTable, column=1, row=3, text=str.tostring((myScreener1(s03))), text_color=color.white, bgcolor=myBackground1(s03))
table.cell(table_id=myTable, column=1, row=4, text=str.tostring((myScreener1(s04))), text_color=color.white, bgcolor=myBackground1(s04))
table.cell(table_id=myTable, column=1, row=5, text=str.tostring((myScreener1(s05))), text_color=color.white, bgcolor=myBackground1(s05))
table.cell(table_id=myTable, column=2, row=0, text="Currency pair above the " +str.tostring(MA2Length)+ " \nperiod " +str.tostring(MA2Type), text_color=color.white, text_halign=text.align_left)
table.cell(table_id=myTable, column=2, row=1, text=str.tostring((myScreener2(s01))), text_color=color.white, bgcolor=myBackground2(s01))
table.cell(table_id=myTable, column=2, row=2, text=str.tostring((myScreener2(s02))), text_color=color.white, bgcolor=myBackground2(s02))
table.cell(table_id=myTable, column=2, row=3, text=str.tostring((myScreener2(s03))), text_color=color.white, bgcolor=myBackground2(s03))
table.cell(table_id=myTable, column=2, row=4, text=str.tostring((myScreener2(s04))), text_color=color.white, bgcolor=myBackground2(s04))
table.cell(table_id=myTable, column=2, row=5, text=str.tostring((myScreener2(s05))), text_color=color.white, bgcolor=myBackground2(s05))
table.cell(table_id=myTable, column=3, row=0, text="Currency pair above the " +str.tostring(MA3Length)+ " \nperiod " +str.tostring(MA3Type), text_color=color.white, text_halign=text.align_left)
table.cell(table_id=myTable, column=3, row=1, text=str.tostring((myScreener3(s01))), text_color=color.white, bgcolor=myBackground3(s01))
table.cell(table_id=myTable, column=3, row=2, text=str.tostring((myScreener3(s02))), text_color=color.white, bgcolor=myBackground3(s02))
table.cell(table_id=myTable, column=3, row=3, text=str.tostring((myScreener3(s03))), text_color=color.white, bgcolor=myBackground3(s03))
table.cell(table_id=myTable, column=3, row=4, text=str.tostring((myScreener3(s04))), text_color=color.white, bgcolor=myBackground3(s04))
table.cell(table_id=myTable, column=3, row=5, text=str.tostring((myScreener3(s05))), text_color=color.white, bgcolor=myBackground3(s05))
table.cell(table_id=myTable, column=4, row=0, text="Currency pair value on the RSI", text_color=color.white)
table.cell(table_id=myTable, column=4, row=1, text=str.tostring((myScreener4(s01))), text_color=color.white, bgcolor=myBackground4(s01))
table.cell(table_id=myTable, column=4, row=2, text=str.tostring((myScreener4(s02))), text_color=color.white, bgcolor=myBackground4(s02))
table.cell(table_id=myTable, column=4, row=3, text=str.tostring((myScreener4(s03))), text_color=color.white, bgcolor=myBackground4(s03))
table.cell(table_id=myTable, column=4, row=4, text=str.tostring((myScreener4(s04))), text_color=color.white, bgcolor=myBackground4(s04))
table.cell(table_id=myTable, column=4, row=5, text=str.tostring((myScreener4(s05))), text_color=color.white, bgcolor=myBackground4(s05)) |
Hull Suite by MRonin added B&S signals | https://www.tradingview.com/script/VciL0ZVF/ | MRonin | https://www.tradingview.com/u/MRonin/ | 334 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MRonin
//@version=4
study("Hull Suite by MRonin", overlay=true)
//INPUT
src = input(close, title="Source")
modeSwitch = input("Hma", title="Hull Variation", options=["Hma", "Thma", "Ehma"])
length = input(55, title="Length(180-200 for floating S/R , 55 for swing entry)")
lengthMult = input(1.0, title="Length multiplier (Used to view higher timeframes with straight band)")
useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)")
htf = input("240", title="Higher timeframe", type=input.resolution)
switchColor = input(true, "Color Hull according to trend?")
candleCol = input(false,title="Color candles based on Hull's Trend?")
visualSwitch = input(true, title="Show as a Band?")
thicknesSwitch = input(1, title="Line Thickness")
transpSwitch = input(40, title="Band Transparency",step=5)
//FUNCTIONS
//HMA
HMA(_src, _length) => wma(2 * wma(_src, _length / 2) - wma(_src, _length), round(sqrt(_length)))
//EHMA
EHMA(_src, _length) => ema(2 * ema(_src, _length / 2) - ema(_src, _length), round(sqrt(_length)))
//THMA
THMA(_src, _length) => wma(wma(_src,_length / 3) * 3 - wma(_src, _length / 2) - wma(_src, _length), _length)
//SWITCH
Mode(modeSwitch, src, len) =>
modeSwitch == "Hma" ? HMA(src, len) :
modeSwitch == "Ehma" ? EHMA(src, len) :
modeSwitch == "Thma" ? THMA(src, len/2) : na
//OUT
_hull = Mode(modeSwitch, src, int(length * lengthMult))
HULL = useHtf ? security(syminfo.ticker, htf, _hull) : _hull
MHULL = HULL[0]
SHULL = HULL[2]
//COLOR
hullColor = switchColor ? (HULL > HULL[2] ? #00ff00 : #ff0000) : #ff9800
//PLOT
///< Frame
Fi1 = plot(MHULL, title="MHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)
Fi2 = plot(visualSwitch ? SHULL : na, title="SHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)
alertcondition(crossover(MHULL, SHULL), title="Hull trending up.", message="Hull trending up.")
alertcondition(crossover(SHULL, MHULL), title="Hull trending down.", message="Hull trending down.")
///< Ending Filler
fill(Fi1, Fi2, title="Band Filler", color=hullColor, transp=transpSwitch)
///BARCOLOR
barcolor(color = candleCol ? (switchColor ? hullColor : na) : na)
plotshape(crossover(MHULL, SHULL), size=size.small, style=shape.labelup, location=location.belowbar, color=color.green, text="AL-BUY", textcolor=color.white)
plotshape(crossover(SHULL, MHULL), size=size.small, style=shape.labeldown, location=location.abovebar, color=color.red, text="SAT-SELL", textcolor=color.white)
|
Infiten's Price Percentage Oscillator Channel (PPOC Indicator) | https://www.tradingview.com/script/uxpgitoo-Infiten-s-Price-Percentage-Oscillator-Channel-PPOC-Indicator/ | spiritualhealer117 | https://www.tradingview.com/u/spiritualhealer117/ | 48 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © spiritualhealer117
//@version=4
study("PPO Display")
len1 = input(title="Short MA Length", type=input.integer, defval=14)
len2 = input(title="Long MA Length", type=input.integer, defval=14)
thresh = input(title="PPO Threshold", type=input.float, defval=0.3)
smas=sma(close,len1)
smal=sma(close,len2)
PPO = (smas-smal)/smal
low_forecast = -thresh*smal+smal
high_forecast = thresh*smal+smal
plot(low_forecast, title="Low PPO Thresh", color=color.red, style=plot.style_circles)
plot(high_forecast, title="High PPO Thresh", color=color.green, style=plot.style_circles)
plotcandle(smas, high_forecast, low_forecast, smal, title = 'MA PPO', color = smas<smal ? color.red : color.green, wickcolor = color.black)
plot(smas, title="Short SMA", color=color.white)
plot(smal, title="Long SMA", color=color.gray) |
Fibonacci Zone Oscillator With MACD Histogram | https://www.tradingview.com/script/L2piavbm-Fibonacci-Zone-Oscillator-With-MACD-Histogram/ | eykpunter | https://www.tradingview.com/u/eykpunter/ | 255 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © eykpunter
//@version=5
indicator("Fibonacci Zone Oscillator With MACD Histogram", shorttitle="Fibzone+MACD Osc", overlay=false)
per=input.int(14, "calculate for last ## bars", minval=6)
perwish=input.bool(true, "script sets lookback")
perfeedback=input.bool(true, "show feedback label about lookback")
//Select all or one group; done this way to make sure someting is plotted.
bothwish=input.bool(true, "togle combination of columns and macd or just one", group="Select all or one")
onewish=input.bool(true, "togle fibzone columns / histgram with volume event marks", group="Select all or one")
fibwish= bothwish or onewish? true:false
macwish= bothwish or not onewish? true:false
//calculate periods by script if perwish == true
setper= 14 //initialize setper
tf=timeframe.period
setper:= tf=="M"? 14: tf=="W"? 14: tf=="D"? 21: tf=="240"? 28: tf=="180"? 28: tf=="120"? 35: tf=="60"? 35: tf=="45"? 35: tf=="30"? 42: tf=="15"? 42: tf=="5"? 49: tf=="3"? 49: tf=="1"? 56: 10
per:= perwish? setper : per
//set lookbacks for MACD histogram
slow = per
fast = math.round(per/2)
signal = math.round(per/3)
//Calculate Donchian Channel
hl=ta.highest(high,per) //High Line (Border)
ll=ta.lowest(low,per) //Low Line (Border)
//Calculate Fibonacci levels
dist=hl-ll //range of the Donchian channel
hf=hl-dist*0.236 //Highest Fibonacci line
cfh=hl-dist*0.382 //Center High Fibonacci line
cfl=hl-dist*0.618 //Center Low Fibonacci line
lf=hl-dist*0.764 //Lowest Fibonacci line
//Calculate relative position of close
posup=close>hf //in uptrend area
posabove=close<=hf and close> cfh //in prudent buyers area
posmiddle=close<=cfh and close>cfl //in center area
posunder=close<=cfl and close>lf //in prudent sellers area
posdown=close<=lf //in downtrend area
//Calculate percents of close
cent=(hl+ll)/2 //used as 100 % level
clocent1=close/cent*100-100 //percent of close for fibonacci oscillator
clocent=fibwish?clocent1:na //show columns if wished in inputs
//MACD histogram with equal percentrange as Fibonaccizone columns
emaF = ta.ema(close, fast)
emaS = ta.ema(close, slow)
emaFperc=emaF/cent*100
emaSperc=emaS/cent*100
macdperc = (emaFperc - emaSperc)
sig = ta.ema(macdperc, signal)
diff1 = (macdperc - sig)
factor=(ta.highest(clocent1, per)-ta.lowest(clocent1,per))/(ta.highest(diff1,per)-ta.lowest(diff1,per)) //factor to make histogram range equal to column range
diff=macwish?diff1*factor:na //show histogram if wished in inputs
//calculate column colors
poscol=posup? color.new(color.blue,00): posabove? color.new(color.lime,00): posmiddle? color.new(color.gray,00): posunder? color.new(color.orange,00): color.new(color.red, 00)
//plots
plot(diff, "diffarea", style=plot.style_area, color=color.rgb(230,250,220, 50), linewidth=0) //macd as area greenish off white
plot(clocent, title="% Close", style=plot.style_columns, color=poscol, linewidth=4) //fibzone oscillator
plot(diff, "diffline", style=plot.style_line, color=diff>0? color.new(color.purple, 00): color.new(color.purple, 00), linewidth=2) //macd as line purple
plot(diff, "diffhist", style=plot.style_histogram, color=color.rgb(240,180,40, 70), linewidth=2)//macd as histgram golden brown, very transparent
//feedback table
var table userorscript = table.new(position=position.bottom_left, columns=1, rows=1)
feedbacktext=perwish? "script lookback " +str.tostring(per) : "user lookback " +str.tostring(per)
if perfeedback == true
table.cell(userorscript, row=0, column=0, text=feedbacktext, bgcolor=color.silver)
else if perfeedback == false
table.clear(userorscript, 0, 0, 0, 0)
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.