Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- // CryptoSignalScanner.com by SEOCO
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- indicator(title='CryptoSignalScanner - MACD Multiple Time Frames', shorttitle='MACD MTF')
- //-------------------------------------------------------------------------------------------------------------
- // MACD Inputs Settings ---------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- fast_length = input.int(title='Fast Length', defval=12, group='MACD Settings')
- slow_length = input.int(title='Slow Length', defval=26, group='MACD Settings')
- src = input.source(title='Source', defval=close, group='MACD Settings')
- signal_length = input.int(title='Signal Smoothing', minval=1, maxval=50, defval=9, group='MACD Settings')
- //-------------------------------------------------------------------------------------------------------------
- // MACD Input Display Settings --------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- show_macd_average = input.bool(true, title='Show MACD Average Line', group='Display Settings')
- show_signal_average = input.bool(false, title='Show Signal Average Line', group='Display Settings')
- show_macd_default = input.bool(true, title='Show MACD Line Current Timeframe', group='Display Settings')
- show_signal_default = input.bool(true, title='Show Signal Line Current Timeframe', group='Display Settings')
- show_macd_15m = input.bool(true, title='Show 15 minutes MACD Line', group='Display Settings')
- show_signal_15m = input.bool(false, title='Show 15 minutes Signal Line', group='Display Settings')
- show_macd_30m = input.bool(true, title='Show 30 minutes MACD Line', group='Display Settings')
- show_signal_30m = input.bool(false, title='Show 30 minutes Signal Line', group='Display Settings')
- show_macd_1h = input.bool(true, title='Show 1 hour MACD Line', group='Display Settings')
- show_signal_1h = input.bool(false, title='Show 1 hour Signal Line', group='Display Settings')
- show_macd_2h = input.bool(true, title='Show 2 hour MACD Line', group='Display Settings')
- show_signal_2h = input.bool(false, title='Show 2 hour Signal Line', group='Display Settings')
- show_macd_4h = input.bool(true, title='Show 4 hour MACD Line', group='Display Settings')
- show_signal_4h = input.bool(false, title='Show 4 hour Signal Line', group='Display Settings')
- //-------------------------------------------------------------------------------------------------------------
- // Define Default Colors --------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- col_grow_above = #26A69A
- col_grow_below = #FFCDD2
- col_fall_above = #B2DFDB
- col_fall_below = #EF5350
- col_macd = #0094ff
- col_signal = #ff6a00
- col_base = #f4b77d
- col_macd_avg = #f4b77d //#3498DB
- col_signal_avg = #E74C3C
- transparent = color.new(color.white, 100)
- col_macd_average = show_macd_average ? col_base : transparent
- col_macd_default = show_macd_default ? col_macd : transparent
- col_macd_15m = show_macd_15m ? col_macd : transparent
- col_macd_30m = show_macd_30m ? col_macd : transparent
- col_macd_1h = show_macd_1h ? col_macd : transparent
- col_macd_2h = show_macd_2h ? col_macd : transparent
- col_macd_4h = show_macd_4h ? col_macd : transparent
- col_signal_average = show_signal_average ? col_signal_avg : transparent
- col_signal_default = show_signal_default ? col_signal : transparent
- col_signal_15m = show_signal_15m ? col_signal : transparent
- col_signal_30m = show_signal_30m ? col_signal : transparent
- col_signal_1h = show_signal_1h ? col_signal : transparent
- col_signal_2h = show_signal_2h ? col_signal : transparent
- col_signal_4h = show_signal_4h ? col_signal : transparent
- //-------------------------------------------------------------------------------------------------------------
- //Calculate MACD Line -----------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- macd = ta.ema(src, fast_length) - ta.ema(src, slow_length)
- macd_15m = request.security(syminfo.tickerid, '15', ta.ema(src, fast_length) - ta.ema(src, slow_length))
- macd_30m = request.security(syminfo.tickerid, '30', ta.ema(src, fast_length) - ta.ema(src, slow_length))
- macd_1h = request.security(syminfo.tickerid, '60', ta.ema(src, fast_length) - ta.ema(src, slow_length))
- macd_2h = request.security(syminfo.tickerid, '120', ta.ema(src, fast_length) - ta.ema(src, slow_length))
- macd_4h = request.security(syminfo.tickerid, '240', ta.ema(src, fast_length) - ta.ema(src, slow_length))
- macd_avg = (macd_15m + macd_30m + macd_1h + macd_2h + macd_4h) / 5
- //-------------------------------------------------------------------------------------------------------------
- // Calculate Signal Line --------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- signal = ta.ema(macd, signal_length)
- signal_15m = ta.ema(macd_15m, signal_length)
- signal_30m = ta.ema(macd_30m, signal_length)
- signal_1h = ta.ema(macd_1h, signal_length)
- signal_2h = ta.ema(macd_2h, signal_length)
- signal_4h = ta.ema(macd_4h, signal_length)
- signal_avg = (signal_15m + signal_30m + signal_1h + signal_2h + signal_4h) / 5
- //-------------------------------------------------------------------------------------------------------------
- // Calculate Histogram ----------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- hist = macd - signal
- //-------------------------------------------------------------------------------------------------------------
- // Plot Lines -------------------------------------------------------------------------------------------------
- //-------------------------------------------------------------------------------------------------------------
- plot(hist, title='Histogram', style=plot.style_columns, color=hist >= 0 ? hist[1] < hist ? col_grow_above : col_fall_above : hist[1] < hist ? col_grow_below : col_fall_below)
- plot(macd, title='MACD', color=col_macd_default, editable=false)
- plot(macd_15m, title='MACD 15m', color=col_macd_15m, editable=false)
- plot(macd_30m, title='MACD 30m', color=col_macd_30m, editable=false)
- plot(macd_1h, title='MACD 1h', color=col_macd_1h, editable=false)
- plot(macd_2h, title='MACD 2h', color=col_macd_2h, editable=false)
- plot(macd_4h, title='MACD 4h', color=col_macd_4h, editable=false)
- plot(macd_avg, title='MACD Average', color=col_macd_average, linewidth=3, editable=false)
- plot(signal, title='Signal', color=col_signal_default, editable=false)
- plot(signal_15m, title='Signal 15m', color=col_signal_15m, editable=false)
- plot(signal_30m, title='Signal 30m', color=col_signal_30m, editable=false)
- plot(signal_1h, title='Signal 1h', color=col_signal_1h, editable=false)
- plot(signal_2h, title='Signal 2h', color=col_signal_2h, editable=false)
- plot(signal_4h, title='Signal 4h', color=col_signal_4h, editable=false)
- plot(signal_avg, title='Signal Average', color=col_signal_average, linewidth=3, editable=false)
Advertisement
Add Comment
Please, Sign In to add comment