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/
- // © GustavoRubi
- //@version=5
- /////////////////////////
- indicator("[BullTrading] 1m Easy Scalping Sys v5.0", overlay=true)
- TF_1_time = input.timeframe("1", "Timeframe 1")
- TF_2_time = input.timeframe("10", "Timeframe 2")
- TF_3_time = input.timeframe("15", "Timeframe 3")
- TF_4_time = input.timeframe("30", "Timeframe 4")
- //========================================================================================================================================================================
- /// Making the colours
- //========================================================================================================================================================================
- upcolor = #00FF00
- downcolor = #f23645
- sidecolor = #FFFF00
- whitecolor = #ffffff
- //========================================================================================================================================================================
- /// Calling HTF's
- //========================================================================================================================================================================
- TF_1 = request.security(syminfo.tickerid, TF_1_time, open) < request.security(syminfo.tickerid, TF_1_time, close) ? true:false
- TF_2 = request.security(syminfo.tickerid, TF_2_time, open) < request.security(syminfo.tickerid, TF_2_time, close) ? true:false
- TF_3 = request.security(syminfo.tickerid, TF_3_time, open) < request.security(syminfo.tickerid, TF_3_time, close) ? true:false
- TF_4 = request.security(syminfo.tickerid, TF_4_time, open) < request.security(syminfo.tickerid, TF_4_time, close) ? true:false
- TF_global = TF_1 and TF_2 and TF_3 and TF_4
- TF_global_bear = TF_1 == false and TF_2 == false and TF_3 == false and TF_4 == false
- exitCondition_Long = TF_global_bear
- exitCondition_Short = TF_global
- //==========================================================================================================================================================================
- /// BULLTRADING HULL MA's
- //==========================================================================================================================================================================
- smooth = input(title='MTF Hull Smooth', defval=true)
- //==========================================================================================================================================================================
- //1st hull
- //==========================================================================================================================================================================
- hull_1_res = '1'// input.timeframe('1', "Hull 1st Resolution")
- hull_1_src_fast = request.security(syminfo.tickerid, hull_1_res, close)
- hull_1_src_slow = request.security(syminfo.tickerid, hull_1_res, close[1])
- hull_1_length = 840//input.int(840, minval=1) //2640
- 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)))
- 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)))
- hull_1_fast_Smooth = request.security(syminfo.tickerid, hull_1_res, hull_1_fast, barmerge.gaps_on, barmerge.lookahead_off)
- hull_1_fast_Step = request.security(syminfo.tickerid, hull_1_res, hull_1_fast, barmerge.gaps_off, barmerge.lookahead_off)
- hull_1_slow_Smooth = request.security(syminfo.tickerid, hull_1_res, hull_1_slow, barmerge.gaps_on, barmerge.lookahead_off)
- hull_1_slow_Step = request.security(syminfo.tickerid, hull_1_res, hull_1_slow, barmerge.gaps_off, barmerge.lookahead_off)
- //==========================================================================================================================================================================
- //2nd hull
- //==========================================================================================================================================================================
- hull_2_res = '1' //input.timeframe('1', "Hull 2nd Resolution")
- hull_2_src_fast = request.security(syminfo.tickerid, hull_2_res, close)
- hull_2_src_slow = request.security(syminfo.tickerid, hull_2_res, close[1])
- hull_2_length = 144//input.int(144, minval=1)
- 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)))
- 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)))
- hull_2_fast_Smooth = request.security(syminfo.tickerid, hull_2_res, hull_2_fast, barmerge.gaps_on, barmerge.lookahead_off)
- hull_2_fast_Step = request.security(syminfo.tickerid, hull_2_res, hull_2_fast, barmerge.gaps_off, barmerge.lookahead_off)
- hull_2_slow_Smooth = request.security(syminfo.tickerid, hull_2_res, hull_2_slow, barmerge.gaps_on, barmerge.lookahead_off)
- hull_2_slow_Step = request.security(syminfo.tickerid, hull_2_res, hull_2_slow, barmerge.gaps_off, barmerge.lookahead_off)
- //==========================================================================================================================================================================
- //3rd hull
- //==========================================================================================================================================================================
- hull_3_res = input.timeframe('1', "Hull 3rd Resolution")
- hull_3_src_fast = request.security(syminfo.tickerid, hull_3_res, close)
- hull_3_src_slow = request.security(syminfo.tickerid, hull_3_res, close[1])
- hull_3_length = input.int(88, minval=1) //2640
- 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)))
- 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)))
- hull_3_fast_Smooth = request.security(syminfo.tickerid, hull_3_res, hull_3_fast, barmerge.gaps_on, barmerge.lookahead_off)
- hull_3_fast_Step = request.security(syminfo.tickerid, hull_3_res, hull_3_fast, barmerge.gaps_off, barmerge.lookahead_off)
- hull_3_slow_Smooth = request.security(syminfo.tickerid, hull_3_res, hull_3_slow, barmerge.gaps_on, barmerge.lookahead_off)
- hull_3_slow_Step = request.security(syminfo.tickerid, hull_3_res, hull_3_slow, barmerge.gaps_off, barmerge.lookahead_off)
- //==========================================================================================================================================================================
- //Hull colors
- //==========================================================================================================================================================================
- col_hull_1 = hull_1_fast_Smooth > hull_1_slow_Smooth? color.lime : color.red
- col_hull_2 = hull_2_fast_Smooth > hull_2_slow_Smooth? color.lime : color.red
- col_hull_3 = hull_3_fast_Smooth > hull_3_slow_Smooth? color.lime : color.red
- //==========================================================================================================================================================================
- //Hull plots
- //==========================================================================================================================================================================
- //plot(smooth ? hull_1_fast_Smooth : hull_1_fast_Step, color= col_hull_1, style=plot.style_line, linewidth=1, title='1st Hull')
- //plot(smooth ? hull_2_fast_Smooth : hull_2_fast_Step, color= col_hull_2, style=plot.style_line, linewidth=1, title='2nd Hull')
- plot(smooth ? hull_3_fast_Smooth : hull_3_fast_Step, color= col_hull_3, style=plot.style_line, linewidth=1, title='3rd Hull')
- ////////////////////////////////////
- ////-ATR-///////////////////////////
- ////////////////////////////////////
- length = input.int(title='Length', defval=14, minval=1)
- smoothing = input.string(title='Smoothing', defval='RMA', options=['RMA', 'SMA', 'EMA', 'WMA'])
- m = input(0.85, 'Multiplier')
- src1 = input(high)
- src2 = input(low)
- pline = input(false, 'Show Price Lines')
- col1 = input(color.blue, 'ATR Text Color')
- col2 = input.color(color.teal, 'Low Text Color', inline='1')
- col3 = input.color(color.red, 'High Text Color', inline='2')
- collong = input.color(color.purple, 'Low Line Color', inline='1')
- colshort = input.color(color.purple, 'High Line Color', inline='2')
- ma_function(source, length) =>
- if smoothing == 'RMA'
- ta.rma(source, length)
- else
- if smoothing == 'SMA'
- ta.sma(source, length)
- else
- if smoothing == 'EMA'
- ta.ema(source, length)
- else
- ta.wma(source, length)
- a = ma_function(ta.tr(true), length) * m
- x = ma_function(ta.tr(true), length) * m + src1
- x2 = src2 - ma_function(ta.tr(true), length) * m
- p1 = plot(x, title='ATR Short Stop Loss', color=colshort, trackprice=pline ? true : false, transp=20)
- p2 = plot(x2, title='ATR Long Stop Loss', color=collong, trackprice=pline ? true : false, transp=20)
- var table Table = table.new(position.bottom_center, 3, 1, border_width=3)
- f_fillCell(_table, _column, _row, _value, _timeframe) =>
- _cellText = _timeframe + str.tostring(_value, '#.#')
- table.cell(_table, _column, _row, _cellText, text_color=col1)
- table.cell_set_text_color(Table, 1, 0, color.new(col3, transp=0))
- table.cell_set_text_color(Table, 2, 0, color.new(col2, transp=0))
- if barstate.islast
- f_fillCell(Table, 0, 0, a, 'ATR: ')
- f_fillCell(Table, 1, 0, x, 'H: ')
- f_fillCell(Table, 2, 0, x2, 'L: ')
- ////////////////////////////////////
- ////////////////////////////////////
- ////////////////////////////////////
- longCondition = TF_global and hull_2_fast_Smooth > hull_2_fast_Step
- shortCondition = TF_global_bear and hull_2_fast_Smooth < hull_2_fast_Step
- barcolor(TF_global?upcolor:TF_global_bear?downcolor:sidecolor)
- alertcondition(longCondition, "Green Bar Alert", "Green Bar")
- alertcondition(shortCondition, "Red Bar Alert", "Red Bar")
- ////////////////////////////////////
- ////////////////////////////////////
- ////////////////////////////////////
Advertisement