OPEN-SOURCE SCRIPT

Daily + 4H MACD & RSI Screener

48
i used this script for my swing trading entry.

//version=5
indicator("Daily + 4H MACD & RSI Screener", overlay=false)

// settings
rsiLength = input.int(14, "RSI Length")
rsiLevel = input.int(50, "RSI Threshold")
macdFast = input.int(12, "MACD Fast")
macdSlow = input.int(26, "MACD Slow")
macdSignal = input.int(9, "MACD Signal")

// ---- daily timeframe ----
dailyRsi = request.security(syminfo.tickerid, "D", ta.rsi(close, rsiLength))
[dailyMacd, dailySignal, _] = request.security(syminfo.tickerid, "D", ta.macd(close, macdFast, macdSlow, macdSignal))
dailyRsiPass = dailyRsi < rsiLevel
dailyMacdPass = dailyMacd < 0
dailyCondition = dailyRsiPass and dailyMacdPass

// ---- 4H timeframe ----
h4Rsi = request.security(syminfo.tickerid, "240", ta.rsi(close, rsiLength))
[h4Macd, h4Signal, _] = request.security(syminfo.tickerid, "240", ta.macd(close, macdFast, macdSlow, macdSignal))
h4RsiPass = h4Rsi < rsiLevel
h4MacdPass = h4Macd < 0
h4Condition = h4RsiPass and h4MacdPass

// ---- combined condition ----
finalCondition = dailyCondition and h4Condition

// plot signals
plotshape(finalCondition, style=shape.triangledown, location=location.top, color=color.red, size=size.large, title="Signal")
bgcolor(finalCondition ? color.new(color.red, 85) : na)

// ---- table (3 columns x 4 rows) ----
var table statusTable = table.new(position=position.top_right, columns=3, rows=4, border_width=1)

// headers
table.cell(statusTable, 0, 0, "Timeframe", text_color=color.white, bgcolor=color.new(color.black, 0))
table.cell(statusTable, 1, 0, "RSI", text_color=color.white, bgcolor=color.new(color.black, 0))
table.cell(statusTable, 2, 0, "MACD", text_color=color.white, bgcolor=color.new(color.black, 0))

// daily row
table.cell(statusTable, 0, 1, "Daily", text_color=color.white, bgcolor=color.new(color.black, 0))
table.cell(statusTable, 1, 1, str.tostring(dailyRsi, "#.##"),
text_color=color.white, bgcolor=dailyRsiPass ? color.new(color.green, 60) : color.new(color.red, 60))
table.cell(statusTable, 2, 1, str.tostring(dailyMacd, "#.##"),
text_color=color.white, bgcolor=dailyMacdPass ? color.new(color.green, 60) : color.new(color.red, 60))

// 4H row
table.cell(statusTable, 0, 2, "4H", text_color=color.white, bgcolor=color.new(color.black, 0))
table.cell(statusTable, 1, 2, str.tostring(h4Rsi, "#.##"),
text_color=color.white, bgcolor=h4RsiPass ? color.new(color.green, 60) : color.new(color.red, 60))
table.cell(statusTable, 2, 2, str.tostring(h4Macd, "#.##"),
text_color=color.white, bgcolor=h4MacdPass ? color.new(color.green, 60) : color.new(color.red, 60))

// status row (simulate colspan by using two adjacent cells with the same bgcolor)
table.cell(statusTable, 0, 3, "Status", text_color=color.white, bgcolor=color.new(color.black, 0))
statusText = finalCondition ? "match" : "no match"
statusBg = finalCondition ? color.new(color.green, 0) : color.new(color.red, 0)
table.cell(statusTable, 1, 3, statusText, text_color=color.white, bgcolor=statusBg, text_size=size.large)
table.cell(statusTable, 2, 3, "", text_color=color.white, bgcolor=statusBg)

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.