Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © nnamdert
- //@version=5
- indicator("FOREX MASTER PATTERN Value Lines by nnam", overlay=true, max_lines_count = 500)
- //BEGIN SCRIPT
- //HANDLES MAX_LINES_COUNTS ISSUE================================================================================================//
- lineLimitInput = input.int( //
- defval = 12, //
- minval = 1, //
- maxval = 499, //
- title = 'Max Lines to Show', //
- tooltip = 'Adjust this number to increase or decrease the total number of lines seen on the chart. (ONLY this indicator)', //
- group = 'Line Settings' //
- ) //
- if array.size(line.all) > lineLimitInput //
- for i = 0 to array.size(line.all) - lineLimitInput - 1 //
- line.delete(array.get(line.all, i)) //
- //BEGIN Get User Inputs=========================================================================================================//
- //BEGIN Get User Inputs - Line Settings //
- show_lines = input.bool( //
- defval = true, //
- title = 'Show Lines on chart', //
- group = 'Line Settings', //
- tooltip = 'Unchecking this box will hide ALL lines on the chart - NO LINES generated by this indicator will appear' //
- ) // //
- show_valuelines = input.bool( //
- defval = true, //
- title = 'Show Value Lines on chart', //
- group = 'Line Settings', //
- tooltip='Unchecking this box will hide the Forex Master Pattern Value Lines on the chart.' //
- ) //
- value_line_width_settings = input.int( //
- defval = 2, //
- title = 'Set Value Line Width', //
- group = 'Line Settings', //
- tooltip = 'Use this option to set the width of the Forex master Pattern Value Line (default is 1, max is 8)', //
- minval = 1, //
- maxval = 8 //
- ) //
- only_show_last_value_line = input.bool( //
- defval = false, //
- title = 'Only show last Value Line on Chart?', //
- group = 'Line Settings', //
- tooltip = 'If box is checked only most recent Value Line will be visible, even if most recent box is not in the same location' // //
- ) //
- showOnlyLastBox = input.bool( //
- defval = false, //
- title = 'show last box only', //
- group = 'Box Settings', //
- tooltip = 'If box is checked only the most recent contraction box will be shown on the chart' //
- ) //
- show_Expansion_Area = input.bool( //
- defval = false, //
- title = 'Show Expansion Area (coming soon)', //
- group = 'Expansion Area Settings (coming Soon!)', //
- tooltip = 'This feature is not implemented yet' //
- ) //
- show_expansion_guidelines = input.bool( //
- defval = false, //
- title = 'Show Expansion GuideLines on Chart (coming soon)', //
- group = 'Expansion Area Settings (coming Soon!)', //
- tooltip = 'This feature is not implemented yet' //
- ) //
- //END Get User Inputs - Line Settings===========================================================================================//
- //BEGIN Get User Inputs - BARS==================================================================================================//
- //BEGIN Get User Inputs - BAR COLORS //
- color_code_candles = input.bool( //
- defval=true, //
- title = 'Color Code the Candles', //
- tooltip = 'Turn on Color Coded Candles. Expansion. Contraction, Bullish and Bearish Candles will be shaded as listed below.', //
- group = 'Candle Colors' //
- ) //
- inside_bar_color = input.color( //
- defval = color.white, //
- title = 'Contraction Candles', //
- tooltip = 'This is the color of the Strat Inside Bar - otherwise known as 1', //
- group = 'Candle Colors', //
- inline = 'inside outside', //
- confirm = false) //
- outside_bar_color = input.color( //
- defval = color.yellow, //
- title = 'Expansion Candles', //
- tooltip = 'This is the color of the Strat Outside Bar - otherwise known as 3', //
- group = 'Candle Colors', //
- inline = 'inside outside', //
- confirm = false) //
- twoup_bar_color = input.color( //
- defval = color.lime, //
- title = 'Bullish Candle', //
- tooltip = 'This is the color of the Strat 2 UP Bar', //
- group = 'Candle Colors', //
- inline = 'twobars', //
- confirm = false) //
- twodown_bar_color = input.color( //
- defval = color.maroon, //
- title = 'Bearish Candle', //
- tooltip = 'This is the color of the Strat 2 DOWN Bar', //
- group = 'Candle Colors', //
- inline = 'twobars', //
- confirm = false) //
- bearish_engulfing_bar_color = input.color( //
- defval = #f57c00, //
- title = 'Bearish Engulfing Candle', //
- tooltip = 'This is the color of a Bearish Engulfing Candle', //
- group = 'Candle Colors', //
- inline = 'engulfing', //
- confirm = false) //
- bullish_engulfing_bar_color = input.color( //
- defval = #f57c00, //
- title = 'Bullish Engulfing Candle', //
- tooltip = 'This is the color of a Bullish Engulfing Candle', //
- group = 'Candle Colors', //
- inline = 'engulfing', //
- confirm = false) //
- //END Get User Inputs - BAR COLORS //
- //BEGIN Get User Inputs - ENGULFING BARS========================================================================================//
- show_engulfing_patterns = input.bool( //
- defval=true, //
- title = 'Show Engulfing Patterns?', //
- group = 'Engulfing Patterns' //
- ) //
- show_bullish_engulfing_patterns = input.bool( //
- defval=true, //
- title ='Show Bullish Engulfing Candles', //
- group = 'Engulfing Patterns') //
- show_bearish_engulfing_patterns = input.bool( //
- defval=true, //
- title ='Show Bearish Engulfing Candles', //
- group = 'Engulfing Patterns') //
- //END Get User Inputs - ENGULFING BARS==========================================================================================//
- //BEGIN STRAT SCENARIO INDENTIFIERS=============================================================================================//
- atr = ta.atr(14) //
- bar_green = close >= open //
- bar_red = close < open //
- bar_inside = (high <= high[1]) and (low >= low[1]) //
- bar_twoup = (high > high[1]) and (low >= low[1]) //
- bar_twodown = (high <= high[1]) and (low < low[1]) //
- bar_outside = (high > high[1]) and (low < low[1]) //
- bar_openTime = time //
- bar_lowPrice = low //
- bar_highPrice = high //
- bar_two_up_green = bar_twoup and bar_green //
- bar_two_up_red = bar_twoup and bar_red //
- bar_two_down_red = bar_twodown and bar_red //
- bar_inside_green = bar_inside and bar_green //
- bar_outside_green = bar_outside and bar_green //
- bar_outside_red = bar_outside and bar_red //
- bar_continuation_green = open[1] <= low and bar_green //
- //END STRAT SCENARIO INDENTIFIERS===============================================================================================//
- //BEGIN BEARISH ENGULFING DEFINITION+===========================================================================================//
- bar_bearish_engulfing = //
- //CLOSE Price of the CURRENT Engulfing candle /session must be (less than) the OPEN Price of PREVIOUS session //
- close < open[1] //
- //OPEN Price of the CURRENT Engulfing candle /session must be (greater than) the CLOSE Price of PREVIOUS session //
- and open > close[1] //
- //Previous Session (before the engulfing candle) - the candle /session being Engulfed MUST be a GREEN candle /session //
- and (close[1] >= open[1]) //
- //OPEN and CLOSE of the CURRENT Engulfing Session is (greater than or equal to) the previous candle /session being Engulfed and //
- //is LARGER by a factor of 2 - (or basically twice as big) - ENGULFING CANDLE MUST BE RED [open - close = RED] //
- and (open - close) >= ((close[1] - open[1]) * 6) //
- //CURRENT Engulfing candle /session needs to be (greater than) the atr //
- and (open - close) >= atr //
- //END BEARISH ENGULFING DEFINITION==============================================================================================//
- //BEGIN BULLISH ENGULFING DEFINITION============================================================================================//
- bar_bullish_engulfing = //
- close > open[1] //
- and open < close[1] //
- and (close[1] <= open[1]) //
- and (close - open) >= ((open[1] - close[1]) * 6) //
- and (close - open) >= atr //
- //END BULLISH ENGULFING DEFINITION==============================================================================================//
- //Begin Bar Colors==============================================================================================================//
- //Expansion Candle also known as Strat 3 Outside Bar //
- barcolor( //
- not bar_bearish_engulfing //
- and not bar_bullish_engulfing //
- and color_code_candles //
- and (high > high[1] //
- and low < low[1]) ? //
- color.new(outside_bar_color, 0) : na, title = '3 Outside Bar') //
- barcolor( //
- not bar_bullish_engulfing //
- and not bar_bearish_engulfing //
- and color_code_candles //
- and (high > high[1] //
- and low >= low[1]) ? //
- color.new(twoup_bar_color, 0) : na, title = '2 up') //
- barcolor( //
- not bar_bullish_engulfing //
- and not bar_bearish_engulfing //
- and color_code_candles //
- and (high <= high[1] //
- and low < low[1]) ? //
- color.new(twodown_bar_color, 0) : na, title = '2 down') //
- barcolor( //
- not bar_bullish_engulfing //
- and not bar_bearish_engulfing //
- and color_code_candles //
- and (high <= high[1] //
- and low >= low[1]) ? //
- color.new(inside_bar_color, 0) : na, title = '1 Inside Bar') //
- barcolor( //
- bar_bullish_engulfing //
- and show_bullish_engulfing_patterns //
- and show_engulfing_patterns ? //
- color.new(bullish_engulfing_bar_color, 0) : na, title = 'Bullish Engulfing') //
- barcolor( //
- bar_bearish_engulfing //
- and show_bearish_engulfing_patterns //
- and show_engulfing_patterns ? //
- color.new(bearish_engulfing_bar_color, 0) : na, title = 'Bearish Engulfing') //
- //bear_candle = open > close //
- //bull_candle = close > open //
- //plotcandle(bull_candle ? open : na, bull_candle ? high: na, bull_candle ? low: na, bull_candle ? close: na, //
- // wickcolor=color.new(color.lime, 0), //
- // bordercolor=color.new(color.lime, 0) //
- // ) //
- //plotcandle(bear_candle ? open: na, bear_candle ? high: na, bear_candle ? low: na, bear_candle ? close: na, //
- // wickcolor=color.new(color.red, 0), //
- // bordercolor=color.new(color.red, 0) //
- // ) //
- //End Bar Colors================================================================================================================//
- // //
- //BEGIN CONTRACTION BOXES=======================================================================================================//
- //showOnlyLastBox = input.bool(false, title = 'show last box only') //is above in global inputs leaving here for //
- //standalone box script if required //
- // variables //
- var box myBox = na //
- var float boxHigh = na //
- var float boxLow = na //
- varip int barIndex = 1 //
- varip bool f = false //
- //
- oneone = bar_inside //request.security(syminfo.tickerid, 'D', bar_inside) // not recommended as it can cause issues //
- if oneone == true
- 1
- else
- na
- //
- if oneone and not oneone[1] and barstate.isconfirmed //
- boxHigh := high[1] // was high[1]
- boxLow := low[1] // was high[1]
- f := true
- if showOnlyLastBox
- box.delete(id=myBox[1])
- myBox := box.new(bar_index-1, high, bar_index, low, bgcolor=color.new(#405fcf, 70), border_width=1) // high and low were [1]
- barIndex := barIndex+1
- else if oneone and oneone[1] and barstate.isconfirmed //
- box.set_right(myBox[1], bar_index)
- barIndex := barIndex+1
- else if oneone[1] and not oneone and barstate.isconfirmed //
- box.set_right(myBox[1], bar_index)
- barIndex := barIndex
- else if not oneone[1] and not oneone //
- f := false
- //END CONTRACTION BOXES=========================================================================================================//
- //lines //
- //midline //
- //EmaCross = ta.crossover(shortest, short) (future use) //
- var float middleBody = na
- //midline = line.new(bar_index[1], middleBody, bar_index+100, middleBody, width = value_line_width_settings) //, extend=extend.right)
- if oneone and oneone[1] and show_lines and not only_show_last_value_line
- middleBody := (((high + high[1]) / 2) + ((low + low[1]) / 2)) / 2 //was (open + close) / 2 or (high + low) / 2
- midline = line.new(bar_index[1], middleBody, bar_index+100, middleBody, width = value_line_width_settings) //, extend=extend.right)
- else
- if oneone and oneone[1] and show_lines and only_show_last_value_line
- middleBody := (((high + high[1]) / 2) + ((low + low[1]) / 2)) / 2 //was (open + close) / 2 or (high + low) / 2
- midline = line.new(bar_index[1], middleBody, bar_index+100, middleBody, width = value_line_width_settings) //, extend=extend.right)
- line.delete(midline[1])
- NotValid = not oneone
- if NotValid
- middleBody := na
- //plot(middleBody, color=color.lime, style=plot.style_linebr, trackprice=true)
- //END MIDLINE SCRIPT=========================================================================================================================//
- //ALERTS
- alertcondition(
- bar_bullish_engulfing,
- title = 'Bullish Engulfing Alert',
- message = 'Bullish Engulfing Pattern Identified'
- )
- alertcondition(
- bar_bearish_engulfing,
- title = 'Bearish Engulfing Alert',
- message = 'Bearish Engulfing Pattern Identified'
- )
- //===========
- //PLOTS
- //plotshape(series, title, style, location, color, offset, text, textcolor, editable, size, show_last, display) → void
- //show_engulfing_patterns and show_bullish_engulfing_patterns ?
- plotshape(not show_engulfing_patterns or not show_bullish_engulfing_patterns ? na :
- bar_bullish_engulfing,
- title = 'Bullish Engulfing Plot',
- style = shape.arrowup,
- location = location.belowbar,
- color = color.new(#f57c00,0),
- size = size.large,
- show_last = 2000)
- //show_engulfing_patterns and show_bearish_engulfing_patterns ?
- plotshape(not show_engulfing_patterns or not show_bearish_engulfing_patterns ? na :
- bar_bearish_engulfing,
- title = 'Bearish Engulfing Plot',
- style = shape.arrowdown,
- location = location.abovebar,
- color = color.new(#f57c00,0),
- size = size.large,
- show_last = 2000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement