igorkrnic

Untitled

Jun 22nd, 2022
84
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.50 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. // © GustavoRubi
  3.  
  4. //@version=5
  5.  
  6.  
  7.  
  8. /////////////////////////
  9.  
  10. indicator("[BullTrading] 1m Easy Scalping Sys v5.0", overlay=true)
  11.  
  12. TF_1_time = input.timeframe("1", "Timeframe 1")
  13. TF_2_time = input.timeframe("10", "Timeframe 2")
  14. TF_3_time = input.timeframe("15", "Timeframe 3")
  15. TF_4_time = input.timeframe("30", "Timeframe 4")
  16.  
  17. //========================================================================================================================================================================
  18. /// Making the colours
  19. //========================================================================================================================================================================
  20.  
  21. upcolor = #00FF00
  22. downcolor = #f23645
  23. sidecolor = #FFFF00
  24. whitecolor = #ffffff
  25. //========================================================================================================================================================================
  26. /// Calling HTF's
  27. //========================================================================================================================================================================
  28.  
  29.  
  30.  
  31. TF_1 = request.security(syminfo.tickerid, TF_1_time, open) < request.security(syminfo.tickerid, TF_1_time, close) ? true:false
  32. TF_2 = request.security(syminfo.tickerid, TF_2_time, open) < request.security(syminfo.tickerid, TF_2_time, close) ? true:false
  33. TF_3 = request.security(syminfo.tickerid, TF_3_time, open) < request.security(syminfo.tickerid, TF_3_time, close) ? true:false
  34. TF_4 = request.security(syminfo.tickerid, TF_4_time, open) < request.security(syminfo.tickerid, TF_4_time, close) ? true:false
  35.  
  36.  
  37.  
  38. TF_global = TF_1 and TF_2 and TF_3 and TF_4
  39. TF_global_bear = TF_1 == false and TF_2 == false and TF_3 == false and TF_4 == false
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. exitCondition_Long = TF_global_bear
  47. exitCondition_Short = TF_global
  48.  
  49.  
  50. //==========================================================================================================================================================================
  51. /// BULLTRADING HULL MA's
  52. //==========================================================================================================================================================================
  53. smooth = input(title='MTF Hull Smooth', defval=true)
  54. //==========================================================================================================================================================================
  55. //1st hull
  56. //==========================================================================================================================================================================
  57.  
  58. hull_1_res = '1'// input.timeframe('1', "Hull 1st Resolution")
  59. hull_1_src_fast = request.security(syminfo.tickerid, hull_1_res, close)
  60. hull_1_src_slow = request.security(syminfo.tickerid, hull_1_res, close[1])
  61.  
  62. hull_1_length = 840//input.int(840, minval=1) //2640
  63.  
  64. hull_1_fast = ta.wma(2*ta.wma(hull_1_src_fast, hull_1_length/2)-ta.wma(hull_1_src_fast, hull_1_length), math.floor(math.sqrt(hull_1_length)))
  65. hull_1_slow = ta.wma(2*ta.wma(hull_1_src_slow, hull_1_length/2)-ta.wma(hull_1_src_slow, hull_1_length), math.floor(math.sqrt(hull_1_length)))
  66.  
  67. hull_1_fast_Smooth = request.security(syminfo.tickerid, hull_1_res, hull_1_fast, barmerge.gaps_on, barmerge.lookahead_off)
  68. hull_1_fast_Step = request.security(syminfo.tickerid, hull_1_res, hull_1_fast, barmerge.gaps_off, barmerge.lookahead_off)
  69.  
  70. hull_1_slow_Smooth = request.security(syminfo.tickerid, hull_1_res, hull_1_slow, barmerge.gaps_on, barmerge.lookahead_off)
  71. hull_1_slow_Step = request.security(syminfo.tickerid, hull_1_res, hull_1_slow, barmerge.gaps_off, barmerge.lookahead_off)
  72.  
  73. //==========================================================================================================================================================================
  74. //2nd hull
  75. //==========================================================================================================================================================================
  76. hull_2_res = '1' //input.timeframe('1', "Hull 2nd Resolution")
  77. hull_2_src_fast = request.security(syminfo.tickerid, hull_2_res, close)
  78. hull_2_src_slow = request.security(syminfo.tickerid, hull_2_res, close[1])
  79.  
  80. hull_2_length = 144//input.int(144, minval=1)
  81.  
  82. hull_2_fast = ta.wma(2*ta.wma(hull_2_src_fast, hull_2_length/2)-ta.wma(hull_2_src_fast, hull_2_length), math.floor(math.sqrt(hull_2_length)))
  83. hull_2_slow = ta.wma(2*ta.wma(hull_2_src_slow, hull_2_length/2)-ta.wma(hull_2_src_slow, hull_2_length), math.floor(math.sqrt(hull_2_length)))
  84.  
  85. hull_2_fast_Smooth = request.security(syminfo.tickerid, hull_2_res, hull_2_fast, barmerge.gaps_on, barmerge.lookahead_off)
  86. hull_2_fast_Step = request.security(syminfo.tickerid, hull_2_res, hull_2_fast, barmerge.gaps_off, barmerge.lookahead_off)
  87.  
  88. hull_2_slow_Smooth = request.security(syminfo.tickerid, hull_2_res, hull_2_slow, barmerge.gaps_on, barmerge.lookahead_off)
  89. hull_2_slow_Step = request.security(syminfo.tickerid, hull_2_res, hull_2_slow, barmerge.gaps_off, barmerge.lookahead_off)
  90.  
  91. //==========================================================================================================================================================================
  92. //3rd hull
  93. //==========================================================================================================================================================================
  94.  
  95. hull_3_res = input.timeframe('1', "Hull 3rd Resolution")
  96. hull_3_src_fast = request.security(syminfo.tickerid, hull_3_res, close)
  97. hull_3_src_slow = request.security(syminfo.tickerid, hull_3_res, close[1])
  98.  
  99. hull_3_length = input.int(88, minval=1) //2640
  100.  
  101. hull_3_fast = ta.wma(2*ta.wma(hull_3_src_fast, hull_3_length/2)-ta.wma(hull_3_src_fast, hull_3_length), math.floor(math.sqrt(hull_3_length)))
  102. hull_3_slow = ta.wma(2*ta.wma(hull_3_src_slow, hull_3_length/2)-ta.wma(hull_3_src_slow, hull_3_length), math.floor(math.sqrt(hull_3_length)))
  103.  
  104. hull_3_fast_Smooth = request.security(syminfo.tickerid, hull_3_res, hull_3_fast, barmerge.gaps_on, barmerge.lookahead_off)
  105. hull_3_fast_Step = request.security(syminfo.tickerid, hull_3_res, hull_3_fast, barmerge.gaps_off, barmerge.lookahead_off)
  106.  
  107. hull_3_slow_Smooth = request.security(syminfo.tickerid, hull_3_res, hull_3_slow, barmerge.gaps_on, barmerge.lookahead_off)
  108. hull_3_slow_Step = request.security(syminfo.tickerid, hull_3_res, hull_3_slow, barmerge.gaps_off, barmerge.lookahead_off)
  109. //==========================================================================================================================================================================
  110. //Hull colors
  111. //==========================================================================================================================================================================
  112. col_hull_1 = hull_1_fast_Smooth > hull_1_slow_Smooth? color.lime : color.red
  113. col_hull_2 = hull_2_fast_Smooth > hull_2_slow_Smooth? color.lime : color.red
  114. col_hull_3 = hull_3_fast_Smooth > hull_3_slow_Smooth? color.lime : color.red
  115. //==========================================================================================================================================================================
  116. //Hull plots
  117. //==========================================================================================================================================================================
  118. //plot(smooth ? hull_1_fast_Smooth : hull_1_fast_Step, color= col_hull_1, style=plot.style_line, linewidth=1, title='1st Hull')
  119. //plot(smooth ? hull_2_fast_Smooth : hull_2_fast_Step, color= col_hull_2, style=plot.style_line, linewidth=1, title='2nd Hull')
  120. plot(smooth ? hull_3_fast_Smooth : hull_3_fast_Step, color= col_hull_3, style=plot.style_line, linewidth=1, title='3rd Hull')
  121.  
  122.  
  123.  
  124.  
  125. ////////////////////////////////////
  126. ////-ATR-///////////////////////////
  127. ////////////////////////////////////
  128.  
  129. length = input.int(title='Length', defval=14, minval=1)
  130. smoothing = input.string(title='Smoothing', defval='RMA', options=['RMA', 'SMA', 'EMA', 'WMA'])
  131. m = input(0.85, 'Multiplier')
  132. src1 = input(high)
  133. src2 = input(low)
  134. pline = input(false, 'Show Price Lines')
  135. col1 = input(color.blue, 'ATR Text Color')
  136. col2 = input.color(color.teal, 'Low Text Color', inline='1')
  137. col3 = input.color(color.red, 'High Text Color', inline='2')
  138.  
  139. collong = input.color(color.purple, 'Low Line Color', inline='1')
  140. colshort = input.color(color.purple, 'High Line Color', inline='2')
  141.  
  142. ma_function(source, length) =>
  143. if smoothing == 'RMA'
  144. ta.rma(source, length)
  145. else
  146. if smoothing == 'SMA'
  147. ta.sma(source, length)
  148. else
  149. if smoothing == 'EMA'
  150. ta.ema(source, length)
  151. else
  152. ta.wma(source, length)
  153.  
  154. a = ma_function(ta.tr(true), length) * m
  155. x = ma_function(ta.tr(true), length) * m + src1
  156. x2 = src2 - ma_function(ta.tr(true), length) * m
  157.  
  158. p1 = plot(x, title='ATR Short Stop Loss', color=colshort, trackprice=pline ? true : false, transp=20)
  159. p2 = plot(x2, title='ATR Long Stop Loss', color=collong, trackprice=pline ? true : false, transp=20)
  160.  
  161. var table Table = table.new(position.bottom_center, 3, 1, border_width=3)
  162.  
  163. f_fillCell(_table, _column, _row, _value, _timeframe) =>
  164.  
  165. _cellText = _timeframe + str.tostring(_value, '#.#')
  166. table.cell(_table, _column, _row, _cellText, text_color=col1)
  167. table.cell_set_text_color(Table, 1, 0, color.new(col3, transp=0))
  168. table.cell_set_text_color(Table, 2, 0, color.new(col2, transp=0))
  169.  
  170. if barstate.islast
  171. f_fillCell(Table, 0, 0, a, 'ATR: ')
  172. f_fillCell(Table, 1, 0, x, 'H: ')
  173. f_fillCell(Table, 2, 0, x2, 'L: ')
  174.  
  175.  
  176. ////////////////////////////////////
  177. ////////////////////////////////////
  178. ////////////////////////////////////
  179. longCondition = TF_global and hull_2_fast_Smooth > hull_2_fast_Step
  180.  
  181.  
  182. shortCondition = TF_global_bear and hull_2_fast_Smooth < hull_2_fast_Step
  183.  
  184. barcolor(TF_global?upcolor:TF_global_bear?downcolor:sidecolor)
  185.  
  186. alertcondition(longCondition, "Green Bar Alert", "Green Bar")
  187. alertcondition(shortCondition, "Red Bar Alert", "Red Bar")
  188.  
  189.  
  190. ////////////////////////////////////
  191. ////////////////////////////////////
  192. ////////////////////////////////////
  193.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment