Indicator · Pine Script v5 · On the chart

Mc War v2

by tuanmcwar

This indicator plots market structure elements directly on the price chart.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code801
Settings22inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago31 Aug 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

801 lines of Pine Script v5 from Mcwarv2v3.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Mcwarv2v3.pine
// @version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/


indicator('Mc War v2', overlay = true
  
  , max_bars_back = 500)


//-----------------------------------------------------------------------------{
//Constants
//-----------------------------------------------------------------------------{

    
color TRANSP_CSS = #f3f3f300




//-----------------------------------------------------------------------------{
//General
//----------------------------------------{

style = input.string ('100%',"Winrate",
  options = ['100%', '80%', '50%']
  , group = 'Win rate'
  )



//----------------------------------------}
//Swing Structure
//----------------------------------------{
show_Structure = input(true, 'Hiện Swing Structure'
  , group = 'Structure Thực'
  )

//Bull Structure
show_bull = input.string('All', 'Bullish Structure'
  , options = ['All', 'BOS', 'CHoCH']
  , inline = 'bull'
  , group = 'Structure Thực')

swing_bull_css = input(#089981, ''
  , inline = 'bull'
  , group = 'Structure Thực')

//Bear Structure
show_bear = input.string('All', 'Bearish Structure'
  , options = ['All', 'BOS', 'CHoCH']
  , inline = 'bear'
  , group = 'Structure Thực')

swing_bear_css = input(#f23645, ''
  , inline = 'bear'
  , group = 'Structure Thực')

swing_structure_size = input.string('Small', 'Swing Label Size'
  , options = ['Tiny', 'Small', 'Normal']
  , group = 'Structure Thực')

//Swings
show_swings = input(false, 'Hiện Swings Points'
  , inline = 'swings'
  , group = 'Structure Thực'
  )

length = input.int(50, ''
  , minval = 10
  , inline = 'swings'
  , group = 'Structure Thực')

show_hl_swings = input(false, 'Hiện Strong/Weak High/Low'
  , group = 'Structure Thực'
  )

//----------------------------------------}
//Order Blocks
//----------------------------------------{


show_ob = input(true, 'Swing Order Blocks'
  , inline = 'ob'
  , group = 'Order Blockss'
 )

ob_showlast = input.int(5, ''
  , minval = 1
  , inline = 'ob',
   group = 'Order Blockss'
 )



bull_ob_css = input.color(color.new(#787b86, 80), 'Bullish OB'
  , group = 'Order Blockss')

bear_ob_css = input.color(color.new(#787b86, 80), 'Bearish OB'
  , group = 'Order Blockss')

//----------------------------------------}

//----------------------------------------}

//Functions
//-----------------------------------------------------------------------------{
n = bar_index,
 ob_filter= true

atr = ta.atr(200)
cmean_range = ta.cum(high - low) / n

//HL Output function
hl() => [high, low]

//Get ohlc values function
get_ohlc()=> [close[1], open[1], high, low, high[2], low[2]]

//Display Structure function
display_Structure(x, y, txt, css, dashed, down, lbl_size)=>
    structure_line = line.new(x, y, n, y
      , 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
      , size = lbl_size)

  
//Swings detection/measurements
swings(len)=>
    var os = 0
    
    upper = ta.highest(len)
    lower = ta.lowest(len)

    os := high[len] > upper ? 0 : low[len] < lower ? 1 : os[1]

    top = os == 0 and os[1] != 0 ? high[len] : 0
    btm = os == 1 and os[1] != 1 ? low[len] : 0

    [top, btm]

//Order block coordinates function
ob_coords(use_max, loc, target_top, target_btm, target_left, target_type)=>
    min = 99999999.
    max = 0.
    idx = 1

    ob_threshold = ob_filter == true? atr : cmean_range 

    //Search for highest/lowest high within the structure interval and get range
    if use_max
        for i = 1 to (n - loc)-1
            if (high[i] - low[i]) < ob_threshold[i] * 2
                max := math.max(high[i], max)
                min := max == high[i] ? low[i] : min
                idx := max == high[i] ? i : idx
    else
        for i = 1 to (n - loc)-1
            if (high[i] - low[i]) < ob_threshold[i] * 2
                min := math.min(low[i], min)
                max := min == low[i] ? high[i] : max
                idx := min == low[i] ? i : idx

    array.unshift(target_top, max)
    array.unshift(target_btm, min)
    array.unshift(target_left, time[idx])
    array.unshift(target_type, use_max ? -1 : 1)

//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)
        get_box = array.get(boxes, i)

        box.set_lefttop(get_box, array.get(target_left, i), array.get(target_top, i))
        box.set_rightbottom(get_box, array.get(target_left, i), array.get(target_btm, i))
        box.set_extend(get_box, extend.right)

        color css = na
        
        if swing 
            if style == 'Monochrome'
                css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
                border_css = array.get(target_type, i) == 1 ? #b2b5be : #5d606b
                box.set_border_color(get_box, border_css)
            else
                css := array.get(target_type, i) == 1 ? bull_ob_css : bear_ob_css
                box.set_border_color(get_box, css)

            box.set_bgcolor(get_box, css)
        else
            if style == 'Monochrome'
                css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80)
          
            box.set_border_color(get_box, css)
            box.set_bgcolor(get_box, css)
        


//Global variables
//-----------------------------------------------------------------------------{
var trend = 0, var itrend = 0

var top_y = 0., var top_x = 0
var btm_y = 0., var btm_x = 0

var itop_y = 0., var itop_x = 0
var ibtm_y = 0., var ibtm_x = 0

var trail_up = high, var trail_dn = low
var trail_up_x = 0,  var trail_dn_x = 0

var top_cross = true,  var btm_cross = true
var itop_cross = true, var ibtm_cross = true

var txt_top = '',  var txt_btm = ''

//Alerts
bull_choch_alert = true 
bull_bos_alert   = true 

bear_choch_alert = true 
bear_bos_alert   = true 

bull_ichoch_alert = true 
bull_ibos_alert   = true 

bear_ichoch_alert = true 
bear_ibos_alert   = true 

bull_iob_break = true 
bear_iob_break = true

bull_ob_break = true 
bear_ob_break = true

eqh_alert = true 
eql_alert = true 

//Structure colors
var bull_css = style == 'Monochrome' ? #0040ff 
  : swing_bull_css

var bear_css = style == 'Monochrome' ? #ff0101 
  : swing_bear_css


//Labels size

var swing_structure_lbl_size = swing_structure_size == 'normal' 
  ? size.tiny 
  : swing_structure_size == 'Small' 
  ? size.small 
  : size.normal 


//Swings
[top, btm] = swings(length)

[itop, ibtm] = swings(5)

//-----------------------------------------------------------------------------}
//Pivot High
//-----------------------------------------------------------------------------{
var line extend_top = na

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'

    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)

      
    //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

trail_up := math.max(high, trail_up)
trail_up_x := trail_up == high ? n : trail_up_x

if barstate.islast and show_hl_swings
    line.set_xy1(extend_top, trail_up_x, trail_up)
    line.set_xy2(extend_top, n + 20, trail_up)

    label.set_x(extend_top_lbl, n + 20)
    label.set_y(extend_top_lbl, trail_up)
    label.set_text(extend_top_lbl, trend < 0 ? 'Strong High' : 'Weak High')

//-----------------------------------------------------------------------------}

//-----------------------------------------------------------------------------{
var line extend_btm = na 

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'
    
    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)

      

    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


trail_dn := math.min(low, trail_dn)
trail_dn_x := trail_dn == low ? n : trail_dn_x


if barstate.islast and show_hl_swings
    line.set_xy1(extend_btm, trail_dn_x, trail_dn)
    line.set_xy2(extend_btm, n + 20, trail_dn)

    label.set_x(extend_btm_lbl, n + 20)
    label.set_y(extend_btm_lbl, trail_dn)
    label.set_text(extend_btm_lbl, trend > 0 ? 'Strong Low' : 'Weak Low')

//-----------------------------------------------------------------------------}

//-----------------------------------------------------------------------------{
var iob_top = array.new_float(0)
var iob_btm = array.new_float(0)
var iob_left = array.new_int(0)
var iob_type = array.new_int(0)

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)

//-----------------------------------------------------------------------------}

//-----------------------------------------------------------------------------{

var bull_concordant = true

if ta.crossover(close, itop_y) and itop_cross and top_y != itop_y and bull_concordant
    bool chochh = na
    
    if itrend < 0
        chochh := true
        bull_ichoch_alert := true
    else 
        bull_ibos_alert := true
    
    txt = chochh ? 'CHoCH' : 'BOS'

 
    itop_cross := false
    itrend := 1
    

if ta.crossover(close, top_y) and top_cross
    bool chochh = na
    
    if trend < 0
        chochh := true
        bull_choch_alert := true
    else 
        bull_bos_alert := true

    txt = chochh ? 'CHoCH' : 'BOS'
    
    if show_Structure
        if show_bull == 'All' or (show_bull == 'BOS' and not chochh) or (show_bull == 'CHoCH' and chochh)
            display_Structure(top_x, top_y, txt, bull_css, false, true, swing_structure_lbl_size)
    
    
    if show_ob
        ob_coords(false, top_x, ob_top, ob_btm, ob_left, ob_type)

    top_cross := false
    trend := 1

