Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // LOVE JOY PEACE PATIENCE KINDNESS GOODNESS FAITHFULNESS GENTLENESS SELF-CONTROL
- // Original Script: https://www.tradingview.com/script/9dK1FvCB/
- // @author LonesomeTheBlue
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Thank you Alex Grover for helping point me in the right direction regarding the capabilities of label.new which led me to line.new
- // Naturally pinecoders already had covered the questions I was asking:
- // http://www.pinecoders.com/faq_and_code/#how-can-i-keep-only-the-last-x-labels-or-lines
- // Updated By: JOSHUAMCGOWAN
- // Date: 1-26-2020
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // Concept taken from Griss' and Brian Beamish's conversation here:
- // https://www.youtube.com/watch?v=pbSBW5otxo8
- // @version=4
- study("The Griss Matrix - TRI LEVEL2 RITE Program", overlay =true)
- //////////////////////////////////////////////////////////////////////////////////////////////
- // Original Inputs and Variables
- //////////////////////////////////////////////////////////////////////////////////////////////
- // Increase these values to pickup less pivot points and reduce to identify more pivot highs/lows.
- lb = input(3, title="Left Bars")
- rb = input(3, title="Right Bars")
- repaint = input(false)
- repaintOffset = repaint ? 0 : 1
- showChartRes = input(false)
- showDailyRes = input(true)
- showWeeklyRes = input(true)
- mb = lb + rb + 1
- // These need to get offset to the left by left bars input above.
- pivot_top = iff(not na(high), iff(highestbars(mb) == -lb, true, false), false)
- pivot_bot = iff(not na(low), iff(lowestbars(mb) == -lb, true, false), false)
- top_value = valuewhen(pivot_top,high[lb],0)
- bot_value = valuewhen(pivot_bot,low[lb],0)
- // Daily
- top_value_d = repaint ? security(syminfo.tickerid, 'D', top_value) : security(syminfo.tickerid, 'D', top_value[1], lookahead = barmerge.lookahead_on)
- bot_value_d = repaint ? security(syminfo.tickerid, 'D', bot_value) : security(syminfo.tickerid, 'D', bot_value[1], lookahead = barmerge.lookahead_on)
- // Weekly
- top_value_w = repaint ? security(syminfo.tickerid, 'W', top_value) : security(syminfo.tickerid, 'W', top_value[1], lookahead = barmerge.lookahead_on)
- bot_value_w = repaint ? security(syminfo.tickerid, 'W', bot_value) : security(syminfo.tickerid, 'W', bot_value[1], lookahead = barmerge.lookahead_on)
- plotchar(top_value, "top_value", "", location.top)
- plotchar(bot_value, "bot_value", "", location.top)
- plotchar(top_value_d, "top_value_d", "", location.top)
- plotchar(bot_value_d, "bot_value_d", "", location.top)
- plotchar(top_value_w, "top_value_w", "", location.top)
- plotchar(bot_value_w, "bot_value_w", "", location.top)
- // ————— Create labels while keeping a trail of label ids in series "lbl".
- // See the following for details: http://www.pinecoders.com/faq_and_code/#how-can-i-keep-only-the-last-x-labels-or-lines
- // // Monthly Levels //
- // line top_lbl_m = na
- // if change(pivot_top_m)
- // top_lbl_m := line.new(bar_index[lb], high[lb], bar_index, high[lb], extend=extend.right, color=color.maroon, width=3)
- // line bot_lbl_m = na
- // if change(pivot_bot_m)
- // bot_lbl_m := line.new(bar_index[lb], low[lb], bar_index, low[lb], extend=extend.right, color=color.maroon, width=3)
- // Current chart res
- if change(top_value) and showChartRes
- line.new(bar_index[lb], top_value[lb], bar_index, top_value[lb], extend=extend.right, color=color.lime, width=2)
- if change(bot_value) and showChartRes
- line.new(bar_index[lb], bot_value[lb], bar_index, bot_value[lb], extend=extend.right, color=color.maroon, width=2)
- // Daily Levels
- if change(top_value_d) and showDailyRes
- line.new(bar_index[lb], top_value_d[lb], bar_index, top_value_d[lb], extend=extend.right, color=color.green, width=2)
- if change(bot_value_d) and showDailyRes
- line.new(bar_index[lb], bot_value_d[lb], bar_index, bot_value_d[lb], extend=extend.right, color=color.red, width=2)
- // Weekly Levels
- if change(top_value_w) and showWeeklyRes
- line.new(bar_index[lb], top_value_w[lb], bar_index, top_value_w[lb], extend=extend.right, color=color.green, width=2)
- if change(bot_value_w) and showWeeklyRes
- line.new(bar_index[lb], bot_value_w[lb], bar_index, bot_value_w[lb], extend=extend.right, color=color.red, width=2)
- // // Daily Levels //
- // line top_lbl_d = na
- // if change(pivot_top_d)
- // top_lbl_d := line.new(bar_index[lb], high[lb], bar_index, high[lb], extend=extend.right, color=color.orange, width=2)
- // line bot_lbl_d = na
- // if change(pivot_bot_d)
- // bot_lbl_d := line.new(bar_index[lb], low[lb], bar_index, low[lb], extend=extend.right, color=color.orange, width=2)
- // plot(iff(not na(high[mb]), iff(highestbars(mb) == -lb, high[lb], na), na), style = shape.cross, linewidth = 3, color = color.maroon, offset = -lb)
- // plot(iff(not na(low[mb]), iff(lowestbars(mb) == -lb, low[lb], na), na), style = shape.cross, linewidth = 3, color = color.green, offset = -lb)
- //DRAWS PIVOT SHAPES// Helps to visually confirm pivots/levels.
- // plotshape(pivot_top, style=shape.cross, location=location.abovebar, color=color.maroon, offset = -lb)
- // plotshape(pivot_bot, style=shape.cross, location=location.belowbar, color=color.green, offset = -lb)
- // plotshape(iff(not na(high[mb]), iff(highestbars(mb) == -lb, high[lb], na), na), style=shape.cross, location=location.abovebar, color=color.maroon, offset = -lb)
- // plotshape(iff(not na(low[mb]), iff(lowestbars(mb) == -lb, low[lb], na), na), style=shape.cross, location=location.belowbar, color=color.green, offset = -lb)
- // plot(top_value, title='top_value', transp=100)
- // plot(bot_value, title='bot_value', transp=100)
- // plot(pivot_top==true?1:0, title='pivot_top', transp=100)
- // plot(pivot_bot==true?1:0, title='pivot_bot', transp=100)
- //Additional Notes by Original Author//
- // sellcondition = iff(not na(high), iff(highestbars(mb) == -lb, true, false), false)
- // buycondition = iff(not na(low), iff(lowestbars(mb) == -lb, true, false), false)
- // alertcondition(buycondition, title='Pivot HL Signal', message='Pivot HL Buy Signal')
- // alertcondition(sellcondition, title='Pivot HL Sell Signal', message='Pivot HL Sell Signal')
- // END //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement