// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © AlexFuch //@version=5 indicator("Traders Trend Dashboard", shorttitle = "TTD", overlay = true, scale = scale.none, max_lines_count = 500) // Table Settings dashboard_position = input.session("Middle Right", "Posision", ["Top Right", "Bottom Right", "Top Left", "Bottom Left", "Top Center", "Bottom Center", "Middle Right"], group = 'Table Settings') text_size = input.session('Normal', "Size", options = ["Tiny", "Small", "Normal", "Large"], group = 'Table Settings') text_color = input(#d1d4dc, title = "Text Color", group = 'Table Settings') table_color = input(color.gray, title = "Border Color", group = 'Table Settings') uptrend_indicator = input("🟢", title = "Uptrend Indicator", group = 'Table Settings') downtrend_indicator = input("🔴", title = "Downtrend Indicator", group = 'Table Settings') neutraltrend_indicator = input("⚫️", title = "Neutral trend Indicator", group = 'Table Settings') max_table_size = 200 min_table_size = 10 // EMA Settings trend_identification_approach = input.session("Direction of a single EMA", "Trend Identification Approach", ["Direction of a single EMA", "Comparison of the two EMAs"], group = 'EMA Settings') ema1_length = input.int(title = "EMA Length", defval = 50, minval = 1, maxval = 800, group = 'EMA Settings') ema2_length = input.int(title = "Additional EMA Length", defval = 200, minval = 20, maxval = 800, tooltip = 'Note that the single EMA trend identification approach ignores this value.', group = 'EMA Settings') // Timeframe Settings show_1m = input(true, title = 'Show 1m', group = 'Timeframe Settings') show_3m = input(true, title = 'Show 3m ', group = 'Timeframe Settings') show_5m = input(true, title = 'Show 5m', group = 'Timeframe Settings') show_8m = input(false, title = 'Show 8m', group = 'Timeframe Settings') show_12m = input(false, title = 'Show 12m', group = 'Timeframe Settings') show_15m = input(true, title = 'Show 15m', group = 'Timeframe Settings') show_20m = input(false, title = 'Show 20m', group = 'Timeframe Settings') show_30m = input(false, title = 'Show 30m', group = 'Timeframe Settings') show_45m = input(false, title = 'Show 45m', group = 'Timeframe Settings') show_1h = input(true, title = 'Show 1h', group = 'Timeframe Settings') show_2h = input(false, title = 'Show 2h', group = 'Timeframe Settings') show_3h = input(false, title = 'Show 3h', group = 'Timeframe Settings') show_4h = input(true, title = 'Show 4h', group = 'Timeframe Settings') show_12h = input(true, title = 'Show 12h', group = 'Timeframe Settings') show_D = input(false, title = 'Show D', group = 'Timeframe Settings') show_W = input(false, title = 'Show W', group = 'Timeframe Settings') show_M = input(false, title = 'Show M', group = 'Timeframe Settings') // Calculation var table_position = dashboard_position == 'Top Right' ? position.top_right : dashboard_position == 'Top Left' ? position.top_left : dashboard_position == 'Top Center' ? position.top_center : dashboard_position == 'Bottom Right' ? position.bottom_right : dashboard_position == 'Bottom Left' ? position.bottom_left : dashboard_position == 'Bottom Center' ? position.bottom_center : dashboard_position == 'Middle Right' ? position.middle_right : dashboard_position == 'Middle Left' ? position.middle_left : position.middle_right var table_text_size = text_size == 'Normal' ? size.normal : text_size == 'Large' ? size.large : text_size == 'Tiny' ? size.tiny : text_size == 'Small' ? size.small : size.normal var t = table.new(table_position, 15, math.abs(max_table_size - min_table_size) + 2, frame_color = table_color, frame_width = 2, border_color = table_color, border_width = 2) calc_smma(src, len) => var float smma = na smma := na(smma) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len smma calc_zlema(src, len) => ema1 = ta.ema(src, len) ema2 = ta.ema(ema1, len) d = ema1 - ema2 ema1 + d check_impulse() => impulseLength = 34 impulseStrength = 9 hi = calc_smma(high, impulseLength) lo = calc_smma(low, impulseLength) mi = calc_zlema(hlc3, impulseLength) md = (mi > hi) ? (mi - hi) : (mi < lo) ? (mi - lo) : 0 md_prev = (mi[1] > hi[1]) ? (mi[1] - hi[1]) : (mi[1] < lo[1]) ? (mi[1] - lo[1]) : 0 sb = ta.sma(md, impulseStrength) sb_prev = ta.sma(md_prev, impulseStrength) sh = md - sb sh_prev = md_prev - sb_prev is_impulse = sh != 0 and sh_prev != 0 is_impulse get_trend_status() => impulse = check_impulse() ema1_current_candle = ta.ema(close, ema1_length) ema1_previous_candle = ema1_current_candle[1] if (trend_identification_approach == "Direction of a single EMA") ema1_previous_previous_candle = ema1_current_candle[2] trend_current_candle = not impulse ? neutraltrend_indicator : ema1_current_candle > ema1_previous_candle ? uptrend_indicator : ema1_current_candle < ema1_previous_candle ? downtrend_indicator : neutraltrend_indicator trend_previous_candle = not impulse ? neutraltrend_indicator : ema1_previous_candle > ema1_previous_previous_candle ? uptrend_indicator : ema1_previous_candle < ema1_previous_previous_candle ? downtrend_indicator : neutraltrend_indicator [trend_current_candle, trend_previous_candle] else ema2_current_candle = ta.ema(close, ema2_length) ema2_previous_candle = ema2_current_candle[1] trend_current_candle = not impulse ? neutraltrend_indicator : ema1_current_candle > ema2_current_candle ? uptrend_indicator : ema1_current_candle < ema2_current_candle ? downtrend_indicator : neutraltrend_indicator trend_previous_candle = not impulse ? neutraltrend_indicator : ema1_previous_candle > ema2_previous_candle ? uptrend_indicator : ema1_previous_candle < ema2_previous_candle ? downtrend_indicator : neutraltrend_indicator [trend_current_candle, trend_previous_candle] [trend_indicator_1m, _] = request.security(syminfo.tickerid, "1", get_trend_status()) [trend_indicator_3m, _] = request.security(syminfo.tickerid, "3", get_trend_status()) [trend_indicator_5m, _] = request.security(syminfo.tickerid, "5", get_trend_status()) [trend_indicator_8m, _] = request.security(syminfo.tickerid, "8", get_trend_status()) [trend_indicator_12m, _] = request.security(syminfo.tickerid, "12", get_trend_status()) [trend_indicator_15m, _] = request.security(syminfo.tickerid, "15", get_trend_status()) [trend_indicator_20m, _] = request.security(syminfo.tickerid, "20", get_trend_status()) [trend_indicator_30m, _] = request.security(syminfo.tickerid, "30", get_trend_status()) [trend_indicator_45m, _] = request.security(syminfo.tickerid, "45", get_trend_status()) [trend_indicator_1h, _] = request.security(syminfo.tickerid, "60", get_trend_status()) [trend_indicator_2h, _] = request.security(syminfo.tickerid, "120", get_trend_status()) [trend_indicator_3h, _] = request.security(syminfo.tickerid, "180", get_trend_status()) [trend_indicator_4h, _] = request.security(syminfo.tickerid, "240", get_trend_status()) [trend_indicator_12h, _] = request.security(syminfo.tickerid, "720", get_trend_status()) [trend_indicator_D, _] = request.security(syminfo.tickerid, "D", get_trend_status()) [trend_indicator_W, _] = request.security(syminfo.tickerid, "W", get_trend_status()) [trend_indicator_M, _] = request.security(syminfo.tickerid, "M", get_trend_status()) if (barstate.islast) if (show_1m) table.cell(t, 1, 2, "1m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 2, trend_indicator_1m, text_color = text_color, text_size = table_text_size) if (show_3m) table.cell(t, 1, 3, "3m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 3, trend_indicator_3m, text_color = text_color, text_size = table_text_size) if (show_5m) table.cell(t, 1, 4, "5m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 4, trend_indicator_5m, text_color = text_color, text_size = table_text_size) if (show_8m) table.cell(t, 1, 5, "8m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 5, trend_indicator_8m, text_color = text_color, text_size = table_text_size) if (show_12m) table.cell(t, 1, 6, "12m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 6, trend_indicator_12m, text_color = text_color, text_size = table_text_size) if (show_15m) table.cell(t, 1, 7, "15m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 7, trend_indicator_15m, text_color = text_color, text_size = table_text_size) if (show_20m) table.cell(t, 1, 8, "20m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 8, trend_indicator_20m, text_color = text_color, text_size = table_text_size) if (show_30m) table.cell(t, 1, 9, "30m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 9, trend_indicator_30m, text_color = text_color, text_size = table_text_size) if (show_45m) table.cell(t, 1, 10, "45m", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 10, trend_indicator_45m, text_color = text_color, text_size = table_text_size) if (show_1h) table.cell(t, 1, 11, "1h", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 11, trend_indicator_1h, text_color = text_color, text_size = table_text_size) if (show_2h) table.cell(t, 1, 12, "2h", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 12, trend_indicator_2h, text_color = text_color, text_size = table_text_size) if (show_3h) table.cell(t, 1, 13, "3h", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 13, trend_indicator_3h, text_color = text_color, text_size = table_text_size) if (show_4h) table.cell(t, 1, 14, "4h", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 14, trend_indicator_4h, text_color = text_color, text_size = table_text_size) if (show_12h) table.cell(t, 1, 15, "12h", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 15, trend_indicator_12h, text_color = text_color, text_size = table_text_size) if (show_D) table.cell(t, 1, 16, "D", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 16, trend_indicator_D, text_color = text_color, text_size = table_text_size) if (show_W) table.cell(t, 1, 17, "W", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 17, trend_indicator_W, text_color = text_color, text_size = table_text_size) if (show_M) table.cell(t, 1, 18, "M", text_color = text_color, text_size = table_text_size) table.cell(t, 5, 18, trend_indicator_M, text_color = text_color, text_size = table_text_size) [current_trend_indicator_current_timeframe, previous_trend_indicator_current_timeframe] = get_trend_status() alertcondition(current_trend_indicator_current_timeframe != previous_trend_indicator_current_timeframe, '0. Trend changed', '⏰ Trend changed on {{ticker}}:{{interval}}min') alertcondition(current_trend_indicator_current_timeframe != previous_trend_indicator_current_timeframe and current_trend_indicator_current_timeframe == uptrend_indicator, '1. Uptrend started', '🟢 Uptrend started on {{ticker}}:{{interval}}min') alertcondition(current_trend_indicator_current_timeframe != previous_trend_indicator_current_timeframe and current_trend_indicator_current_timeframe == downtrend_indicator, '2. Downtrend started', '🔴 Downtrend started on {{ticker}}:{{interval}}min') alertcondition(current_trend_indicator_current_timeframe != previous_trend_indicator_current_timeframe and current_trend_indicator_current_timeframe == neutraltrend_indicator, '3. Neutral trend started', '⚫️ Neutral trend started on {{ticker}}:{{interval}}min') alertcondition(trend_indicator_W == trend_indicator_D and trend_indicator_D == trend_indicator_4h, '4. W, D, 4h aligned', 'W, D, 4h {{ticker}} trend alignment') alertcondition(trend_indicator_D == trend_indicator_4h and trend_indicator_4h == trend_indicator_1h, '5. D, 4h, 1h aligned', 'D, 4h, 1h {{ticker}} trend alignment') alertcondition(trend_indicator_4h == trend_indicator_1h and trend_indicator_1h == trend_indicator_15m, '6. 4h, 1h, 15m aligned', '4h, 1h, 15m {{ticker}} trend alignment') alertcondition(trend_indicator_1h == trend_indicator_15m and trend_indicator_15m == trend_indicator_5m, '7. 1h, 15m, 5m aligned', '1h, 15m, 5m {{ticker}} trend alignment') alertcondition(trend_indicator_15m == trend_indicator_5m and trend_indicator_5m == trend_indicator_3m, '8. 15m, 5m, 3m aligned', '15m, 5m, 3m {{ticker}} trend alignment')