//-----------------------------------------------------------------------------}

//-----------------------------------------------------------------------------{
var bear_concordant = true



if ta.crossunder(close, ibtm_y) and ibtm_cross and btm_y != ibtm_y and bear_concordant
    bool chochh = false
    
    if itrend > 0
        chochh := true
        bear_ichoch_alert := true
    else 
        bear_ibos_alert := true
    
    txt = chochh ? 'CHoCH' : 'BOS'

 
    ibtm_cross := false
    itrend := -1
    

if ta.crossunder(close, btm_y) and btm_cross
    bool chochh = na
    
    if trend > 0
        chochh := true
        bear_choch_alert := true
    else 
        bear_bos_alert := true

    txt = chochh ? 'CHoCH' : 'BOS'
    
    if show_Structure
        if show_bear == 'All' or (show_bear == 'BOS' and not chochh) or (show_bear == 'CHoCH' and chochh)
            display_Structure(btm_x, btm_y, txt, bear_css, false, false, swing_structure_lbl_size)
    

    if show_ob
        ob_coords(true, btm_x, ob_top, ob_btm, ob_left, ob_type)

    btm_cross := false
    trend := -1

//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------{

var iob_boxes = array.new_box(0)
var ob_boxes = array.new_box(0)


for element in iob_type
    index = array.indexof(iob_type, element)

    if close < array.get(iob_btm, index) and element == 1
        array.remove(iob_top, index) 
        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
        array.remove(iob_top, index) 
        array.remove(iob_btm, index)
        array.remove(iob_left, index) 
        array.remove(iob_type, index)
        bear_iob_break := true


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_ob
        for i = 0 to ob_showlast-1
            array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time))


    

if ob_size > 0
    if barstate.islast
        display_ob(ob_boxes, ob_top, ob_btm, ob_left, ob_type, ob_showlast, true, ob_size)

//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}





//Cài đặt
//-----------------------------------------------------------------------------{
length1   = input.int(30, 'Swing', minval = 3 , group = 'OB V3')
showBear = input.int(5, 'Số OB trên', minval = 0, group = 'OB V3')
showBull = input.int(5, 'Số OB dưới', minval = 0, group = 'OB V3')
useBody  = input(false, 'Thu gọn OB không nên dùng', group = 'OB V3')

