OPEN-SOURCE SCRIPT
Daily + 4H MACD & RSI Screener

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)
//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)
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。