← All Analyses
PEPPERSTONEUKXAUUSD
Bearish

trading view

Trad Shubahm
Trad Shubahm
3d ago
trading view

//@version=6

indicator("SMART AI - Forex Multi Timeframe", overlay=true)

//────────────────────────────────────────────

// SETTINGS

//────────────────────────────────────────────

fastLen = input.int(20, "Fast EMA")

slowLen = input.int(50, "Slow EMA")

rsiLen = input.int(14, "RSI Length")

adxLen = input.int(14, "ADX Length")

//────────────────────────────────────────────

// TREND FUNCTION

//────────────────────────────────────────────

getTrend() =>

    emaFast = ta.ema(close, fastLen)

    emaSlow = ta.ema(close, slowLen)

    rsiVal = ta.rsi(close, rsiLen)

    macdLine = ta.ema(close, 12) - ta.ema(close, 26)

    signalLine = ta.ema(macdLine, 9)

    bullish = emaFast > emaSlow and rsiVal > 50 and macdLine > signalLine

    bearish = emaFast < emaSlow and rsiVal < 50 and macdLine < signalLine

    bullish ? 1 : bearish ? -1 : 0

//────────────────────────────────────────────

// MULTI TIMEFRAME DATA

//────────────────────────────────────────────

monthly = request.security(syminfo.tickerid, "1M", getTrend())

weekly = request.security(syminfo.tickerid, "1W", getTrend())

daily = request.security(syminfo.tickerid, "1D", getTrend())

h12 = request.security(syminfo.tickerid, "720", getTrend())

h8 = request.security(syminfo.tickerid, "480", getTrend())

h4 = request.security(syminfo.tickerid, "240", getTrend())

h2 = request.security(syminfo.tickerid, "120", getTrend())

h1 = request.security(syminfo.tickerid, "60", getTrend())

m30 = request.security(syminfo.tickerid, "30", getTrend())

m15 = request.security(syminfo.tickerid, "15", getTrend())

m5 = request.security(syminfo.tickerid, "5", getTrend())

m3 = request.security(syminfo.tickerid, "3", getTrend())

m1 = request.security(syminfo.tickerid, "1", getTrend())

//────────────────────────────────────────────

// HELPER

//────────────────────────────────────────────

trendText(v) =>

    v == 1 ? "Bullish" : v == -1 ? "Bearish" : "Neutral"

trendColor(v) =>

    v == 1 ? color.lime : v == -1 ? color.red : color.orange

//────────────────────────────────────────────

// SCORE

//────────────────────────────────────────────

score =

     monthly +

     weekly +

     daily +

     h12 +

     h8 +

     h4 +

     h2 +

     h1 +

     m30 +

     m15 +

     m5 +

     m3 +

     m1

totalTF = 13

bullCount =

     (monthly == 1 ? 1 : 0) +

     (weekly == 1 ? 1 : 0) +

     (daily == 1 ? 1 : 0) +

     (h12 == 1 ? 1 : 0) +

     (h8 == 1 ? 1 : 0) +

     (h4 == 1 ? 1 : 0) +

     (h2 == 1 ? 1 : 0) +

     (h1 == 1 ? 1 : 0) +

     (m30 == 1 ? 1 : 0) +

     (m15 == 1 ? 1 : 0) +

     (m5 == 1 ? 1 : 0) +

     (m3 == 1 ? 1 : 0) +

     (m1 == 1 ? 1 : 0)

bearCount =

     (monthly == -1 ? 1 : 0) +

     (weekly == -1 ? 1 : 0) +

     (daily == -1 ? 1 : 0) +

     (h12 == -1 ? 1 : 0) +

     (h8 == -1 ? 1 : 0) +

     (h4 == -1 ? 1 : 0) +

     (h2 == -1 ? 1 : 0) +

     (h1 == -1 ? 1 : 0) +

     (m30 == -1 ? 1 : 0) +

     (m15 == -1 ? 1 : 0) +

     (m5 == -1 ? 1 : 0) +

     (m3 == -1 ? 1 : 0) +

     (m1 == -1 ? 1 : 0)

overall =

     bullCount > bearCount ? "Bullish" :

     bearCount > bullCount ? "Bearish" :

     "Neutral"

alignment = math.round(math.max(bullCount, bearCount) / totalTF * 100)

//────────────────────────────────────────────

// SIGNAL LOGIC

//────────────────────────────────────────────

longSetup =

     daily == 1 and h4 == 1 and h1 == 1 and

     m15 == 1 and m5 == 1

shortSetup =

     daily == -1 and h4 == -1 and h1 == -1 and

     m15 == -1 and m5 == -1

signal =

     longSetup ? "BUY SETUP" :

     shortSetup ? "SELL SETUP" :

     "WAITING"

//────────────────────────────────────────────

// DASHBOARD

//────────────────────────────────────────────

var table dash = table.new(

     position.top_right,

     2,

     19,

     border_width=1,

     frame_width=1)

if barstate.islast

    table.cell(dash, 0, 0, "SMART AI 🔥",

         text_color=color.orange,

         bgcolor=color.black)

    table.cell(dash, 1, 0, "ACTIVE",

         text_color=color.lime,

         bgcolor=color.black)

    table.cell(dash, 0, 1, "Monthly Trend")

    table.cell(dash, 1, 1, trendText(monthly),

         text_color=trendColor(monthly))

    table.cell(dash, 0, 2, "Weekly Trend")

    table.cell(dash, 1, 2, trendText(weekly),

         text_color=trendColor(weekly))

    table.cell(dash, 0, 3, "Daily Trend")

    table.cell(dash, 1, 3, trendText(daily),

         text_color=trendColor(daily))

    table.cell(dash, 0, 4, "12H Trend")

    table.cell(dash, 1, 4, trendText(h12),

         text_color=trendColor(h12))

    table.cell(dash, 0, 5, "8H Trend")

    table.cell(dash, 1, 5, trendText(h8),

         text_color=trendColor(h8))

    table.cell(dash, 0, 6, "4H Trend")

    table.cell(dash, 1, 6, trendText(h4),

         text_color=trendColor(h4))

    table.cell(dash, 0, 7, "2H Trend")

    table.cell(dash, 1, 7, trendText(h2),

         text_color=trendColor(h2))

    table.cell(dash, 0, 8, "1H Trend")

    table.cell(dash, 1, 8, trendText(h1),

         text_color=trendColor(h1))

    table.cell(dash, 0, 9, "30min Trend")

    table.cell(dash, 1, 9, trendText(m30),

         text_color=trendColor(m30))

    table.cell(dash, 0, 10, "15min Trend")

    table.cell(dash, 1, 10, trendText(m15),

         text_color=trendColor(m15))

    table.cell(dash, 0, 11, "5min Trend")

    table.cell(dash, 1, 11, trendText(m5),

         text_color=trendColor(m5))

    table.cell(dash, 0, 12, "3min Trend")

    table.cell(dash, 1, 12, trendText(m3),

         text_color=trendColor(m3))

    table.cell(dash, 0, 13, "1min Trend")

    table.cell(dash, 1, 13, trendText(m1),

         text_color=trendColor(m1))

    table.cell(dash, 0, 14, "Overall Trend")

    table.cell(dash, 1, 14, overall,

         text_color=overall == "Bullish" ? color.lime :

                    overall == "Bearish" ? color.red :

                    color.orange)

    table.cell(dash, 0, 15, "Trend Alignment")

    table.cell(dash, 1, 15, str.tostring(alignment) + "%",

         text_color=color.white)

    table.cell(dash, 0, 16, "Bullish TF")

    table.cell(dash, 1, 16, str.tostring(bullCount),

         text_color=color.lime)

    table.cell(dash, 0, 17, "Bearish TF")

    table.cell(dash, 1, 17, str.tostring(bearCount),

         text_color=color.red)

    table.cell(dash, 0, 18, "Signal Status")

    table.cell(dash, 1, 18, signal,

         text_color=signal == "BUY SETUP" ? color.lime :

                    signal == "SELL SETUP" ? color.red :

                    color.orange)

//────────────────────────────────────────────

// ALERTS

//────────────────────────────────────────────

alertcondition(

     longSetup,

     title="SMART AI BUY SETUP",

     message="SMART AI: Multi-Timeframe BUY setup detected.")

alertcondition(

     shortSetup,

     title="SMART AI SELL SETUP",

     message="SMART AI: Multi-Timeframe SELL setup detected.")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by GoCharting. Read more in the Terms of Use.

Comments (0)

Loading comments…