Saty, Double T - B, 123 Pattern, Profile
Saty, Double T - B, 123 Pattern, Profile
0
at https://mozilla.org/MPL/2.0/
// © Riptide88
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
at https://mozilla.org/MPL/2.0/
// © NewLifeRipon
//@version=5
indicator('Saty ATR Levels, Drawing max_bars_back', shorttitle='Saty ATR Levels',
overlay=true)
// max_bars_back(time, 5000)
var int pastBar = na
if barstate.islastconfirmedhistory
pastBar := bar_index - 2000
if barstate.islast
label.new(pastBar, 1, text = "Label text"),
// max_bars_back(time= 5000)
// Options
day_trading = 'Day'
multiday_trading = 'Multiday'
swing_trading = 'Swing'
position_trading = 'Position'
longterm_trading = 'Long-term'
trading_type = input.string(day_trading, 'Trading Type', options=[day_trading,
multiday_trading, swing_trading, position_trading, longterm_trading])
use_options_labels = input(true, 'Use Options Labels')
atr_length = input(14, 'ATR Length')
trigger_percentage = input(0.236, 'Trigger Percentage')
previous_close_level_color = input(color.white, 'Previous Close Level Color')
lower_trigger_level_color = input(color.yellow, 'Lower Trigger Level Color')
upper_trigger_level_color = input(color.aqua, 'Upper Trigger Level Color')
key_target_level_color = input(color.silver, 'Key Target Level Color')
atr_target_level_color = input(color.white, 'ATR Target Level Color')
intermediate_target_level_color = input(color.gray, 'Intermediate Target Level
Color')
show_all_fibonacci_levels = input(true, 'Show All Fibonacci Levels')
show_extensions = input(false, 'Show Extensions')
level_size = input(2, 'Level Size')
show_info = input(true, 'Show Info Label')
use_current_close = input(false, 'Use Current Close')
fast_ema = input(8, 'Fast EMA')
pivot_ema = input(21, 'Pivot EMA')
slow_ema = input(34, 'Slow EMA')
// Trend
price = close
fast_ema_value = ta.ema(price, fast_ema)
pivot_ema_value = ta.ema(price, pivot_ema)
slow_ema_value = ta.ema(price, slow_ema)
bullish = price >= fast_ema_value and fast_ema_value >= pivot_ema_value and
pivot_ema_value >= slow_ema_value
bearish = price <= fast_ema_value and fast_ema_value <= pivot_ema_value and
pivot_ema_value <= slow_ema_value
// Data
period_index = use_current_close ? 0 : 1
ticker = ticker.new(syminfo.prefix, syminfo.ticker, session=session.extended)
previous_close = request.security(ticker, timeframe_func(), close[period_index],
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
atr = request.security(ticker, timeframe_func(), ta.atr(atr_length)[period_index],
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
period_high = request.security(ticker, timeframe_func(), high,
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
period_low = request.security(ticker, timeframe_func(), low,
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
range_1 = period_high - period_low
tr_percent_of_atr = range_1 / atr * 100
lower_trigger = previous_close - trigger_percentage * atr
upper_trigger = previous_close + trigger_percentage * atr
lower_0382 = previous_close - atr * 0.382
upper_0382 = previous_close + atr * 0.382
lower_0500 = previous_close - atr * 0.5
upper_0500 = previous_close + atr * 0.5
lower_0618 = previous_close - atr * 0.618
upper_0618 = previous_close + atr * 0.618
lower_0786 = previous_close - atr * 0.786
upper_0786 = previous_close + atr * 0.786
lower_1000 = previous_close - atr
upper_1000 = previous_close + atr
lower_1236 = lower_1000 - atr * 0.236
upper_1236 = upper_1000 + atr * 0.236
lower_1382 = lower_1000 - atr * 0.382
upper_1382 = upper_1000 + atr * 0.382
lower_1500 = lower_1000 - atr * 0.5
upper_1500 = upper_1000 + atr * 0.5
lower_1618 = lower_1000 - atr * 0.618
upper_1618 = upper_1000 + atr * 0.618
lower_1786 = lower_1000 - atr * 0.786
upper_1786 = upper_1000 + atr * 0.786
lower_2000 = lower_1000 - atr
upper_2000 = upper_1000 + atr
lower_2236 = lower_2000 - atr * 0.236
upper_2236 = upper_2000 + atr * 0.236
lower_2382 = lower_2000 - atr * 0.382
upper_2382 = upper_2000 + atr * 0.382
lower_2500 = lower_2000 - atr * 0.5
upper_2500 = upper_2000 + atr * 0.5
lower_2618 = lower_2000 - atr * 0.618
upper_2618 = upper_2000 + atr * 0.618
lower_2786 = lower_2000 - atr * 0.786
upper_2786 = upper_2000 + atr * 0.786
lower_3000 = lower_2000 - atr
upper_3000 = upper_2000 + atr
// Add Labels
tr_vs_atr_color = color.green
if tr_percent_of_atr <= 70
tr_vs_atr_color := color.green
else if tr_percent_of_atr >= 90
tr_vs_atr_color := color.red
else
tr_vs_atr_color := color.orange
trading_mode = 'Day'
if trading_type == day_trading
trading_mode := 'Day'
else if trading_type == multiday_trading
trading_mode := 'Multiday'
else if trading_type == swing_trading
trading_mode := 'Swing'
else if trading_type == position_trading
trading_mode := 'Position'
else if trading_type == longterm_trading
trading_mode := 'Long-term'
else
trading_mode := ''
long_label = ''
short_label = ''
if use_options_labels
long_label := 'Calls'
short_label := 'Puts'
else
long_label := 'Long'
short_label := 'Short'
trend_color = color.orange
if bullish
trend_color := color.green
else if bearish
trend_color := color.red
else
trend_color := color.orange
// Add levels
plot(show_extensions ? lower_3000 : na, color=color.new(atr_target_level_color,
40), linewidth=level_size, title='-300.0%', style=plot.style_stepline)
//plot(show_all_fibonacci_levels and show_extensions ? lower_2786 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-278.6%', style=plot.style_stepline)
plot(show_extensions ? lower_2618 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='-261.8%', style=plot.style_stepline)
//plot(show_all_fibonacci_levels and show_extensions ? lower_2500 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-250.0%', style=plot.style_stepline)
//plot(show_all_fibonacci_levels and show_extensions ? lower_2382 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-238.2%', style=plot.style_stepline)
plot(show_extensions ? lower_2236 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='-223.6%', style=plot.style_stepline)
plot(show_extensions ? lower_2000 : na, color=color.new(atr_target_level_color,
40), linewidth=level_size, title='-200.0%', style=plot.style_stepline)
plot(show_all_fibonacci_levels and show_extensions ? lower_1786 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-178.6%', style=plot.style_stepline)
plot(show_extensions ? lower_1618 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='-161.8%', style=plot.style_stepline)
plot(show_all_fibonacci_levels and show_extensions ? lower_1500 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-150.0%', style=plot.style_stepline)
plot(show_all_fibonacci_levels and show_extensions ? lower_1382 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-138.2%', style=plot.style_stepline)
plot(show_extensions ? lower_1236 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='-123.6%', style=plot.style_stepline)
plot(lower_1000, color=color.new(atr_target_level_color, 40), linewidth=level_size,
title='-100%', style=plot.style_stepline)
plot(show_all_fibonacci_levels ? lower_0786 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-78.6%', style=plot.style_stepline)
plot(lower_0618, color=color.new(key_target_level_color, 40), linewidth=level_size,
title='-61.8%', style=plot.style_stepline)
plot(show_all_fibonacci_levels ? lower_0500 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-50.0%', style=plot.style_stepline)
plot(show_all_fibonacci_levels ? lower_0382 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='-38.2%', style=plot.style_stepline)
plot(lower_trigger, color=color.new(lower_trigger_level_color, 40),
linewidth=level_size, title='Lower Trigger', style=plot.style_circles)
plot(previous_close, color=color.new(previous_close_level_color, 40),
linewidth=level_size, title='Previous Close', style=plot.style_circles)
plot(upper_trigger, color=color.new(upper_trigger_level_color, 40),
linewidth=level_size, title='Upper Trigger', style=plot.style_circles)
plot(show_all_fibonacci_levels ? upper_0382 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='38.2%', style=plot.style_stepline)
plot(show_all_fibonacci_levels ? upper_0500 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='50.0%', style=plot.style_stepline)
plot(upper_0618, color=color.new(key_target_level_color, 40), linewidth=level_size,
title='61.8%', style=plot.style_stepline)
plot(show_all_fibonacci_levels ? upper_0786 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='78.6%', style=plot.style_stepline)
plot(upper_1000, color=color.new(atr_target_level_color, 40), linewidth=level_size,
title='100%', style=plot.style_stepline)
plot(show_extensions ? upper_1236 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='123.6%', style=plot.style_stepline)
plot(show_all_fibonacci_levels and show_extensions ? upper_1382 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='138.2%', style=plot.style_stepline)
plot(show_all_fibonacci_levels and show_extensions ? upper_1500 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='150.0%', style=plot.style_stepline)
plot(show_extensions ? upper_1618 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='161.8%', style=plot.style_stepline)
plot(show_all_fibonacci_levels and show_extensions ? upper_1786 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='178.6%', style=plot.style_stepline)
plot(show_extensions ? upper_2000 : na, color=color.new(atr_target_level_color,
40), linewidth=level_size, title='200.0%', style=plot.style_stepline)
plot(show_extensions ? upper_2236 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='223.6%', style=plot.style_stepline)
//plot(show_all_fibonacci_levels and show_extensions ? upper_2382 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='238.2%', style=plot.style_stepline)
//plot(show_all_fibonacci_levels and show_extensions ? upper_2500 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='250.0%', style=plot.style_stepline)
plot(show_extensions ? upper_2618 : na, color=color.new(key_target_level_color,
40), linewidth=level_size, title='261.8%', style=plot.style_stepline)
//plot(show_all_fibonacci_levels and show_extensions ? upper_2786 : na,
color=color.new(intermediate_target_level_color, 40), linewidth=level_size,
title='278.6%', style=plot.style_stepline)
plot(show_extensions ? upper_3000 : na, color=color.new(atr_target_level_color,
40), linewidth=level_size, title='300%', style=plot.style_stepline)
//@version=5
// ~~ ToolTips {
t1 = "Pivot period"
t2 = "Show pattern break, set the size, and coloring"
t3 = "Show the 1-2-3 Pattern"
t4 = "Enable the HH/HL/LL/LH labels"
// ~~}
// ~~ Inputs {
prd = input.int(10,title="Period",tooltip=t1)
visuell =
input.string("Diamond","",options=["Diamond","XCross","Cross","Flag","Square"],inli
ne="break")
colBull = input.color(#34fa03,"",inline="break")
colBear = input.color(#fc0303,"",inline="break")
size =
input.string(size.tiny,"",options=[size.tiny,size.small,size.normal,size.large,size
.huge],inline="break",tooltip=t2)
line.new(array.get(idx,1),array.get(pvts,1),bar_index,array.get(pvts,1),color=chart
.fg_color,style=line.style_dashed)
if showPattern
label.new(array.get(idx,2),array.get(pvts,2),text="1",color=color(na),textcolor=cha
rt.fg_color,style=label.style_label_up)
label.new(array.get(idx,1),array.get(pvts,1),text="2",color=color(na),textcolor=cha
rt.fg_color,style=label.style_label_down)
label.new(array.get(idx,0),array.get(pvts,0),text="3",color=color(na),textcolor=cha
rt.fg_color,style=label.style_label_up)
line.new(array.get(idx,2),array.get(pvts,2),array.get(idx,1),array.get(pvts,1),colo
r=color.rgb(78, 254, 3, 2))
line.new(array.get(idx,1),array.get(pvts,1),array.get(idx,0),array.get(pvts,0),colo
r=color.rgb(78, 255, 3, 2))
alert("Bullish 1-2-3 Pattern Identified on:
"+syminfo.ticker,alert.freq_once_per_bar_close)
pattern := false
if ta.crossunder(low,array.get(pvts,1)) and pattern
if array.get(pvts,0)<array.get(pvts,2) and array.get(pvts,0)>array.get(pvts,1)
if showBreak
label.new(bar_index,low,style=shape,color=colBear,size=size)
line.new(array.get(idx,1),array.get(pvts,1),bar_index,array.get(pvts,1),color=chart
.fg_color,style=line.style_dashed)
if showPattern
label.new(array.get(idx,2),array.get(pvts,2),text="1",color=color(na),textcolor=cha
rt.fg_color,style=label.style_label_down)
label.new(array.get(idx,1),array.get(pvts,1),text="2",color=color(na),textcolor=cha
rt.fg_color,style=label.style_label_up)
label.new(array.get(idx,0),array.get(pvts,0),text="3",color=color(na),textcolor=cha
rt.fg_color,style=label.style_label_down)
line.new(array.get(idx,2),array.get(pvts,2),array.get(idx,1),array.get(pvts,1),
color=#fa0303fa)
line.new(array.get(idx,1),array.get(pvts,1),array.get(idx,0),array.get(pvts,0),colo
r=#fa0303fa)
alert("Bearish 1-2-3 Pattern Identified on:
"+syminfo.ticker,alert.freq_once_per_bar_close)
pattern := false
// ~~ }
// ~~ Debugger only check break once {
if ta.change(array.get(pvts,1))
pattern := true
// ~~ }
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © HSAF
//@version=5
//==========================
//Inputs
//==========================
sessionType = input.string('Daily', 'Session Type', options=['Tokyo','London','New
York','Daily','Weekly', 'Monthly'])
//==========================
//Constants / Variable Declaration
//==========================
var int zoneStart = 0
int lookback = bar_index - zoneStart
var activeZone = false
vol() =>
smoothVol ? ta.ema(volume, 5) : volume
//Getting intrabar intial data
[dO, dC, dH, dL, dV] = request.security_lower_tf(syminfo.tickerid, dataTf, [open,
close, high, low, vol()])
//==========================
//Functions
//==========================
resetProfile(enable) =>
if enable
array.fill(vpGreen, 0)
array.fill(vpRed, 0)
array.clear(ltfOpen)
array.clear(ltfHigh)
array.clear(ltfLow)
array.clear(ltfClose)
array.clear(ltfVolume)
tr = ta.atr(1)
profileAdd(o, h, l, c, v, g, w) =>
//Array to store how much to distribute in each zone, on scale of 1 for full
gap size to 0
zoneDist = array.new_float(resolution, 0)
distSum = 0.0
// Going over each zone
for i = 0 to array.size(vpGreen) - 1
// Checking to see if cur bar is in zone
zoneTop = array.get(zoneBounds, i)
zoneBot = zoneTop - g
body_top = math.max(c, o)
body_bot = math.min(c, o)
itsgreen = c >= o
topwick = h - body_top
bottomwick = body_bot - l
body = body_top - body_bot
calcSession(update) =>
array.fill(vpGreen, 0)
array.fill(vpRed, 0)
if bar_index > lookback and update
gap = (profHigh - profLow) / resolution
// Putting each bar inside zone into the volume profile array
if array.size(ltfOpen) > 0
for j = 0 to array.size(ltfOpen) - 1
profileAdd(array.get(ltfOpen, j), array.get(ltfHigh, j),
array.get(ltfLow, j), array.get(ltfClose, j), array.get(ltfVolume, j), gap, 1)
pocLevel() =>
float maxVol = 0
int levelInd = 0
for i = 0 to array.size(vpRed) - 1
if array.get(vpRed, i) + array.get(vpGreen, i) > maxVol
maxVol := array.get(vpRed, i) + array.get(vpGreen, i)
levelInd := i
float outLevel = na
if levelInd != array.size(vpRed) - 1
outLevel := array.get(zoneBounds, levelInd) - (array.get(zoneBounds,
levelInd) - array.get(zoneBounds, levelInd+1)) / 2
outLevel
valueLevels(poc) =>
float gap = (profHigh - profLow) / resolution
float volSum = array.sum(vpRed) + array.sum(vpGreen)
float volCnt = 0
drawNewZone(update) =>
if bar_index > lookback and update and array.sum(vpGreen) + array.sum(vpRed) >
0
gap = (profHigh - profLow) / resolution
float leftMax = bar_index[lookback]
float rightMax = bar_index[int(lookback / 1.4)]
float rightMaxVol = array.max(vpGreen)+array.max(vpRed)
float buffer = gap / 10
if showProf
for i = 0 to array.size(vpRed) - 1
greenEnd = int(leftMax + (rightMax - leftMax) * (array.get(vpGreen,
i) / rightMaxVol))
redEnd = int(greenEnd + (rightMax - leftMax) * (array.get(vpRed, i)
/ rightMaxVol))
box.new(int(leftMax), array.get(zoneBounds, i) - buffer, greenEnd,
array.get(zoneBounds, i) - gap + buffer, bgcolor=bullCol, border_width=0)
box.new(greenEnd, array.get(zoneBounds, i) - buffer, redEnd,
array.get(zoneBounds, i) - gap + buffer, bgcolor=bearCol, border_width=0)
box.new(int(leftMax), profHigh, bar_index-1, profLow, chart.fg_color,
boxWid, line.style_dashed, bgcolor=color.rgb(0,0,0,100))
poc = pocLevel()
[val, vah] = valueLevels(poc)
if showPoc
line.new(int(leftMax), poc, bar_index-1, poc, color=pocCol,
width=pocWid)
if showVA
line.new(int(leftMax), vah, bar_index-1, vah, color=vahCol,
width=vahWid)
line.new(int(leftMax), val, bar_index-1, val, color=valCol,
width=valWid)
//if update
// resetProfile(true)
drawCurZone(update) =>
var line pocLine = na
var line vahLine = na
var line valLine = na
var box outBox = na
poc = pocLevel()
[val, vah] = valueLevels(poc)
if showPoc
line.new(int(leftMax), poc, bar_index-1, poc, color=pocCol,
width=pocWid)
if showVA
line.new(int(leftMax), vah, bar_index-1, vah, color=vahCol,
width=vahWid)
line.new(int(leftMax), val, bar_index-1, val, color=valCol,
width=valWid)
updateIntra(o, h, l, c, v) =>
if array.size(o) > 0
for i = 0 to array.size(o) - 1
array.push(ltfOpen, array.get(o, i))
array.push(ltfHigh,array.get(h, i))
array.push(ltfLow,array.get(l, i))
array.push(ltfClose,array.get(c, i))
array.push(ltfVolume,array.get(v, i))
//==========================
//Calculations
//==========================
//Detecting different start dates
newDaily = dayofweek != dayofweek[1]
newWeekly = (dayofweek != dayofweek[1] + 1) and (dayofweek != dayofweek[1])
newMonthly = (dayofmonth != dayofmonth[1] + 1) and (dayofmonth != dayofmonth[1])
if newSession
zoneStart := bar_index
activeZone := true
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
at https://mozilla.org/MPL/2.0/
// © NewLifeRipon
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © Nephew_Sam_
//@version=5
// --------------- INPUTS ---------------
var GRP1 = "•••••••••• INTRADAY TIMEFRAMES ••••••••••"
// 1
ltimeframe1Show = input.bool(true, title='', inline='1', group=GRP1)
ltimeframe1 = input.timeframe('15', title='', inline='1', group=GRP1)
lleftBars1 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP1,
inline='1')
lrightBars1 = input.int(defval=7, title='Right', minval=2, maxval=20, group=GRP1,
inline='1', tooltip="Highest/lowest point in x right and left bars.")
// 2
ltimeframe2Show = input.bool(true, title='', inline='2', group=GRP1)
ltimeframe2 = input.timeframe('30', title='', inline='2', group=GRP1)
lleftBars2 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP1,
inline='2')
lrightBars2 = input.int(defval=7, title='Right', minval=2, maxval=20, group=GRP1,
inline='2', tooltip="Highest/lowest point in x right and left bars.")
// 3
ltimeframe3Show = input.bool(true, title='', inline='3', group=GRP1)
ltimeframe3 = input.timeframe('60', title='', inline='3', group=GRP1)
lleftBars3 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP1,
inline='3')
lrightBars3 = input.int(defval=6, title='Right', minval=2, maxval=20, group=GRP1,
inline='3', tooltip="Highest/lowest point in x right and left bars.")
// 4
ltimeframe4Show = input.bool(true, title='', inline='4', group=GRP1)
ltimeframe4 = input.timeframe('120', title='', inline='4', group=GRP1)
lleftBars4 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP1,
inline='4')
lrightBars4 = input.int(defval=6, title='Right', minval=2, maxval=20, group=GRP1,
inline='4', tooltip="Highest/lowest point in x right and left bars.")
// 5
ltimeframe5Show = input.bool(true, title='', inline='5', group=GRP1)
ltimeframe5 = input.timeframe('240', title='', inline='5', group=GRP1)
lleftBars5 = input.int(defval=6, title='Left', minval=2, maxval=20, group=GRP1,
inline='5')
lrightBars5 = input.int(defval=6, title='Right', minval=2, maxval=20, group=GRP1,
inline='5', tooltip="Highest/lowest point in x right and left bars.")
// 6
ltimeframe6Show = input.bool(true, title='', inline='6', group=GRP1)
ltimeframe6 = input.timeframe('D', title='', inline='6', group=GRP1)
lleftBars6 = input.int(defval=5, title='Left', minval=2, maxval=20, group=GRP1,
inline='6')
lrightBars6 = input.int(defval=5, title='Right', minval=2, maxval=20, group=GRP1,
inline='6', tooltip="Highest/lowest point in x right and left bars.")
// 2
htimeframe2Show = input.bool(true, title='', inline='2', group=GRP2)
htimeframe2 = input.timeframe('D', title='', inline='2', group=GRP2)
hleftBars2 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP2,
inline='2')
hrightBars2 = input.int(defval=7, title='Right', minval=2, maxval=20, group=GRP2,
inline='2', tooltip="Highest/lowest point in x right and left bars.")
// 3
htimeframe3Show = input.bool(true, title='', inline='3', group=GRP2)
htimeframe3 = input.timeframe('3D', title='', inline='3', group=GRP2)
hleftBars3 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP2,
inline='3')
hrightBars3 = input.int(defval=6, title='Right', minval=2, maxval=20, group=GRP2,
inline='3', tooltip="Highest/lowest point in x right and left bars.")
// 4
htimeframe4Show = input.bool(true, title='', inline='4', group=GRP2)
htimeframe4 = input.timeframe('W', title='', inline='4', group=GRP2)
hleftBars4 = input.int(defval=7, title='Left', minval=2, maxval=20, group=GRP2,
inline='4')
hrightBars4 = input.int(defval=6, title='Right', minval=2, maxval=20, group=GRP2,
inline='4', tooltip="Highest/lowest point in x right and left bars.")
// 5
htimeframe5Show = input.bool(true, title='', inline='5', group=GRP2)
htimeframe5 = input.timeframe('M', title='', inline='5', group=GRP2)
hleftBars5 = input.int(defval=6, title='Left', minval=2, maxval=20, group=GRP2,
inline='5')
hrightBars5 = input.int(defval=6, title='Right', minval=2, maxval=20, group=GRP2,
inline='5', tooltip="Highest/lowest point in x right and left bars.")
// 6
htimeframe6Show = input.bool(false, title='', inline='6', group=GRP2)
htimeframe6 = input.timeframe('2M', title='', inline='6', group=GRP2)
hleftBars6 = input.int(defval=5, title='Left', minval=2, maxval=20, group=GRP2,
inline='6')
hrightBars6 = input.int(defval=5, title='Right', minval=2, maxval=20, group=GRP2,
inline='6', tooltip="Highest/lowest point in x right and left bars.")
topColor6 = color.new(color.red, 5)
bottomColor6 = color.rgb(0, 230, 23, 5)
lineLength6 = 15
// --------------- COLORS AND LENGTH ---------------
pl = ta.pivotlow(lb, rb)
pltimestart = pl ? time[rb-1] : na
getLineStyle(_style) =>
_linestyle = _style == "Solid" ? line.style_solid : _style == "Dashed" ?
line.style_dashed : line.style_dotted
_linestyle
notLowerTimeframe(tf) =>
_cond = hideLTF ? resolutionInMinutes() < resolutionInMinutes(tf) : true
_cond
// ▓ ▒ ░ ░
_text
// --------------- FUNCTIONS ---------------
// Timeframe 1
if showTimeframe1 and pivothigh1 and validTimeframe1
label.new(phtimestart1, ph1, xloc=xloc.bar_time,
text=generateText(lineLength1), style=label.style_none, textcolor=topColor1)
if showTimeframe1 and pivotlow1 and validTimeframe1
label.new(pltimestart1, pl1, xloc=xloc.bar_time,
text=generateText(lineLength1), style=label.style_none, textcolor=bottomColor1)
// Timeframe 2
showTimeframe2 = isLtf ? ltimeframe2Show : htimeframe2Show
validTimeframe2 = isLtf ? notLowerTimeframe(ltimeframe2) :
notLowerTimeframe(htimeframe2)
if showTimeframe2 and pivothigh2 and validTimeframe2
label.new(phtimestart2, ph2, xloc=xloc.bar_time,
text=generateText(lineLength2), style=label.style_none, textcolor=topColor2)
if showTimeframe2 and pivotlow2 and validTimeframe2
label.new(pltimestart2, pl2, xloc=xloc.bar_time,
text=generateText(lineLength2), style=label.style_none, textcolor=bottomColor2)
// Timeframe 3
showTimeframe3 = isLtf ? ltimeframe3Show : htimeframe3Show
validTimeframe3 = isLtf ? notLowerTimeframe(ltimeframe3) :
notLowerTimeframe(htimeframe3)
if showTimeframe3 and pivothigh3 and validTimeframe3
label.new(phtimestart3, ph3, xloc=xloc.bar_time,
text=generateText(lineLength3), style=label.style_none, textcolor=topColor3)
if showTimeframe3 and pivotlow3 and validTimeframe3
label.new(pltimestart3, pl3, xloc=xloc.bar_time,
text=generateText(lineLength3), style=label.style_none, textcolor=bottomColor3)
// Timeframe 4
showTimeframe4 = isLtf ? ltimeframe4Show : htimeframe4Show
validTimeframe4 = isLtf ? notLowerTimeframe(ltimeframe4) :
notLowerTimeframe(htimeframe4)
if showTimeframe4 and pivothigh4 and validTimeframe4
label.new(phtimestart4, ph4, xloc=xloc.bar_time,
text=generateText(lineLength4), style=label.style_none, textcolor=topColor4)
if showTimeframe4 and pivotlow4 and validTimeframe4
label.new(pltimestart4, pl4, xloc=xloc.bar_time,
text=generateText(lineLength4), style=label.style_none, textcolor=bottomColor4)
// Timeframe 5
showTimeframe5 = isLtf ? ltimeframe5Show : htimeframe5Show
validTimeframe5 = isLtf ? notLowerTimeframe(ltimeframe5) :
notLowerTimeframe(htimeframe5)
if showTimeframe5 and pivothigh5 and validTimeframe5
label.new(phtimestart5, ph5, xloc=xloc.bar_time, text=generateText(lineLength5,
true), style=label.style_none, textcolor=topColor5)
if showTimeframe5 and pivotlow5 and validTimeframe5
label.new(pltimestart5, pl5, xloc=xloc.bar_time, text=generateText(lineLength5,
true), style=label.style_none, textcolor=bottomColor5)
// Timeframe 6
showTimeframe6 = isLtf ? ltimeframe6Show : htimeframe6Show
validTimeframe6 = isLtf ? notLowerTimeframe(ltimeframe6) :
notLowerTimeframe(htimeframe6)
if showTimeframe6 and pivothigh6 and validTimeframe6
label.new(phtimestart6, ph6, xloc=xloc.bar_time, text=generateText(lineLength6,
true), style=label.style_none, textcolor=topColor6)
if showTimeframe6 and pivotlow6 and validTimeframe6
label.new(pltimestart6, pl6, xloc=xloc.bar_time, text=generateText(lineLength6,
true), style=label.style_none, textcolor=bottomColor6)
// --------------- Plot pivot points ---------------
// WATERMARK
if barstate.islast
_table = table.new("bottom_left", 1, 1)
table.cell(_table, 0, 0, text="@Nephew_Sam_", text_size=size.small,
text_color=color.new(color.gray, 50))
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © protradingart
//@version=5
ph = ta.pivothigh(pivotLeg, pivotLeg)
pl = ta.pivotlow(pivotLeg, pivotLeg)
if array.size(top) > 3
array.shift(top)
array.shift(topIndex)
if array.size(bottom) > 3
array.shift(bottom)
array.shift(bottomIndex)
if inRange
topStart = array.get(topIndex, array.size(topIndex)-1)
topPrice := array.get(top, array.size(top)-1)
isTop := high >= topPrice and high[1] < topPrice and low < topPrice and
array.get(bottom, array.size(top)-1) > array.get(bottom, array.size(top)-2)
var topEnd = 0
if isTop
topEnd := bar_index
topLine = line.new(x1=topStart, y1=topPrice, x2=topEnd, y2=topPrice,
color=color.lime, width=1)
topA = label.new(x=topStart, y=topPrice, text="Top 1", color=color.lime,
style=label.style_label_down, textcolor=color.black, size=size.small)
topB = label.new(x=topEnd, y=topPrice, text="Top 2", color=color.lime,
style=label.style_label_down, textcolor=color.black, size=size.small)
alert("Double Top In: "+str.tostring(syminfo.ticker),
alert.freq_once_per_bar_close)
////////////////////////// Bottom
Calculation //////////////////////////////////////////////////////
bottomPrice = 0.0
isBottom = false
if inRange
bottomStart = array.get(bottomIndex, array.size(bottomIndex)-1)
bottomPrice := array.get(bottom, array.size(bottom)-1)
isBottom := low <= bottomPrice and low[1] > bottomPrice and high > bottomPrice
and array.get(top, array.size(top)-1) < array.get(top, array.size(top)-2)
var bottomEnd = 0
if isBottom
bottomEnd := bar_index
bottomLine = line.new(x1=bottomStart, y1=bottomPrice, x2=bottomEnd,
y2=bottomPrice, color=color.red, width=1)
bottomA = label.new(x=bottomStart, y=bottomPrice, text="Bottom 1",
color=color.red, style=label.style_label_up, textcolor=color.black, size=size.tiny)
bottomB = label.new(x=bottomEnd, y=bottomPrice, text="Bottom 2",
color=color.red, style=label.style_label_up, textcolor=color.black, size=size.tiny)
alert("Double Bottom In: "+str.tostring(syminfo.ticker),
alert.freq_once_per_bar_close)