//Style
bearCss      = input(color.new(#ff9800, 90), 'OB trên', group = 'Style OB V3')
bearBreakCss = input(color.new(#ff1100, 100), 'OB trên Break', group = 'Style OB V3')



bullCss      = input(color.new(#ff9800, 90), 'OB dưới', group = 'Style OB V3')
bullBreakCss = input(color.new(#ff1100, 100), 'OB dưới Break', group = 'Style OB V3')





//-----------------------------------------------------------------------------}

//-----------------------------------------------------------------------------{
type ob1
    float top1 = na
    float btm1 = na
    int   loc1 = bar_index
    bool  breaker1 = false
    int   break_loc1 = na
    

type swing
    float y = na
    int   x = na
    bool  crossed = false


//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
swings1(len)=>
    var os = 0
    var swing top1 = swing.new(na, na)
    var swing btm1 = swing.new(na, na)
    
    upper = ta.highest(len)
    lower = ta.lowest(len)

    os := high[len] > upper ? 0 
      : low[len] < lower ? 1 : os

    if os == 0 and os[1] != 0
        top1 := swing.new(high[length1], bar_index[length1])
    
    if os == 1 and os[1] != 1
        btm1 := swing.new(low[length1], bar_index[length1])

    [top1, btm1]

method notransp(color css) => color.rgb(color.r(css), color.g(css), color.b(css))

method display(ob1 id, css, break_css)=>
    if id.breaker1
        box.new(id.loc1, id.top1, id.break_loc1, id.btm1, css.notransp()
          , bgcolor = css
          , xloc = xloc.bar_time)

        box.new(id.break_loc1, id.top1, time+1, id.btm1, na
          , bgcolor = break_css
          , extend = extend.right
       
          , xloc = xloc.bar_time)
        // vien ob chưa dùng
        // line.new(id.loc1, id.top1, id.break_loc1, id.top1, xloc.bar_time, color = css.notransp())
        // line.new(id.loc1, id.btm1, id.break_loc1, id.btm1, xloc.bar_time, color = css.notransp())
        // // line ob bị phá
        // line.new(id.break_loc1, id.top1, time+1, id.top1, xloc.bar_time, extend.right, break_css.notransp(), line.style_dashed)
        // line.new(id.break_loc1, id.btm1, time+1, id.btm1, xloc.bar_time, extend.right, break_css.notransp(), line.style_dashed)
    else
        box.new(id.loc1, id.top1, time, id.btm1, na
          , bgcolor = css
          , extend = extend.right
       
          , xloc = xloc.bar_time)
        
        // line.new(id.loc1, id.top1, time, id.top1, xloc.bar_time, extend.right, css.notransp())
        // line.new(id.loc1, id.btm1, time, id.btm1, xloc.bar_time, extend.right, css.notransp())

//-----------------------------------------------------------------------------}

n1 = bar_index

[top1, btm1] = swings1(length1)
max = useBody ? math.max(close, open) : high
min = useBody ? math.min(close, open) : low

//-----------------------------------------------------------------------------}
// OB trên
//-----------------------------------------------------------------------------{
var bullish_ob = array.new<ob1>(0)
bull_break_conf = 0

if close > top1.y and not top1.crossed
    top1.crossed := true

    minima = max[1]
    maxima = min[1]
    loc = time[1]

    for i = 1 to (n1 - top1.x)-1
        minima := math.min(min[i], minima)
        maxima := minima == min[i] ? max[i] : maxima
        loc := minima == min[i] ? time[i] : loc

    bullish_ob.unshift(ob1.new(maxima, minima, loc))

if bullish_ob.size() > 0
    for i = bullish_ob.size()-1 to 0
        element = bullish_ob.get(i)
    
        if not element.breaker1 
            if math.min(close, open) < element.btm1
                element.breaker1 := true
                element.break_loc1 := time
        else
            if close > element.top1
                bullish_ob.remove(i)
            else if i < showBull and top1.y < element.top1 and top1.y > element.btm1 
                bull_break_conf := 1

//-----------------------------------------------------------------------------}
// OB dưới
//-----------------------------------------------------------------------------{
var bearish_ob = array.new<ob1>(0)
bear_break_conf = 0

if close < btm1.y and not btm1.crossed
    btm1.crossed := true

    minima = min[1]
    maxima = max[1]
    loc = time[1]

    for i = 1 to (n1 - btm1.x)-1
        maxima := math.max(max[i], maxima)
        minima := maxima == max[i] ? min[i] : minima
        loc := maxima == max[i] ? time[i] : loc

    bearish_ob.unshift(ob1.new(maxima, minima, loc))

if bearish_ob.size() > 0
    for i = bearish_ob.size()-1 to 0
        element = bearish_ob.get(i)

        if not element.breaker1 
            if math.max(close, open) > element.top1
                element.breaker1 := true
                element.break_loc1 := time
        else
            if close < element.btm1
                bearish_ob.remove(i)
            else if i < showBear and btm1.y > element.btm1 and btm1.y < element.top1 
                bear_break_conf := 1


//-----------------------------------------------------------------------------}
// Order Blocks
//-----------------------------------------------------------------------------{
// for bx in box.all
//     bx.delete()

// for l in line.all
//     l.delete()

if barstate.islast
    //Bullish
    if showBull > 0
        for i = 0 to math.min(showBull-1, bullish_ob.size())
            get_ob = bullish_ob.get(i)
            get_ob.display(bullCss, bullBreakCss)

    //Bearish
    if showBear > 0

        for i = 0 to math.min(showBear-1, bearish_ob.size())
            get_ob = bearish_ob.get(i)
            get_ob.display(bearCss, bearBreakCss)

//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}
//-----------------------------------------------------------------------------}

// len1 = input(34, title='EMA 34',group='EMA')
// len2 = input(89, title='EMA 89',group='EMA')
// len3 = input(200, title='EMA 200',group='EMA')


// M1 = ta.ema(close, len1)
// M2 = ta.ema(close, len2)
// M3 = ta.ema(close, len3)

// plot(M1, color=color.new(#eeff00, 11), linewidth=1)
// plot(M2, color=color.new(#2729b0, 0), linewidth=1)
// plot(M3, color=color.new(#f32121, 0), linewidth=2)
// //text inputs
// //title settings
// title = input.string('MC War', 'Tittle', group='Tên')
// c_title = input.color(color.new(color.yellow, 20), 'Title Color', group='Tên')
// s_title = input.string('large', 'Title Size', options=['tiny', 'small', 'normal', 'large', 'huge', 'auto'], group='Tên')
// a_title = input.string('center', 'Title Alignment', options=['center', 'left', 'right'], group='Tên')


// //subtitle settings

// subtitle = input.string('Nguyễn Thanh Tuấn', group='Phụ đề')
// c_subtitle = input.color(color.new(color.yellow, 40), 'Subitle Color', group='Phụ đề')
// s_subtitle = input.string('normal', 'Subtitle Size', options=['tiny', 'small', 'normal', 'large', 'huge', 'auto'], group='Phụ đề')
// a_subtitle = input.string('center', 'Subtitle Alignment', options=['center', 'left', 'right'], group='Phụ đề')

// //Ngày giờ
// symInfoCheck = input.bool(title='Ngày - Mả - TF', defval=true,group='Ngày giờ')
// c_symInfo = input.color(color.new(color.yellow, 40), 'Subitle Color', group='Ngày giờ')
// s_symInfo = input.string('normal', 'Subtitle Size', options=['tiny', 'small', 'normal', 'large', 'huge', 'auto'], group='Ngày giờ')
// a_symInfo = input.string('left', 'Subtitle Alignment', options=['center', 'left', 'right'], group='Ngày giờ')


// //symbol info
// symInfo = syminfo.ticker + ' | ' + timeframe.period + (timeframe.isminutes ? 'M' : na)
// date = str.tostring(dayofmonth(time_close)) + '/' + str.tostring(month(time_close)) + '/' + str.tostring(year(time_close))
// //text positioning
// textVPosition = input.string('top', 'Trục X', options=['top', 'middle', 'bottom'], group='Vị trí tên')
// textHPosition = input.string('right', 'Trục Y', options=['left', 'center', 'right'], group='Vị trí tên')
// //symbol info positioning
// symVPosition = input.string('bottom', 'Trục X', options=['top', 'middle', 'bottom'], group='Vị trí ngày')
// symHPosition = input.string('right', 'Trục Y', options=['left', 'center', 'right'], group='Vị trí ngày')
// //cell size
// width = input.int(0, 'Width', minval=0, maxval=0,  group='cell size')
// height = input.int(0, 'Height', minval=0, maxval=0, group='cell size')

// c_bg = input.color(color.new(color.blue, 100), 'Background', group='background')


// //text watermark creation
// textWatermark = table.new(textVPosition + '_' + textHPosition, 1, 3)
// table.cell(textWatermark, 0, 0, title, width, height, c_title, a_title, text_size=s_title, bgcolor=c_bg)
// table.cell(textWatermark, 0, 1, subtitle, width, height, c_subtitle, a_subtitle, text_size=s_subtitle, bgcolor=c_bg)


// //symbol info watermark creation
// symWatermark = table.new(symVPosition + '_' + symHPosition, 5, 5)
// if symInfoCheck == true
//     table.cell(symWatermark, 0, 1, symInfo, width, height, c_symInfo, a_symInfo, text_size=s_symInfo, bgcolor=c_bg)
//     table.cell(symWatermark, 0, 0, date, width, height, c_symInfo, a_symInfo, text_size=s_symInfo, bgcolor=c_bg)

Overview

Mc War v2 detects swing points, swing high and low levels, and breaks of structure or change of character labels (BOS and CHoCH). It also identifies and draws bullish and bearish swing order blocks based on swing high and low logic. Main settings allow customization of structure filtering, order block visual styles, swing detection length, and display options for strong or weak high and low levels.

Details

Published by

tuanmcwar on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Winratestring100%style
Hiện Swing Structurebooltrueshow_Structure
Bullish StructurestringAllshow_bull
swing_bull_csscolor#089981swing_bull_css
Bearish StructurestringAllshow_bear
swing_bear_csscolor#f23645swing_bear_css
Swing Label SizestringSmallswing_structure_size
Hiện Swings Pointsboolfalseshow_swings
lengthint50length
Hiện Strong/Weak High/Lowboolfalseshow_hl_swings
Swing Order Blocksbooltrueshow_ob
ob_showlastint5ob_showlast
Show all 22 settings
SettingTypeDefaultVariable
Bullish OBcolorcolor.new(#787b86, 80)bull_ob_css
Bearish OBcolorcolor.new(#787b86, 80)bear_ob_css
Swingint30length1
Số OB trênint5showBear
Số OB dướiint5showBull
Thu gọn OB không nên dùngboolfalseuseBody
OB trêncolorcolor.new(#ff9800, 90)bearCss
OB trên Breakcolorcolor.new(#ff1100, 100)bearBreakCss
OB dướicolorcolor.new(#ff9800, 90)bullCss
OB dưới Breakcolorcolor.new(#ff1100, 100)bullBreakCss
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.

Similar Pine Scripts

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
303 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 2 years ago · None stated GitHub repository of DE-tracker

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

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 3 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

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

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 2 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers