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("GRIDBOT Scalper", overlay = true, max_lines_count = 500)
- //BEGIN SCRIPT
- //HANDLES MAX_LINES_COUNTS ISSUE================================================================================================//
- lineLimitInput = input.int( //
- defval = 30, //
- 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 LINE SETTINGS //
- extend_lines = input.bool( //
- defval = true, //
- title = 'Extend Lines to the right?', //
- tooltip = 'Checking this box will extend the current lines on the chart to the right', //
- group = 'Line Settings' //
- ) ? extend.right : extend.none //
- use_low_bullish = input.bool( //
- defval = false, //
- title = 'Use Low for Bullish Reversal Support Line?', //
- tooltip = 'The default for the support line is the close of the candle, this setting changes it to the candle Low (wick)', //
- group = 'Line Settings' //
- ) ? low : close //
- use_high_bearish = input.bool( //
- defval = false, //
- title = 'Use High for Bearish Reversal Resistance Line?', //
- tooltip = 'The default for the resistance line is the close of the candle, this setting changes it to the candle High (wick)', //
- group = 'Line Settings' //
- ) ? high : close //
- //END LINE SETTINGS //
- show_price_label = input.bool( //
- defval = true, //
- title = ' Show Price Label on Chart', //
- tooltip = 'Unchecking this box will hide the optional price label from the chart', //
- group = "Price Label Settings" //
- ) //
- only_bearish = input.bool( //
- defval = false, //
- title = ' Show only Bearish Labels on Chart', //
- tooltip = 'checking this box will hide Bullish Reversal and only show Bearish Reversals', //
- group = 'Signal Label Settings' //
- ) //
- only_bullish = input.bool( //
- defval = false, //
- title = ' Show only Bullish Labels on Chart', //
- tooltip = 'checking this box will hide Bearish Reversal and only show Bullish Reversals', //
- group = 'Signal Label Settings' //
- ) //
- //END Get User Inputs===========================================================================================================//
- //BEGIN script Code=============================================================================================================//
- var priceArray = array.new_float(0) //
- array.push(priceArray, close) //
- size = array.size(priceArray) //
- price = array.get(priceArray, size -1) //
- // //
- //LABEL script for OPTIONAL PRICE LABEL=========================================================================================//
- label pricelabel = na //
- if barstate.islast and show_price_label //
- pricelabel := label.new(bar_index, //
- y=0, //
- yloc=yloc.abovebar, //
- color = color.new(color.yellow, 0), //
- style = label.style_none, //
- text="Price:\n " + str.tostring(array.get(priceArray, size -1)), //
- textcolor = color.new(color.orange, 0)) //
- label.delete(pricelabel[1]) //
- // //
- //BEGIN Definitions=============================================================================================================//
- bullish_break = //
- price > high[1] //
- and price > high[2] //
- and price > high[3] //
- and price > high[4] //
- and price > high[5] //
- and price > high[6] //
- and price > high[7] //
- and price > high[8] //
- and price > high[9] //
- and price > high[10] //
- and price > high[11] //
- and price > high[12] //
- and price > high[13] //
- and price > high[14] //
- // //
- bearish_break = //
- price < low[1] //
- and price < low[2] //
- and price < low[3] //
- and price < low[4] //
- and price < low[5] //
- and price < low[6] //
- and price < low[7] //
- and price < low[8] //
- and price < low[9] //
- and price < low[10] //
- and price < low[11] //
- and price < low[11] //
- and price < low[12] //
- and price < low[13] //
- and price < low[14] //
- // //
- bearish_signal = (bearish_break[1] and not bearish_break) //
- bullish_signal = (bullish_break[1] and not bullish_break) //
- //END Definitions===============================================================================================================//
- //PLOTSHAPES BULLISH============================================================================================================//
- //label bullishlabel = na //
- if barstate.isconfirmed and bullish_signal and not only_bullish//bullish_break[1] and not bullish_break //
- bullishlabel = label.new( //
- bar_index, //
- y=0, //
- yloc=yloc.abovebar, //
- style= label.style_triangledown, //
- size = size.normal, //
- color = color.new(color.red, 0), //
- text = "Potential \n Bearish \n Reversal", //
- textcolor = color.new(color.red, 0) //
- ) //
- label.delete(bullishlabel[1]) //
- // //
- if barstate.isconfirmed and bullish_break //
- bullishline = line.new( //
- x1=bar_index, //
- y1=use_high_bearish, //
- x2=bar_index+30, //
- y2=use_high_bearish, //
- color = color.new(color.red, 0), //
- extend = extend_lines //
- ) //
- line.delete(bullishline[1]) //
- //PLOTSHAPES BEARISH============================================================================================================//
- //label bearishlabel = na //
- if barstate.isconfirmed and bearish_signal and not only_bearish//bearish_break[1] and not bearish_break //
- bearishlabel = label.new( //
- bar_index, //
- y=0, //
- yloc=yloc.belowbar, //
- style= label.style_triangleup, //
- size = size.normal, //
- color = color.new(color.green, 0), //
- text = "Potential \n Bullish \n Reversal", //
- textcolor = color.new(color.green, 0) //
- ) //
- label.delete(bearishlabel[1]) //
- // //
- if barstate.isconfirmed and bearish_break //
- bearishline = line.new( //
- bar_index, //
- use_low_bullish, //
- bar_index+30, //
- use_low_bullish, //
- color = color.new(color.green, 0), //
- extend = extend_lines //
- ) //
- line.delete(bearishline[1]) //
- //END Script====================================================================================================================//
- //SIGNALS
- alertcondition(bearish_signal, title = 'Bullish Reversal', message = 'Possible Bullish Reversal')
- alertcondition(bullish_signal, title = 'Bearish Reversal', message = 'Possible Bearish Reversal')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement