1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
843 lines of Pine Script v5 from TradeEase.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
TradeEase.pine
// TradeEase v0.3
//@version=5
indicator("TradeEase"
, overlay = true
, max_labels_count = 500
, max_lines_count = 500
, max_boxes_count = 500
, max_bars_back = 500)
//-----------------------------------------------------------------------------{
//Constants
//-----------------------------------------------------------------------------{
color TRANSP_CSS = #ffffff00
//Tooltips
string MODE_TOOLTIP = 'Allows to display historical Structure or only the recent ones'
string STYLE_TOOLTIP = 'Indicator color theme'
string COLOR_CANDLES_TOOLTIP = 'Display additional candles with a color reflecting the current trend detected by structure'
string SHOW_INTERNAL = 'Display internal market structure'
string CONFLUENCE_FILTER = 'Filter non significant internal structure breakouts'
string SHOW_SWING = 'Display swing market Structure'
string SHOW_SWING_POINTS = 'Display swing point as labels 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'
//-----------------------------------------------------------------------------{
//Settings
//-----------------------------------------------------------------------------{
//General
//----------------------------------------{
mode = input.string('Historical' //creating an option in tooltip menu called Mode with options Historical and Present
, options = ['Historical', 'Present'] //with Historical being default and the group being TradeEase
, group = 'TradeEase'
, tooltip = MODE_TOOLTIP)
style = input.string('Colored' //creating an option in tooltip menu called Style with options Colored and Monochrome
, options = ['Colored', 'Monochrome'] //with Colored being default and the group being TradeEase
, group = 'TradeEase'
, tooltip = STYLE_TOOLTIP)
show_trend = input(false, 'Color Candles' //creating an option in tooltip menu called Color Candles that is a checkbox with it not being checked by default
, group = 'TradeEase'
, tooltip = COLOR_CANDLES_TOOLTIP)
//----------------------------------------}
//Internal Structure
//----------------------------------------{
show_internals = input(true, 'Show Internal Structure' //another tooltip option but in a different group called Real Time Internal Structure
, group = 'Real Time Internal Structure'
, tooltip = SHOW_INTERNAL)
show_ibull = input.string('All', 'Bullish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'ibull' //inline operator allows multiple inputs to be put in the same line
, group = 'Real Time Internal Structure')
swing_ibull_css = input(#089981, ''
, inline = 'ibull' //this is a color input that is the same line as the Bullish Structure input
, group = 'Real Time Internal Structure')
//Bear Structure
show_ibear = input.string('All', 'Bearish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'ibear'
, group = 'Real Time Internal Structure')
swing_ibear_css = input(#f23645, ''
, inline = 'ibear'
, group = 'Real Time Internal Structure')
ifilter_confluence = input(false, 'Confluence Filter'
, group = 'Real Time Internal Structure' //an option called the Confluence Filter that is a checkbox not checked by default
, tooltip = CONFLUENCE_FILTER)
internal_structure_size = input.string('Tiny', 'Internal Label Size'
, options = ['Tiny', 'Small', 'Normal']
, group = 'Real Time Internal Structure')
//----------------------------------------}
//Swing Structure
//----------------------------------------{
show_Structure = input(true, 'Show Swing Structure'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING)
//Bull Structure
show_bull = input.string('All', 'Bullish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'bull'
, group = 'Real Time Swing Structure')
swing_bull_css = input(#089981, ''
, inline = 'bull'
, group = 'Real Time Swing Structure')
//Bear Structure
show_bear = input.string('All', 'Bearish Structure'
, options = ['All', 'BOS', 'CHoCH']
, inline = 'bear'
, group = 'Real Time Swing Structure')
swing_bear_css = input(#f23645, ''
, inline = 'bear'
, group = 'Real Time Swing Structure')
swing_structure_size = input.string('Small', 'Swing Label Size'
, options = ['Tiny', 'Small', 'Normal']
, group = 'Real Time Swing Structure')
//Swings
show_swings = input(false, 'Show Swings Points'
, inline = 'swings'
, group = 'Real Time Swing Structure'
, tooltip = SHOW_SWING_POINTS)
length = input.int(50, ''
, minval = 10
, inline = 'swings'
, group = 'Real Time Swing Structure')
//----------------------------------------}
//Order Blocks
//----------------------------------------{
// This code defines several input variables related to order blocks.
// The first variable determines whether to show internal order blocks.
show_iob = input(true, 'Internal Order Blocks'
, inline = 'iob'
, group = 'Order Blocks'
, tooltip = INTERNAL_OB)
// The second variable determines how many of the most recent internal order blocks to display.
iob_showlast = input.int(5, ''
, minval = 1
, inline = 'iob'
, group = 'Order Blocks')
// The third variable determines whether to show swing order blocks.
show_ob = input(false, 'Swing Order Blocks'
, inline = 'ob'
, group = 'Order Blocks'
, tooltip = SWING_OB)
// The fourth variable determines how many of the most recent swing order blocks to display.
ob_showlast = input.int(5, ''
, minval = 1
, inline = 'ob'
, group = 'Order Blocks')
// The fifth variable determines which type of filter to apply to the swing order blocks.
ob_filter = input.string('Atr', 'Order Block Filter'
, options = ['Atr', 'Cumulative Mean Range']
, group = 'Order Blocks'
, tooltip = FILTER_OB)
// The next four variables determine the colors to use for each type of order block.
ibull_ob_css = input.color(color.new(#3179f5, 80), 'Internal Bullish OB'
, group = 'Order Blocks')
ibear_ob_css = input.color(color.new(#f77c80, 80), 'Internal Bearish OB'
, group = 'Order Blocks')
bull_ob_css = input.color(color.new(#1848cc, 80), 'Bullish OB'
, group = 'Order Blocks')
bear_ob_css = input.color(color.new(#b22833, 80), 'Bearish OB'
, group = 'Order Blocks')
////----------------------------------------}
//Previous day/week high/low // https://www.tradingview.com/script/07key9XM-Previous-Days-High-Low/
//----------------------------------------{
//Daily
show_pdhl = input(false, 'Daily' // by default fallse. if false doesn't execute
, inline = 'daily' // inline and group are paremeters of input function. inline in seeting asks in same line and group in particular group
, group = 'Highs & Lows MTF')
pdhl_style = input.string('⎯⎯⎯', '' // asks user what style of line should be used to show
, options = ['⎯⎯⎯', '----', '····'] // creates a drop down menu for user to choose from three styles
, inline = 'daily'
, group = 'Highs & Lows MTF')
pdhl_css = input(#2157f3, ''
, inline = 'daily'
, group = 'Highs & Lows MTF')
//Weekly
show_pwhl = input(false, 'Weekly' // same with all three functions until you turn it on, it will ot display anything
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_style = input.string('⎯⎯⎯', '' // '' is empty string is title which can be set to display but not included here
, options = ['⎯⎯⎯', '----', '····']
, inline = 'weekly'
, group = 'Highs & Lows MTF')
pwhl_css = input(#2157f3, ''
, inline = 'weekly'
, group = 'Highs & Lows MTF')
//Monthly
show_pmhl = input(false, 'Monthly'
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_style = input.string('⎯⎯⎯', ''
, options = ['⎯⎯⎯', '----', '····']
, inline = 'monthly'
, group = 'Highs & Lows MTF')
pmhl_css = input(#2157f3, ''
, inline = 'monthly'
, group = 'Highs & Lows MTF')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
n = bar_index //returns number of bars in the given time frae ie 4h or 1d since birth of chart
atr = ta.atr(200) //finds 200 period average true range
cmean_range = ta.cum(high - low) / n //finds culuminative mean range
//HL Output function
hl() => [high, low] //current high and low prices of asset.
//this is a one-line function as => is used and does not require return keyword
//Get ohlc values function //for swing measurement
get_ohlc()=> [close[1], open[1], high, low, high[2], low[2]]
//open,high,low,close prices of current and two previous bars
//Display Structure function
display_Structure(x, y, txt, css, dashed, down, lbl_size)=>
structure_line = line.new(x, y, n, y //creates a new line
, color = css
, style = dashed ? line.style_dashed : line.style_solid)
structure_lbl = label.new(int(math.avg(x, n)), y, txt
, color = TRANSP_CSS
, textcolor = css
, style = down ? label.style_label_down : label.style_label_up // location where you want the label to be
, size = lbl_size)
if mode == 'Present' //it is a parameter that allows our code to operate in 2 different modes:
// historial and present. When mode is 'Historical', function draws structure line and labe chart
//does not delete them.
//whereas present mode deletes the data after specified number of bars has passed.
//for structure levels that are still forming and might change in future.
//therefore it is after new values come to change it constantly
line.delete(structure_line[1])
label.delete(structure_lbl[1])
//Swings detection/measurements
swings(len)=>
var os = 0
upper = ta.highest(len) //finds highet and lowest part in given length
lower = ta.lowest(len)
os := high[len] > upper ? 0 : low[len] < lower ? 1 : os[1] //checks if current bar's price is high or low
// price is below or above the the swing high or low.
top = os == 0 and os[1] != 0 ? high[len] : 0 //calculates swing top
btm = os == 1 and os[1] != 1 ? low[len] : 0 //calculates swing btm
[top, btm] //returns top and bottom of swing
//Order block coordinates function
ob_coord(use_max, loc, target_top, target_btm, target_left, target_type)=>
min = 99999999. // initialize the minimum value
max = 0. // initialize the maximum value
idx = 1 // initialize the index value
ob_threshold = ob_filter == 'Atr' ? atr : cmean_range // set the filter threshold based on the filter condition
//Search for highest/lowest high within the structure interval and get range
if use_max // if use_max is true
for i = 1 to (n - loc)-1 // loop from i=1 to n-loc-1
if (high[i] - low[i]) < ob_threshold[i] * 2 // if difference between high and low value is less than ob_threshold*2
max := math.max(high[i], max) // update max to the higher value of high[i] and max
min := max == high[i] ? low[i] : min // if max is equal to high[i] then set min as low[i], otherwise keep min same
idx := max == high[i] ? i : idx // if max is equal to high[i] then set idx as i, otherwise keep idx same
else // if use_max is false
for i = 1 to (n - loc)-1 // loop from i=1 to n-loc-1
if (high[i] - low[i]) < ob_threshold[i] * 2 // if difference between high and low value is less than ob_threshold*2
min := math.min(low[i], min) // update min to the lower value of low[i] and min
max := min == low[i] ? high[i] : max // if min is equal to low[i] then set max as high[i], otherwise keep max same
idx := min == low[i] ? i : idx // if min is equal to low[i] then set idx as i, otherwise keep idx same
array.unshift(target_top, max) // add max value to the beginning of target_top array
array.unshift(target_btm, min) // add min value to the beginning of target_btm array
array.unshift(target_left, time[idx]) // add time[idx] value to the beginning of target_left array
array.unshift(target_type, use_max ? -1 : 1) // add -1 if use_max is true, else add 1 to the beginning of target_type array
//Set order blocks
display_ob(boxes, target_top, target_btm, target_left, target_type, show_last, swing, size) =>
for i = 0 to math.min(show_last-1, size-1) // loop from i=0 to minimum of (show_last-1) and (size-1)
get_box = array.get(boxes, i) // get the ith box from boxes array
box.set_lefttop(get_box, array.get(target_left, i), array.get(target_top, i)) // set left and top coordinates of the box using ith values from target_left and target_top arrays
box.set_rightbottom(get_box, array.get(target_left, i), array.get(target_btm, i)) // set right and bottom coordinates of the box using ith values from target_left and target_btm arrays
box.set_extend(get_box, extend.right) // set the extension of the box towards the right direction
color css = na // initialize the color css variable with na value
// This section defines the CSS style and border color of a box
if swing
// If swing exists, check the color style
if style == 'Monochrome'
// If the color style is Monochrome, assign a CSS color value based on the target type
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
// Assign the corresponding border color based on the target type
border_css = array.get(target_type, i) == 1 ? #b2b5be : #5d606b
// Set the border color of a box
box.set_border_color(get_box, border_css)
else
// If the color style is not Monochrome, assign CSS styles based on the target type
css := array.get(target_type, i) == 1 ? bull_ob_css : bear_ob_css
// Set the border color of a box
box.set_border_color(get_box, css)
// Set the background color of a box
box.set_bgcolor(get_box, css)
else
// If swing does not exist, assign CSS colors based on the target type
if style == 'Monochrome'
css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
else
css := array.get(target_type, i) == 1 ? ibull_ob_css : ibear_ob_css
// Set the border color of a box
box.set_border_color(get_box, css)
// Set the background color of a box
box.set_bgcolor(get_box, css)
// This section defines the line style function, which takes a string argument 'style'
get_line_style(style) =>
// Return a line style based on the value of the 'style' argument
out = switch style
'⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted
// This section defines the function 'phl', which sets the line and label for the previous high/lows of an asset
phl(h, l, tf, css) =>
// Define the high line and label, low line and label, and their corresponding x and y values
// Four variable declarations with `var` keyword.
var line high_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label high_lbl = label.new(na,na
, xloc = xloc.bar_time
, text = str.format('P{0}H', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
var line low_line = line.new(na,na,na,na
, xloc = xloc.bar_time
, color = css
, style = get_line_style(pdhl_style))
var label low_lbl = label.new(na,na
, xloc = xloc.bar_time
, text = str.format('P{0}L', tf)
, color = TRANSP_CSS
, textcolor = css
, size = size.small
, style = label.style_label_left)
// Two value assignments, `hx` and `lx`, using `ta.valuewhen()` function.
hy = ta.valuewhen(h != h[1], h, 1)
hx = ta.valuewhen(h == high, time, 1)
ly = ta.valuewhen(l != l[1], l, 1)
lx = ta.valuewhen(l == low, time, 1)
if barstate.islast
ext = time + (time - time[1])*20
//High
line.set_xy1(high_line, hx, hy)
line.set_xy2(high_line, ext, hy)
label.set_xy(high_lbl, ext, hy)
//Low
line.set_xy1(low_line, lx, ly)
line.set_xy2(low_line, ext, ly)
label.set_xy(low_lbl, ext, ly)
//-----------------------------------------------------------------------------}
//Global variables
//-----------------------------------------------------------------------------{
//Uddhav Jain . start
// need to check its functions above
var trend = 0, var itrend = 0 // trend is current trend direction. itrend is intermediate trend direction
// top_y stores price(y) of the last price peak
var top_y = 0., var top_x = 0 //top_x stores bar_index of last price peak.
//btm_y stoes price(y coordinate) of last price valley)
var btm_y = 0., var btm_x = 0// btm_x stores bar_index of last price valley
//same as top_y abt_y etc but for intermediate price peaks and valleys
var itop_y = 0., var itop_x = 0
var ibtm_y = 0., var ibtm_x = 0
//trail_up variable stores highest price. intialized to high price of current bar and will keep on chnging with each bar.
var trail_up = high, var trail_dn = low //similarly, lowest price of current bar
var trail_up_x = 0, var trail_dn_x = 0 // this stores bar index for above found values
// top_cross used to dtect if price has crossed above last price peak.
//btm_cross to detect if price passed below the last price valley.
var top_cross = true, var btm_cross = true // why is it inititalized to true?
var itop_cross = true, var ibtm_cross = true
//used to store lael text for peak and vallley.
var txt_top = '', var txt_btm = ''
//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
// var to track inverse CHO and inverse Balance of Power of earish
bear_ichoch_alert = false
bear_ibos_alert = false
// var to track Inside/Outside Bar IOB break
bull_iob_break = false
bear_iob_break = false
// var to track OB(Outside Bar) breaks
bull_ob_break = false
bear_ob_break = false
//Structure colors for bull and bearish marks
var bull_css = style == 'Monochrome' ? #b2b5be
: swing_bull_css
var bear_css = style == 'Monochrome' ? #b2b5be
: swing_bear_css
var ibull_css = style == 'Monochrome' ? #b2b5be
: swing_ibull_css
var ibear_css = style == 'Monochrome' ? #b2b5be
: swing_ibear_css
//Labels size
var internal_structure_lbl_size = internal_structure_size == 'Tiny' ? size.tiny
: internal_structure_size == 'Small' ? size.small
: size.normal
var swing_structure_lbl_size = swing_structure_size == 'Tiny' ? size.tiny
: swing_structure_size == 'Small' ? size.small
: size.normal
//Swings
[top, btm] = swings(length) // the swing function using length finds highest bar in given period and lowest bar given an array of them. Length can be defined by the user.
[itop, ibtm] = swings(5)
// Uddhav . end
//-----------------------------------------------------------------------------}
// Pivot High || SHREYAN [Start] · 02 / 28 / 23
//-----------------------------------------------------------------------------{
// This section works on the UI rendering / labeling aspect of a high in the chart.
var line extend_top = na
// Makes a new transparent label unanchored to any specific coordinates and small font size.
// Used later when creating strong high / weak high labels.
var label extend_top_lbl = label.new(na, na
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = size.tiny)
if top
top_cross := true
txt_top := top > top_y ? 'HH' : 'LH' // Updates the top text to 'HH' or 'LH' depending on the value of top.
// Displays a new label if the show swings option is turned on in the script settings.
if show_swings
top_lbl = label.new(n-length, top, txt_top
, color = TRANSP_CSS
, textcolor = bear_css
, style = label.style_label_down
, size = swing_structure_lbl_size)
// Else deletes the labels
if mode == 'Present'
label.delete(top_lbl[1])
//Extend recent top to last bar
// ???
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
// Sets the time frame's maximum highest value to the trail_up variable.
// If current high value is greater than the previously recorded value of up_trail, the variable is updated.
trail_up := math.max(high, trail_up)
trail_up_x := trail_up == high ? n : trail_up_x
//-----------------------------------------------------------------------------}
//Pivot Low
//-----------------------------------------------------------------------------{
// This section works on the UI rendering / labeling aspect of a low in the chart.
var line extend_btm = na
// Makes a new transparent label unanchored to any specific coordinates and small font size.
// Used later when creating strong low / weak low labels.
var label extend_btm_lbl = label.new(na, na
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = size.tiny)
if btm
btm_cross := true
txt_btm := btm < btm_y ? 'LL' : 'HL' // Updates the top text to 'LL' or 'HL' depending on the value of bottom.
// Displays a new label if the show swings option is turned on in the script settings.
if show_swings
btm_lbl = label.new(n - length, btm, txt_btm
, color = TRANSP_CSS
, textcolor = bull_css
, style = label.style_label_up
, size = swing_structure_lbl_size)
// Else deletes the labels
if mode == 'Present'
label.delete(btm_lbl[1])
//Extend recent btm to last bar
// ???
line.delete(extend_btm[1])
extend_btm := line.new(n - length, btm, n, btm
, 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
// Sets the time frame's minimum lowest value to the trail_down variable.
// If current low value is smaller than the previously recorded value of train_dn, the variable is updated.
trail_dn := math.min(low, trail_dn)
trail_dn_x := trail_dn == low ? n : trail_dn_x
// SHREYAN [End] · 02 / 28 / 23
//-----------------------------------------------------------------------------}
//Order Blocks Arrays
// ADITH [Start] 03.01.23
//-----------------------------------------------------------------------------{
var iob_top = array.new_float(0) //this section of code is used to initialize arrays
var iob_btm = array.new_float(0) //array.new_float(0) initializes an array of floats with size 0
var iob_left = array.new_int(0) //similarly with integers
var iob_type = array.new_int(0)
// this defines size of order block where significant buying
var ob_top = array.new_float(0)
var ob_btm = array.new_float(0)
var ob_left = array.new_int(0)
var ob_type = array.new_int(0)
//-----------------------------------------------------------------------------}
//Pivot High BOS/CHoCH
//-----------------------------------------------------------------------------{
//Filtering
var bull_concordant = true //initializing variable to be true
if ifilter_confluence //if condition that assesses if ifilter_confluence is true
bull_concordant := high - math.max(close, open) > math.min(close, open - low) //assigns true or false to bull_concordant depending on if difference between high and max of close and open is higher that min of close and (open-low)
//Detect internal bullish Structure
if ta.crossover(close, itop_y) and itop_cross and top_y != itop_y and bull_concordant
bool choch = na
if itrend < 0
choch := true
bull_ichoch_alert := true
else
bull_ibos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_internals
if show_ibull == 'All' or (show_ibull == 'BOS' and not choch) or (show_ibull == 'CHoCH' and choch)
display_Structure(itop_x, itop_y, txt, ibull_css, true, true, internal_structure_lbl_size)
itop_cross := false
itrend := 1
//Internal Order Block
if show_iob
ob_coord(false, itop_x, iob_top, iob_btm, iob_left, iob_type)
//Detect bullish Structure
if ta.crossover(close, top_y) and top_cross
bool choch = na
if trend < 0
choch := true
bull_choch_alert := true
else
bull_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bull == 'All' or (show_bull == 'BOS' and not choch) or (show_bull == 'CHoCH' and choch)
display_Structure(top_x, top_y, txt, bull_css, false, true, swing_structure_lbl_size)
//Order Block
if show_ob
ob_coord(false, top_x, ob_top, ob_btm, ob_left, ob_type)
top_cross := false
trend := 1
//-----------------------------------------------------------------------------}
//Pivot Low BOS/CHoCH
//-----------------------------------------------------------------------------{
var bear_concordant = true
if ifilter_confluence
bear_concordant := high - math.max(close, open) < math.min(close, open - low)
//Detect internal bearish Structure
if ta.crossunder(close, ibtm_y) and ibtm_cross and btm_y != ibtm_y and bear_concordant
bool choch = false
if itrend > 0
choch := true
bear_ichoch_alert := true
else
bear_ibos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_internals
if show_ibear == 'All' or (show_ibear == 'BOS' and not choch) or (show_ibear == 'CHoCH' and choch)
display_Structure(ibtm_x, ibtm_y, txt, ibear_css, true, false, internal_structure_lbl_size)
ibtm_cross := false
itrend := -1
//Internal Order Block
if show_iob
ob_coord(true, ibtm_x, iob_top, iob_btm, iob_left, iob_type)
//Detect bearish Structure
if ta.crossunder(close, btm_y) and btm_cross
bool choch = na
if trend > 0
choch := true
bear_choch_alert := true
else
bear_bos_alert := true
txt = choch ? 'CHoCH' : 'BOS'
if show_Structure
if show_bear == 'All' or (show_bear == 'BOS' and not choch) or (show_bear == 'CHoCH' and choch)
display_Structure(btm_x, btm_y, txt, bear_css, false, false, swing_structure_lbl_size)
//Order Block
if show_ob
ob_coord(true, btm_x, ob_top, ob_btm, ob_left, ob_type)
btm_cross := false
trend := -1
//-----------------------------------------------------------------------------}
//Order Blocks
//-----------------------------------------------------------------------------{
//Set order blocks
var iob_boxes = array.new_box(0) // create a array block which stores iob coordinates
var ob_boxes = array.new_box(0) //
//Delete internal order blocks box coordinates if top/bottom is broken
for element in iob_type //creates loop iob_type element
index = array.indexof(iob_type, element)
if close < array.get(iob_btm, index) and element == 1 // checks if the closing price is below bottom of internal order block and block is bullish it removes iob coordinatines
array.remove(iob_top, index) // and sets bull_iob_break var to true
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bull_iob_break := true
else if close > array.get(iob_top, index) and element == -1 // checks if closing price is above the top of an IOB and block is bearish. It removes coordinates of IOB
array.remove(iob_top, index) // and sets bear_iob_break = true
array.remove(iob_btm, index)
array.remove(iob_left, index)
array.remove(iob_type, index)
bear_iob_break := true // by default it is false, and when this happens it breaks so remove sit.
//Delete internal order blocks box coordinates if top/bottom is broken
for element in ob_type
index = array.indexof(ob_type, element)
if close < array.get(ob_btm, index) and element == 1
array.remove(ob_top, index)
array.remove(ob_btm, index)
array.remove(ob_left, index)
array.remove(ob_type, index)
bull_ob_break := true
else if close > array.get(ob_top, index) and element == -1
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
array.push(iob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if show_ob
for i = 0 to ob_showlast-1
array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))
if iob_size > 0
if barstate.islast
display_ob(iob_boxes, iob_top, iob_btm, iob_left, iob_type, iob_showlast, false, iob_size)
if ob_size > 0
if barstate.islast
display_ob(ob_boxes, ob_top, ob_btm, ob_left, ob_type, ob_showlast, true, ob_size)
////-----------------------------------------------------------------------------}
//Previous day/week high/lows
//-----------------------------------------------------------------------------{
//Daily high/low
[pdh, pdl] = request.security(syminfo.tickerid, 'D', hl()
, lookahead = barmerge.lookahead_on)
//Weekly high/low
[pwh, pwl] = request.security(syminfo.tickerid, 'W', hl()
, lookahead = barmerge.lookahead_on)
//Monthly high/low
[pmh, pml] = request.security(syminfo.tickerid, 'M', hl()
, lookahead = barmerge.lookahead_on)
//Display Daily
if show_pdhl
phl(pdh, pdl, 'D', pdhl_css)
//Display Weekly
if show_pwhl
phl(pwh, pwl, 'W', pwhl_css)
//Display Monthly
if show_pmhl
phl(pmh, pml, 'M', pmhl_css)
//-----------------------------------------------------------------------------}
//Trend
//-----------------------------------------------------------------------------{
var color trend_css = na
if show_trend
if style == 'Colored'
trend_css := itrend == 1 ? bull_css : bear_css
else if style == 'Monochrome'
trend_css := itrend == 1 ? #b2b5be : #5d606b
plotcandle(open, high, low, close
, color = trend_css
, wickcolor = trend_css
, bordercolor = trend_css
, editable = false)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//Internal Structure sms
alertcondition(bull_ibos_alert, 'Internal Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_ichoch_alert, 'Internal Bullish CHoCH', 'Internal Bullish CHoCH formed')
alertcondition(bear_ibos_alert, 'Internal Bearish BOS', 'Internal Bearish BOS formed')
alertcondition(bear_ichoch_alert, 'Internal Bearish CHoCH', 'Internal Bearish CHoCH formed')
//Swing Structure sms
alertcondition(bull_bos_alert, 'Bullish BOS', 'Internal Bullish BOS formed')
alertcondition(bull_choch_alert, 'Bullish CHoCH', 'Internal Bullish CHoCH formed')
alertcondition(bear_bos_alert, 'Bearish BOS', 'Bearish BOS formed')
alertcondition(bear_choch_alert, 'Bearish CHoCH', 'Bearish CHoCH formed')
//order Blocks sms
alertcondition(bull_iob_break, 'Bullish Internal OB Breakout', 'Price broke bullish internal OB')
alertcondition(bear_iob_break, 'Bearish Internal OB Breakout', 'Price broke bearish internal OB')
alertcondition(bull_ob_break, 'Bullish Swing OB Breakout', 'Price broke bullish swing OB')
alertcondition(bear_ob_break, 'Bearish Swing OB Breakout', 'Price broke bearish swing OB')
//-----------------------------------------------------------------------------}
Overview
TradeEase identifies internal and swing market structure changes, including Break of Structure (BOS) and Change of Character (CHoCH), as well as internal and swing order blocks. Key settings allow traders to filter volatile order blocks using ATR, toggle structure confluence filters, color candles according to trend structure, and display daily high and low levels. Higher-timeframe logic may utilize lookahead data.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
mode
string
Historical
mode
style
string
Colored
style
Color Candles
bool
false
show_trend
Show Internal Structure
bool
true
show_internals
Bullish Structure
string
All
show_ibull
swing_ibull_css
color
#089981
swing_ibull_css
Bearish Structure
string
All
show_ibear
swing_ibear_css
color
#f23645
swing_ibear_css
Confluence Filter
bool
false
ifilter_confluence
Internal Label Size
string
Tiny
internal_structure_size
Show Swing Structure
bool
true
show_Structure
Bullish Structure
string
All
show_bull
Show all 36 settings
Setting
Type
Default
Variable
swing_bull_css
color
#089981
swing_bull_css
Bearish Structure
string
All
show_bear
swing_bear_css
color
#f23645
swing_bear_css
Swing Label Size
string
Small
swing_structure_size
Show Swings Points
bool
false
show_swings
length
int
50
length
Internal Order Blocks
bool
true
show_iob
iob_showlast
int
5
iob_showlast
Swing Order Blocks
bool
false
show_ob
ob_showlast
int
5
ob_showlast
Order Block Filter
string
Atr
ob_filter
Internal Bullish OB
color
color.new(#3179f5, 80)
ibull_ob_css
Internal Bearish OB
color
color.new(#f77c80, 80)
ibear_ob_css
Bullish OB
color
color.new(#1848cc, 80)
bull_ob_css
Bearish OB
color
color.new(#b22833, 80)
bear_ob_css
Daily
bool
false
show_pdhl
pdhl_style
string
⎯⎯⎯
pdhl_style
pdhl_css
color
#2157f3
pdhl_css
Weekly
bool
false
show_pwhl
pwhl_style
string
⎯⎯⎯
pwhl_style
pwhl_css
color
#2157f3
pwhl_css
Monthly
bool
false
show_pmhl
pmhl_style
string
⎯⎯⎯
pmhl_style
pmhl_css
color
#2157f3
pmhl_css
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult
This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm
This indicator plots market structure on the price chart by identifying swing highs and lows. It connects these points with lines to visualize trend direction and detect Break of Structure (BOS) when price breaks a prior swing in the current trend. Change of C
This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart
BigBeluga Smart Money Concepts identifies and overlays market structure and volumetric order blocks directly on the price chart. It analyzes market swings, trend sweeps, and mapping structure using customizable pivot lengths and calculation modes. The indicato
Apex Trend & Liquidity Master calculates a trend cloud using customizable moving averages expanded by a volatility multiplier directly on the main price chart. It identifies dynamic support and resistance liquidity zones from swing high and low pivots, extendi