Pinescript
Pinescript
0)
https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
, overlay = true
, max_labels_count = 200
, max_lines_count = 200
, max_boxes_count = 200
, max_bars_back = 200)
//-----------------------------------------------------------------------------{
//Constants
//-----------------------------------------------------------------------------{
plotma=plot(ta.ema(close,200),color=color.green,linewidth=2)
//vwap
O_PERIOD1 = 'Session'
O_PERIOD2 = 'Week'
i_millisDay = 86400000
i_daysInWeek = 7
//#endregion }
if na(dwmBarTime)
dwmBarTime := nz(dwmBarTime[1])
dwmBarTime
(_dayOfWeek + 5) % 7
f_isMidnight(_t) =>
f_isOvernight() =>
f_tradingDayStart(_t) =>
_y = year(_t)
_m = month(_t)
_d = dayofmonth(_t)
_y1 = year(_time1)
_m1 = month(_time1)
_d1 = dayofmonth(_time1)
_y2 = year(_time2)
_m2 = month(_time2)
_d2 = dayofmonth(_time2)
_diff = math.abs(timestamp('GMT', _y1, _m1, _d1, 0, 0) - timestamp('GMT', _y2, _m2, _d2, 0, 0))
_diff / i_millisDay
f_isNewPeriod() =>
_isNew = false
if f_tradingDay != nz(f_tradingDay[1])
if i_period == 'Session'
_isNew
if i_period == 'Week'
_isNew
_isNew
//#endregion }
sumSrc = float(na)
sumVol = float(na)
sumSrc := nz(sumSrc[1], 0)
sumVol := nz(sumVol[1], 0)
if f_isNewPeriod()
periodStart := f_tradingDay
sumSrc := 0.0
sumVol := 0.0
sumVol
sumVol += volume
sumVol
// <color>
vwapDir == 1 ? color.green :
vwapDir == -1 ? color.red : na
// --------- Plot
plot(
vwapLine,
title = 'VWAP',
linewidth = 2,
color = c_vwap)
//Tooltips
string MODE_TOOLTIP = 'Allows to display historical Structure or only the recent ones'
string COLOR_CANDLES_TOOLTIP = 'Display additional candles with a color reflecting the current trend detected by
structure'
string SHOW_SWHL_POINTS = 'Highlight most recent strong and weak high/low points on the chart'
string INTERNAL_OB = 'Display internal order blocks on the chart\n\nNumber of internal order blocks to display
on the chart'
string SWING_OB = 'Display swing order blocks on the chart\n\nNumber of internal swing blocks to display on
the chart'
string FILTER_OB = 'Method used to filter out volatile order blocks \n\nIt is recommended to use the
cumulative mean range method when a low amount of data is available'
string SHOW_EQHL = 'Display equal highs and equal lows on the chart'
string EQHL_BARS = 'Number of bars used to confirm equal highs and equal lows'
string EQHL_THRESHOLD = 'Sensitivity threshold in a range (0, 1) used for the detection of equal highs & lows\n\
nLower values will return fewer but more pertinent results'
string EXTEND_FVG = 'Determine how many bars to extend the Fair Value Gap boxes on chart'
//-----------------------------------------------------------------------------{
//Settings
//-----------------------------------------------------------------------------{
//General
//----------------------------------------{
mode = input.string('Historical'
, tooltip = MODE_TOOLTIP)
style = input.string('Colored'
, tooltip = STYLE_TOOLTIP)
, tooltip = COLOR_CANDLES_TOOLTIP)
//----------------------------------------}
//Internal Structure
//----------------------------------------{
, tooltip = SHOW_INTERNAL)
, inline = 'ibull'
, inline = 'ibull'
, inline = 'ibear'
, inline = 'ibear'
, tooltip = CONFLUENCE_FILTER)
//----------------------------------------}
//Swing Structure
//----------------------------------------{
, tooltip = SHOW_SWING)
//Bull Structure
, inline = 'bull'
, inline = 'bull'
, inline = 'bear'
, inline = 'bear'
//Swings
, inline = 'swings'
, tooltip = SHOW_SWING_POINTS)
, minval = 10
, inline = 'swings'
, tooltip = SHOW_SWHL_POINTS)
//----------------------------------------}
//Order Blocks
//----------------------------------------{
, tooltip = INTERNAL_OB)
, minval = 1
, inline = 'iob'
, inline = 'ob'
, tooltip = SWING_OB)
, minval = 1
, inline = 'ob'
, tooltip = FILTER_OB)
//----------------------------------------}
//EQH/EQL
//----------------------------------------{
, group = 'EQH/EQL'
, tooltip = SHOW_EQHL)
, minval = 1
, group = 'EQH/EQL'
, tooltip = EQHL_BARS)
, minval = 0
, maxval = 0.5
, step = 0.1
, group = 'EQH/EQL'
, tooltip = EQHL_THRESHOLD)
, group = 'EQH/EQL')
//----------------------------------------}
//----------------------------------------{
, tooltip = SHOW_FVG)
, tooltip = FVG_TF)
, minval = 0
, tooltip = EXTEND_FVG)
//----------------------------------------}
//----------------------------------------{
//Daily
, inline = 'daily'
, inline = 'daily'
, inline = 'daily'
, inline = 'weekly'
, inline = 'weekly'
, inline = 'weekly'
//Monthly
, inline = 'monthly'
, inline = 'monthly'
, inline = 'monthly'
//----------------------------------------}
//Premium/Discount zones
//----------------------------------------{
, tooltip = PED_ZONES)
premium_css = input.color(#f23645, 'Premium Zone'
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index
atr = ta.atr(200)
structure_line = line.new(x, y, n, y
, color = css
, color = TRANSP_CSS
, textcolor = css
if mode == 'Present'
line.delete(structure_line[1])
label.delete(structure_lbl[1])
//Swings detection/measurements
swings(len)=>
var os = 0
upper = ta.highest(len)
lower = ta.lowest(len)
[top, btm]
min = 99999999.
max = 0.
idx = 1
//Search for highest/lowest high within the structure interval and get range
if use_max
for i = 1 to (n - loc)-1
else
for i = 1 to (n - loc)-1
array.unshift(target_top, max)
array.unshift(target_btm, min)
array.unshift(target_left, time[idx])
array.unshift(target_type, use_max ? -1 : 1)
get_box = array.get(boxes, i)
box.set_extend(get_box, extend.right)
color css = na
if swing
if style == 'Monochrome'
box.set_border_color(get_box, border_css)
else
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
else
if style == 'Monochrome'
else
box.set_border_color(get_box, css)
box.set_bgcolor(get_box, css)
get_line_style(style) =>
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
, xloc = xloc.bar_time
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
, xloc = xloc.bar_time
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
hy = ta.valuewhen(h != h[1], h, 1)
ly = ta.valuewhen(l != l[1], l, 1)
if barstate.islast
//High
//Low
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
var trend = 0, var itrend = 0
//Alerts
bull_choch_alert = false
bull_bos_alert = false
bear_choch_alert = false
bear_bos_alert = false
bull_ichoch_alert = false
bull_ibos_alert = false
bear_ichoch_alert = false
bear_ibos_alert = false
bull_iob_break = false
bear_iob_break = false
bull_ob_break = false
bear_ob_break = false
eqh_alert = false
eql_alert = false
//Structure colors
: swing_bull_css
: swing_bear_css
: swing_ibull_css
: swing_ibear_css
//Labels size
? size.tiny
: internal_structure_size == 'Small'
? size.small
: size.normal
? size.tiny
: swing_structure_size == 'Small'
? size.small
: size.normal
? size.tiny
: eq_size == 'Small'
? size.small
: size.normal
//Swings
//-----------------------------------------------------------------------------}
//Pivot High
//-----------------------------------------------------------------------------{
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.tiny)
if top
top_cross := true
if show_swings
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = swing_structure_lbl_size)
if mode == 'Present'
label.delete(top_lbl[1])
line.delete(extend_top[1])
extend_top := line.new(n-length, top, n, top
, color = bear_css)
top_y := top
top_x := n - length
trail_up := top
trail_up_x := n - length
if itop
itop_cross := true
itop_y := itop
itop_x := n - 5
//Trailing maximum
label.set_x(extend_top_lbl, n + 20)
label.set_y(extend_top_lbl, trail_up)
//-----------------------------------------------------------------------------}
//Pivot Low
//-----------------------------------------------------------------------------{
, textcolor = bull_css
, style = label.style_label_up
, size = size.tiny)
if btm
btm_cross := true
if show_swings
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = swing_structure_lbl_size)
if mode == 'Present'
label.delete(btm_lbl[1])
line.delete(extend_btm[1])
, color = bull_css)
btm_y := btm
btm_x := n-length
trail_dn := btm
trail_dn_x := n-length
if ibtm
ibtm_cross := true
ibtm_y := ibtm
ibtm_x := n - 5
//Trailing minimum
label.set_x(extend_btm_lbl, n + 20)
label.set_y(extend_btm_lbl, trail_dn)
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------{
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------{
//Filtering
bool choch = na
if itrend < 0
choch := true
bull_ichoch_alert := true
else
bull_ibos_alert := true
if show_internals
if show_ibull == 'All' or (show_ibull == 'BOS' and not choch) or (show_ibull == 'CHoCH' and choch)
itop_cross := false
itrend := 1
if show_iob
bool choch = na
if trend < 0
choch := true
bull_choch_alert := true
else
bull_bos_alert := true
if show_Structure
if show_bull == 'All' or (show_bull == 'BOS' and not choch) or (show_bull == 'CHoCH' and choch)
//Order Block
if show_ob
top_cross := false
trend := 1
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------{
if ifilter_confluence
if itrend > 0
choch := true
bear_ichoch_alert := true
else
bear_ibos_alert := true
if show_ibear == 'All' or (show_ibear == 'BOS' and not choch) or (show_ibear == 'CHoCH' and choch)
ibtm_cross := false
itrend := -1
if show_iob
bool choch = na
if trend > 0
choch := true
bear_choch_alert := true
else
bear_bos_alert := true
if show_Structure
if show_bear == 'All' or (show_bear == 'BOS' and not choch) or (show_bear == 'CHoCH' and choch)
//Order Block
if show_ob
btm_cross := false
trend := -1
//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bull_iob_break := true
array.remove(iob_top, index)
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bear_iob_break := true
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bull_ob_break := true
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bear_ob_break := true
iob_size = array.size(iob_type)
ob_size = array.size(ob_type)
if barstate.isfirst
if show_iob
for i = 0 to iob_showlast-1
if show_ob
for i = 0 to ob_showlast-1
if iob_size > 0
if barstate.islast
if ob_size > 0
if barstate.islast
//-----------------------------------------------------------------------------}
//EQH/EQL
//-----------------------------------------------------------------------------{
var eq_prev_top = 0.
var eq_top_x = 0
var eq_prev_btm = 0.
var eq_btm_x = 0
if show_eq
if eq_top
, color = bear_css
, style = line.style_dotted)
, color = #00000000
, textcolor = bear_css
, style = label.style_label_down
, size = eqhl_lbl_size)
if mode == 'Present'
line.delete(eqh_line[1])
label.delete(eqh_lbl[1])
eqh_alert := true
eq_prev_top := eq_top
eq_top_x := n-eq_len
if eq_btm
, color = bull_css
, style = line.style_dotted)
, color = #00000000
, textcolor = bull_css
, style = label.style_label_up
, size = eqhl_lbl_size)
eql_alert := true
if mode == 'Present'
line.delete(eql_line[1])
label.delete(eql_lbl[1])
eq_prev_btm := eq_btm
eq_btm_x := n-eq_len
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------{
float bullish_fvg_avg = na
float bearish_fvg_avg = na
bullish_fvg_cnd = false
bearish_fvg_cnd = false
if show_fvg
change_tf = timeframe.change(fvg_tf)
:0
//FVG conditions
and change_tf
and change_tf
//FVG Areas
if bullish_fvg_cnd
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
, border_color = bull_fvg_css
, bgcolor = bull_fvg_css))
if bearish_fvg_cnd
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
, border_color = bear_fvg_css
, bgcolor = bear_fvg_css))
for bx in bullish_fvg_min
box.delete(bx)
for bx in bearish_fvg_max
box.delete(bx)
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------{
//Daily high/low
, lookahead = barmerge.lookahead_on)
//Weekly high/low
, lookahead = barmerge.lookahead_on)
//Monthly high/low
, lookahead = barmerge.lookahead_on)
//Display Daily
if show_pdhl
//Display Weekly
if show_pwhl
//Display Monthly
if show_pmhl
//-----------------------------------------------------------------------------}
//Premium/Discount/Equilibrium zones
//-----------------------------------------------------------------------------{
, border_color = na)
, text = 'Premium'
, color = TRANSP_CSS
, textcolor = premium_css
, style = label.style_label_down
, size = size.small)
, border_color = na)
, text = 'Equilibrium'
, color = TRANSP_CSS
, textcolor = eq_css
, style = label.style_label_left
, size = size.small)
, border_color = na)
, text = 'Discount'
, color = TRANSP_CSS
, textcolor = discount_css
, style = label.style_label_up
, size = size.small)
label.set_xy(eq_lbl, n, avg)
box.set_rightbottom(discount, n, trail_dn)
//-----------------------------------------------------------------------------}
//Trend
//-----------------------------------------------------------------------------{
if show_trend
if style == 'Colored'
, color = trend_css
, wickcolor = trend_css
, bordercolor = trend_css
, editable = false)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//Internal Structure
//Swing Structure
//order Blocks
alertcondition(bull_iob_break, 'Bullish Internal OB Breakout', 'Price broke bullish internal OB')
//EQH/EQL
//FVG
//-----------------------------------------------------------------------------}
LINE_WIDTH1_STR => 1
LINE_WIDTH2_STR => 2
// ----------------------------------------------------------------------------
// Settings:
// {
var int max_tl = input.int(1, title="Max pair of lines", maxval=250, minval=1, group=GROUP_ATL)*2
var string _str_extend = input.string("Right", options=["Right", "Both ways"], title="Which way to extend lines",
group=GROUP_ATL)
var bool show_crosses = input.bool(false, title="Show crosses", tooltip="Instances when closing price of a bar has
crossed lower/upper trendlines", group=GROUP_ATL)
// }
// ----------------------------------------------------------------------------
// {
type fractal
int xloc = na
float yloc = na
int xloc_parent = na
float yloc_parent = na
var fractal[] arr_fract = array.new<fractal>() // Can be used for multiple purposes such as:
// (a) connecting trendlines but added condition to skip X no. of fractals in between
var line[] arr_ln_up = array.new_line() // Array of lines, newest elements inserted to front
init_fractal(int fract_type, int xloc, float yloc, int xparent, float yparent)=>
f = fractal.new()
f.up_or_down := fract_type
f.xloc := xloc
f.yloc := yloc
f.xloc_parent := xparent
f.yloc_parent := yparent
if f.up_or_down == TYPE_UP
array.unshift(arr_ln_up, ln)
array.unshift(arr_ln_dn, ln)
array.unshift(arr_fract, f)
f // <- return
// Clean up: Drop oldest trendlines, change colors for previous trendline
drop_and_roll(fractal f) =>
if array.size(arr_ln) > 1
line.delete(array.pop(arr_ln))
drop_and_roll(f)
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// A Fractal is always a Pivot H/L (but a Pivot H/L is not always a Fractal):
alertcondition(not na(ph) or not na(pl), title="New trendline formed", message="New trendline formed")
// {
if downfract
if upfract
// }
// Plotting fractals
// ----------------------------------------------------------------------------
// Finding crosses between closing price & pair of most recent trendlines
// ----------------------------------------------------------------------------
// @function get_slope()
// Solving for price at current x (bar_index), given two pairs of fractals with x values < bar_index.
// Plotting crosses
//plotshape(show_crosses and cross_upper, title = "Crossed upper trendline", style = shape.xcross, location =
location.belowbar, color = color.new(color = color.blue, transp = 50), size = size.small)
//plotshape(show_crosses and cross_lower, title = "Crossed lower trendline", style = shape.xcross, location =
location.abovebar, color = color.new(color = color.red, transp = 50), size = size.small)
up=src-(Multiplier*atr3)
up1 = nz(up[1],up)
dn=src+(Multiplier*atr3)
trenda = 1
trenda := trenda == -1 and close > dn1 ? 1 : trenda == 1 and close < up1 ? -1 : trenda
// Configuration
i_ma_type = input.string('EMA', title = 'Moving Average Type', options = ['SMA', 'EMA', 'WMA', 'RMA', 'McGinley'],
group = 'RSI Trailing Stop [UAlgo]')
f_rsi_lower = input.float(40, title = 'RSI Lower Bound', inline = 'rsi_bounds', group = 'RSI Trailing Stop [UAlgo]', minval
= 0, maxval = 100)
f_rsi_upper = input.float(60, title = 'RSI Upper Bound', inline = 'rsi_bounds', group = 'RSI Trailing Stop [UAlgo]', minval
= 0, maxval = 100)
b_show_midline = input.bool(false, title = 'Show Midline', inline = 'display', group = 'RSI Trailing Stop [UAlgo]')
b_color_candles = input.bool(false, title = 'Color Candles', inline = 'display', group = 'RSI Trailing Stop [UAlgo]')
ta.sma(_src, _length)
ta.ema(_src, _length)
ta.wma(_src, _length)
ta.rma(_src, _length)
var float md = na
md := na(md[1]) ? _src : md[1] + (_src - md[1]) / (0.6 * _length * math.pow(_src / md[1], 4))
md
switch _type
[upper_bound, lower_bound]
f_volatility = ta.atr(27)
if ta.crossover(ohlc4, f_upper_bound)
is_bullish := true
is_bearish := false
is_bearish
if ta.crossunder(close, f_lower_bound)
is_bullish := false
is_bearish := true
is_bearish
// Plotting
barcolor(f_candle_color)
// Alerts
if _condition
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ajithcpas
//@version=5
AUTO = "Auto"
DAILY = "Daily"
WEEKLY = "Weekly"
MONTHLY = "Monthly"
QUARTERLY = "Quarterly"
HALF_YEARLY = "Half-yearly"
YEARLY = "Yearly"
TRADITIONAL = "Traditional"
FIBONACCI = "Fibonacci"
CLASSIC = "Classic"
CAMARILLA = "Camarilla"
// Input fields
is_daily_based = input.bool(title="Use Daily-based Values", defval=true, tooltip="When this option is unchecked, CPR
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 CPR level calculation. If intraday OHLC values are different from daily-based values
(normal for stocks), the CPR levels will also differ.")
var p = array.new_float()
var tp = array.new_float()
var bp = array.new_float()
var r1 = array.new_float()
var s1 = array.new_float()
s1_show = input.bool(true, "", inline="S1/R1", group="CPR levels")
var r2 = array.new_float()
var s2 = array.new_float()
var r3 = array.new_float()
var s3 = array.new_float()
var s4 = array.new_float()
var r5 = array.new_float()
var s5 = array.new_float()
check_holidays = input.bool(true, "Check NSE/BSE holidays", group="Developing CPR levels", tooltip="Enable this
when the Dev CPR lines are not visible(i.e. there is a trading holiday in upcoming session).")
pivotX_open = float(na)
pivotX_open := nz(pivotX_open[1], open)
pivotX_high = float(na)
pivotX_low = float(na)
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 cpr_time_frame == AUTO
if timeframe.isintraday
else if timeframe.isdaily
resolution := "M"
else if timeframe.isweekly
resolution := "6M"
else
resolution := "12M"
resolution := "D"
resolution := "W"
resolution := "M"
resolution := "3M"
resolution := "12M"
resolution
line aLine = na
if array.size(arr_time) > 1
aLine := 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, style=line_style)
array.push(lines, aLine)
aLine
if show_labels or show_prices
display_text = ""
else
traditional() =>
array.push(r1, _r1)
array.push(s1, _s1)
array.push(r2, _r2)
array.push(s2, _s2)
array.push(r3, _r3)
array.push(s3, _s3)
array.push(r4, _r4)
array.push(s4, _s4)
array.push(r5, _r5)
array.push(s5, _s5)
fibonacci() =>
classic() =>
camarilla() =>
array.push(r5, r5_val)
temp = pivotX_Bottom
pivotX_Bottom := pivotX_Top
pivotX_Top := temp
array.push(p, pivotX_Median)
array.push(tp, pivotX_Top)
array.push(bp, pivotX_Bottom)
if kind == TRADITIONAL
traditional()
fibonacci()
classic()
camarilla()
resolution = get_pivot_resolution()
if na(prev) or na(curr)
else
math.max(prev, curr)
math.min(prev, curr)
else
is_time_change = ta.change(time(resolution)) != 0
if is_time_change
change_time := time
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
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
else if without_time_change
array.push(arr_time, start_time)
else
calc_pivot()
if array.size(arr_time) > 0
array.shift(arr_time)
array.shift(p)
array.shift(tp)
array.shift(bp)
if sr_show or hist_sr_show
array.shift(r0_5)
array.shift(s0_5)
array.shift(r1)
array.shift(s1)
array.shift(r1_5)
array.shift(s1_5)
array.shift(r2)
array.shift(s2)
array.shift(r2_5)
array.shift(s2_5)
array.shift(r3)
array.shift(s3)
array.shift(r3_5)
array.shift(s3_5)
array.shift(r4)
array.shift(s4)
if array.size(r4_5) > 0 and r4_5_show
array.shift(r4_5)
array.shift(s4_5)
array.shift(r5)
array.shift(s5)
is_change := true
runtime.error("Not enough intraday data to calculate CPR. Lower the CPR Timeframe or turn on the 'Use Daily-
based Values' option in the indicator settings.")
is_change := false
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(labels) > 0
label.delete(array.shift(labels))
for i = 0 to array.size(arr_time) - 2
draw_line(i, p, cpr_color)
for i = 0 to j
i = array.size(arr_time) - 2
isHoliday(_date) =>
is_holiday = (_date == timestamp(2024, 12, 25, 15, 30) or _date == timestamp(2025, 02, 26, 15, 30) or _date ==
timestamp(2025, 03, 14, 15, 30) or _date == timestamp(2025, 03, 31, 15, 30) or _date == timestamp(2025, 04, 10,
15, 30) or _date == timestamp(2025, 04, 14, 15, 30) or _date == timestamp(2025, 04, 18, 15, 30) or _date ==
timestamp(2025, 05, 01, 15, 30) or _date == timestamp(2025, 08, 15, 15, 30) or _date == timestamp(2025, 08, 27,
15, 30) or _date == timestamp(2025, 10, 02, 15, 30) or _date == timestamp(2025, 10, 21, 15, 30) or _date ==
timestamp(2025, 10, 22, 15, 30) or _date == timestamp(2025, 11, 05, 15, 30) or _date == timestamp(2025, 12, 25,
15, 30))
is_holiday
getDevEndTime() =>
ONE_DAY = 1000 * 60 * 60 * 24
var dev_end_time = 0
if resolution == "D"
else
if extend_dev_cpr_line
dev_end_time
drawLineAndLabel(_price, _line_color, _text, _text_color) =>
var dev_start_time = 0
dev_start_time := time_close(resolution)
var dev_end_time = 0
dev_end_time := getDevEndTime()
line.delete(_aLine[1])
if show_labels or show_prices
display_text = ""
else
label.delete(_aLabel[1])
_aLine
if dev_cpr_show
if dev_r1_show
if kind == FIBONACCI
if dev_s1_show
if kind == FIBONACCI