Advertisement
xmd79

GRIDBOT Scalper

Jan 24th, 2023
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.62 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © nnamdert
  3.  
  4. //@version=5
  5. indicator("GRIDBOT Scalper", overlay = true, max_lines_count = 500)
  6.  
  7. //BEGIN SCRIPT
  8. //HANDLES MAX_LINES_COUNTS ISSUE================================================================================================//
  9. lineLimitInput = input.int( //
  10. defval = 30, //
  11. title = 'Max Lines to Show', //
  12. tooltip = 'Adjust this number to increase or decrease the total number of lines seen on the chart. (ONLY this indicator)', //
  13. group = 'Line Settings' //
  14. ) //
  15. if array.size(line.all) > lineLimitInput //
  16. for i = 0 to array.size(line.all) - lineLimitInput - 1 //
  17. line.delete(array.get(line.all, i)) //
  18. //BEGIN Get User Inputs=========================================================================================================//
  19. //BEGIN LINE SETTINGS //
  20. extend_lines = input.bool( //
  21. defval = true, //
  22. title = 'Extend Lines to the right?', //
  23. tooltip = 'Checking this box will extend the current lines on the chart to the right', //
  24. group = 'Line Settings' //
  25. ) ? extend.right : extend.none //
  26. use_low_bullish = input.bool( //
  27. defval = false, //
  28. title = 'Use Low for Bullish Reversal Support Line?', //
  29. tooltip = 'The default for the support line is the close of the candle, this setting changes it to the candle Low (wick)', //
  30. group = 'Line Settings' //
  31. ) ? low : close //
  32. use_high_bearish = input.bool( //
  33. defval = false, //
  34. title = 'Use High for Bearish Reversal Resistance Line?', //
  35. tooltip = 'The default for the resistance line is the close of the candle, this setting changes it to the candle High (wick)', //
  36. group = 'Line Settings' //
  37. ) ? high : close //
  38. //END LINE SETTINGS //
  39. show_price_label = input.bool( //
  40. defval = true, //
  41. title = ' Show Price Label on Chart', //
  42. tooltip = 'Unchecking this box will hide the optional price label from the chart', //
  43. group = "Price Label Settings" //
  44. ) //
  45. only_bearish = input.bool( //
  46. defval = false, //
  47. title = ' Show only Bearish Labels on Chart', //
  48. tooltip = 'checking this box will hide Bullish Reversal and only show Bearish Reversals', //
  49. group = 'Signal Label Settings' //
  50. ) //
  51. only_bullish = input.bool( //
  52. defval = false, //
  53. title = ' Show only Bullish Labels on Chart', //
  54. tooltip = 'checking this box will hide Bearish Reversal and only show Bullish Reversals', //
  55. group = 'Signal Label Settings' //
  56. ) //
  57. //END Get User Inputs===========================================================================================================//
  58. //BEGIN script Code=============================================================================================================//
  59. var priceArray = array.new_float(0) //
  60. array.push(priceArray, close) //
  61. size = array.size(priceArray) //
  62. price = array.get(priceArray, size -1) //
  63. // //
  64. //LABEL script for OPTIONAL PRICE LABEL=========================================================================================//
  65. label pricelabel = na //
  66. if barstate.islast and show_price_label //
  67. pricelabel := label.new(bar_index, //
  68. y=0, //
  69. yloc=yloc.abovebar, //
  70. color = color.new(color.yellow, 0), //
  71. style = label.style_none, //
  72. text="Price:\n " + str.tostring(array.get(priceArray, size -1)), //
  73. textcolor = color.new(color.orange, 0)) //
  74. label.delete(pricelabel[1]) //
  75. // //
  76. //BEGIN Definitions=============================================================================================================//
  77. bullish_break = //
  78. price > high[1] //
  79. and price > high[2] //
  80. and price > high[3] //
  81. and price > high[4] //
  82. and price > high[5] //
  83. and price > high[6] //
  84. and price > high[7] //
  85. and price > high[8] //
  86. and price > high[9] //
  87. and price > high[10] //
  88. and price > high[11] //
  89. and price > high[12] //
  90. and price > high[13] //
  91. and price > high[14] //
  92. // //
  93. bearish_break = //
  94. price < low[1] //
  95. and price < low[2] //
  96. and price < low[3] //
  97. and price < low[4] //
  98. and price < low[5] //
  99. and price < low[6] //
  100. and price < low[7] //
  101. and price < low[8] //
  102. and price < low[9] //
  103. and price < low[10] //
  104. and price < low[11] //
  105. and price < low[11] //
  106. and price < low[12] //
  107. and price < low[13] //
  108. and price < low[14] //
  109. // //
  110. bearish_signal = (bearish_break[1] and not bearish_break) //
  111. bullish_signal = (bullish_break[1] and not bullish_break) //
  112. //END Definitions===============================================================================================================//
  113. //PLOTSHAPES BULLISH============================================================================================================//
  114. //label bullishlabel = na //
  115. if barstate.isconfirmed and bullish_signal and not only_bullish//bullish_break[1] and not bullish_break //
  116. bullishlabel = label.new( //
  117. bar_index, //
  118. y=0, //
  119. yloc=yloc.abovebar, //
  120. style= label.style_triangledown, //
  121. size = size.normal, //
  122. color = color.new(color.red, 0), //
  123. text = "Potential \n Bearish \n Reversal", //
  124. textcolor = color.new(color.red, 0) //
  125. ) //
  126. label.delete(bullishlabel[1]) //
  127. // //
  128. if barstate.isconfirmed and bullish_break //
  129. bullishline = line.new( //
  130. x1=bar_index, //
  131. y1=use_high_bearish, //
  132. x2=bar_index+30, //
  133. y2=use_high_bearish, //
  134. color = color.new(color.red, 0), //
  135. extend = extend_lines //
  136. ) //
  137. line.delete(bullishline[1]) //
  138. //PLOTSHAPES BEARISH============================================================================================================//
  139. //label bearishlabel = na //
  140. if barstate.isconfirmed and bearish_signal and not only_bearish//bearish_break[1] and not bearish_break //
  141. bearishlabel = label.new( //
  142. bar_index, //
  143. y=0, //
  144. yloc=yloc.belowbar, //
  145. style= label.style_triangleup, //
  146. size = size.normal, //
  147. color = color.new(color.green, 0), //
  148. text = "Potential \n Bullish \n Reversal", //
  149. textcolor = color.new(color.green, 0) //
  150. ) //
  151. label.delete(bearishlabel[1]) //
  152. // //
  153. if barstate.isconfirmed and bearish_break //
  154. bearishline = line.new( //
  155. bar_index, //
  156. use_low_bullish, //
  157. bar_index+30, //
  158. use_low_bullish, //
  159. color = color.new(color.green, 0), //
  160. extend = extend_lines //
  161. ) //
  162. line.delete(bearishline[1]) //
  163. //END Script====================================================================================================================//
  164. //SIGNALS
  165. alertcondition(bearish_signal, title = 'Bullish Reversal', message = 'Possible Bullish Reversal')
  166. alertcondition(bullish_signal, title = 'Bearish Reversal', message = 'Possible Bearish Reversal')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement